Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

PhxDescription.h

Go to the documentation of this file.
00001 #ifndef PHX_DESCRIPTION_H
00002 #define PHX_DESCRIPTION_H
00003 
00004 #include <Phx/PhxConfig.h>
00005 #include <Phx/PhxTypes.h>
00006 
00007 #include <Phx/Util/PhxBitVector.h>
00008 #include <Phx/Util/PhxListeners.h>
00009 
00017 namespace Phx {
00018 
00091   class Description : public LockedPtrInterface<Description> {
00092     class TypeClass;
00093   public:
00094     class Manager;
00095 
00100     typedef ValueType<TypeClass, uint32_t>  Type;
00101 
00110     const static Type INVALID_TYPE;
00111 
00122     virtual BitVector serializedData(void) const = 0;
00123 
00142     virtual void serializedData(const BitVector& serializedData) = 0;
00143 
00144     // virtual XMLNode xmlData(void) = 0;
00145     // virtual void xmlData(const XMLNode& xmlNode) =0;
00146 
00155     Type type() const { return mType; }
00156 
00157     // virtual destructor
00158     virtual ~Description() {}
00159 
00160   protected:
00161     Description() : mType(INVALID_TYPE) {}
00162 
00163   private:
00164     // no assignment
00165     Description& operator=(const Description& rhs);
00166 
00167     friend class Manager;
00168     void setType(Type type) { mType = type; }
00169 
00170     Type mType;
00171   };
00172 
00173 
00183   class Description::Manager : public LockedPtrInterface<Description::Manager> {
00184     template <class T>
00185     class DefaultTypeListener;
00186 
00187   public:
00188 
00189     // ------------ CREATING DESCRIPTIONS ------------
00190 
00210     virtual Ptr<Description> newDescription(Description::Type type) = 0;
00211 
00212 
00229     virtual Ptr<Description> newDescription(const Ptr<const Description>& description) = 0;
00230 
00231 
00257     virtual Ptr<const Description> fileDescription(const String& filename) = 0;
00258 
00259 
00260     // ----------- DESCRIPTION TYPES -----------
00261 
00272     class TypeListener : 
00273     public BaseMultiListener<Description::Manager, TypeListener, Description::Type> {
00274 
00275     public:
00290       virtual Ptr<Description> onNewDescription(const Ptr<const Description>& description) = 0;
00291     };
00292 
00313     virtual void typeListener(Description::Type type, TypeListener* listener) = 0;
00314 
00315     // typeNameType(String typeName, Type type);
00316     // Type typeNameType(String typeName);
00317 
00346     template <class T>
00347     Ptr<TypeListener> newDescriptionType() {
00348       Ptr<DefaultTypeListener<T> > typeListenerPtr(new DefaultTypeListener<T>());
00349       typeListener(T::DESCRIPTION_TYPE, typeListenerPtr.ptr());
00350       return typeListenerPtr;
00351     }
00352 
00353 
00354     // virtual destructor
00355     virtual ~Manager() { }
00356 
00357   private:
00358     // A default listener implementation that returns a default
00359     // constructed instance of the template parameter type T.
00360     template <class T>
00361     class DefaultTypeListener : public TypeListener {
00362       virtual Ptr<Description> onNewDescription(const Ptr<const Description>& description)
00363       { return Ptr<Description>(new T(description)); }
00364     };
00365   };
00366 
00367 }; // namespace Phx
00368 
00369 #endif /* PHX_DESCRIPTION_H */

Generated on Wed Dec 21 22:05:37 2005 for Phoenix OSFS by  doxygen 1.4.2