PageRenderTime 28ms CodeModel.GetById 22ms app.highlight 2ms RepoModel.GetById 1ms 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
 1%module template_typedef_inherit
 2
 3// Bug 3378145
 4
 5%include std_string.i
 6
 7%inline %{
 8#include <string>                // for std::string
 9
10typedef std::string String;
11
12namespace Type {
13  template <class T> class TypedInterfaceObject {};
14
15  template <class T> class TypedCollectionInterfaceObject : public TypedInterfaceObject<T> {
16  public:
17    typedef T                                                   ImplementationType;
18    typedef typename ImplementationType::ElementType            ImplementationElementType;
19
20    /** Method add() appends an element to the collection */
21    void add(const ImplementationElementType & elt) {}
22  };
23
24  template <class T> class PersistentCollection {
25  public:
26    typedef T ElementType;
27
28    /** Method add() appends an element to the collection */
29    inline virtual void add(const T & elt) {}
30  };
31}
32%}
33
34%template(StringPersistentCollection) Type::PersistentCollection<String>;
35
36%inline %{
37
38namespace Type {
39  class DescriptionImplementation : public PersistentCollection<String> {
40  public:
41    typedef PersistentCollection<String>::ElementType ElementType;
42    DescriptionImplementation() {}
43  };
44}
45
46%}
47
48%template(DescriptionImplementationTypedInterfaceObject)           Type::TypedInterfaceObject<Type::DescriptionImplementation>;
49%template(DescriptionImplementationTypedCollectionInterfaceObject) Type::TypedCollectionInterfaceObject<Type::DescriptionImplementation>;
50