PageRenderTime 44ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/template_typedef_inherit.i

#
Swig | 50 lines | 33 code | 15 blank | 2 comment | 0 complexity | bb875199c7516f35250f32a3eb592d52 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module template_typedef_inherit
  2. // Bug 3378145
  3. %include std_string.i
  4. %inline %{
  5. #include <string> // for std::string
  6. typedef std::string String;
  7. namespace Type {
  8. template <class T> class TypedInterfaceObject {};
  9. template <class T> class TypedCollectionInterfaceObject : public TypedInterfaceObject<T> {
  10. public:
  11. typedef T ImplementationType;
  12. typedef typename ImplementationType::ElementType ImplementationElementType;
  13. /** Method add() appends an element to the collection */
  14. void add(const ImplementationElementType & elt) {}
  15. };
  16. template <class T> class PersistentCollection {
  17. public:
  18. typedef T ElementType;
  19. /** Method add() appends an element to the collection */
  20. inline virtual void add(const T & elt) {}
  21. };
  22. }
  23. %}
  24. %template(StringPersistentCollection) Type::PersistentCollection<String>;
  25. %inline %{
  26. namespace Type {
  27. class DescriptionImplementation : public PersistentCollection<String> {
  28. public:
  29. typedef PersistentCollection<String>::ElementType ElementType;
  30. DescriptionImplementation() {}
  31. };
  32. }
  33. %}
  34. %template(DescriptionImplementationTypedInterfaceObject) Type::TypedInterfaceObject<Type::DescriptionImplementation>;
  35. %template(DescriptionImplementationTypedCollectionInterfaceObject) Type::TypedCollectionInterfaceObject<Type::DescriptionImplementation>;