Eliminating access specifiers and dummy constructors reduces clutter, and
in most cases pure virtual functions prevent instantiation anyway. Since
these reside in private or protected sections of other classes, risk of
misuse is negligible.
class CollectionItemTypeBase
{
protected:
class CollectionItemTypeBase
{
protected:
- protected:
- TagBase() { }
- public:
virtual ~TagBase() { }
};
template<typename T>
virtual ~TagBase() { }
};
template<typename T>
- class Tag: public TagBase
class CollectionItemType: public CollectionItemTypeBase
{
private:
class CollectionItemType: public CollectionItemTypeBase
{
private:
- protected:
- CreatorBase() { }
- public:
virtual ~CreatorBase() { }
virtual T *create(Collection &, const std::string &) const = 0;
};
template<typename C>
virtual ~CreatorBase() { }
virtual T *create(Collection &, const std::string &) const = 0;
};
template<typename C>
- class Creator: public CreatorBase
+ struct Creator: CreatorBase
typedef T *(C::*FuncPtr)(const std::string &);
typedef T *(C::*FuncPtr)(const std::string &);
Creator(FuncPtr f): func(f) { }
virtual T *create(Collection &coll, const std::string &name) const
{ return (static_cast<C &>(coll).*func)(name); }
};
Creator(FuncPtr f): func(f) { }
virtual T *create(Collection &coll, const std::string &name) const
{ return (static_cast<C &>(coll).*func)(name); }
};
- protected:
- StoreBase() { }
- public:
virtual ~StoreBase() { }
virtual void store(Collection &, const std::string &, T *) = 0;
virtual ~StoreBase() { }
virtual void store(Collection &, const std::string &, T *) = 0;
- class Store: public StoreBase
+ struct Store: StoreBase
virtual void store(Collection &coll, const std::string &name, T *obj)
{ coll.add(name, static_cast<S *>(obj)); }
virtual void store(Collection &coll, const std::string &name, T *obj)
{ coll.add(name, static_cast<S *>(obj)); }