Adrian Maire
Adrian Maire

Reputation: 14815

What is the base class exactly in this case?

What is the base class exactly in this case?

I have some difficulty to grab the full meaning of the first inheritance, due to the FieldType::template and RecordPolicy<N>

template<
class N,
    class FieldType
>
class FieldDefinition:
    public FieldType::template RecordPolicy<N>
{
public:
    typedef typename FieldType::GetSetPolicy::Type Type;
    typedef typename FieldType::GetSetPolicy::MemoryType MemoryType;
    typedef FieldType FieldClass;
};

Usage:

template<class ObjectClass_, class Schema_>
class Object:
    public virtual ObjectBase,
    public FieldDefinition<ObjectClass_, PointerField<ObjectClass_> >
{
    //...
}

Others:

template<class T> class PointerField;


template<class T>
class PointerField
{
    public:
    //...
    template<class N>
    class RecordPolicy : public SerializedField<N, PointerField<T> > {};
};

Upvotes: 1

Views: 81

Answers (1)

Sebastian Redl
Sebastian Redl

Reputation: 71909

The full hierarchy of Object<Foo, Bar> is:

Object<Foo, Bar>
  virtual ObjectBase
  FieldDefinition<Foo, PointerField<Foo>>
    PointerField<Foo>::RecordPolicy<Foo>
      SerializedField<Foo, PointerField<Foo>>

In particular, note that FieldType::template RecordPolicy<N> base clause. This means that FieldDefinition expects whatever class is supplied as FieldType (in your case, PointerField<Foo>) to have a nested template named RecordPolicy with a single type template parameter, for which N (in your case, Foo again) will be substituted. The class derives from the result of this instantiation, in your case the nested class PointerField<Foo>::RecordPolicy<Foo>, which in turn has another base class.

Upvotes: 3

Related Questions