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

# · Swig · 50 lines · 33 code · 15 blank · 2 comment · 0 complexity · bb875199c7516f35250f32a3eb592d52 MD5 · raw file

  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>;