00001
00002
00004
00005 #ifndef TYPE_H
00006 #define TYPE_H
00007
00008 #include "X3DTypes.h"
00009 #include "SceneGraph.h"
00010 #include "Component.h"
00011
00012 namespace X3DTK {
00013
00014 class X3DActor;
00015
00016 namespace X3D {
00017 class Creator;
00018 class X3DComponentCreator;
00019 }
00020
00024
00025 class Type
00026 {
00027 friend class X3D::Creator;
00028 friend class Walker;
00029 friend class Visitor;
00030 friend class X3D::X3DComponentCreator;
00031 friend class X3DComponentWalker;
00032 friend class X3DComponentVisitor;
00033 friend class X3DAbstractNode;
00034
00035 public:
00037 static Type *getTypeOfName(const SFString &sceneGraph, const SFString &component, const SFString &name);
00039 static Type *getTypeOfId(int id);
00041 static void recomputeIds();
00042
00044 inline SFString getName() const {return _name;};
00046 inline SFString getComponentName() const {return _component->getName();};
00048 inline SFString getSceneGraphName() const {return _component->getSceneGraph()->getName();};
00050 inline int getId() const {return _id;};
00052 inline Type *getParent() const {return _parent;};
00054 inline MFType getChildList() const {return _childList;};
00056 inline Component *getComponent() const {return _component;};
00058 inline SceneGraph *getSceneGraph() const {return _component->getSceneGraph();};
00060 static void printDerivationTree();
00061
00062 private:
00064 Type(const SFString &name, const SFString &component, const SFString &sceneGraph);
00065 ~Type();
00066
00068 void setParent(Type *parent);
00070 void addOneReference();
00072 void addOneReferenceRecursive();
00074 static void removeOneReference(Type *type);
00075
00077 static void defineTypeName(Type **type, const SFString &name, const SFString &component, const SFString &sceneGraph);
00079 static void addActor(X3DActor *actor);
00081 static void removeActor(X3DActor *actor);
00082
00085 static void beginFunctionDefinition();
00087 static void endFunctionDefinition();
00089 static SFString encodeKey(const SFString &sceneGraph, const SFString &component, const SFString &type);
00091 inline SFString getEncodedName() const {return encodeKey(getSceneGraphName(), getComponentName(), getName());};
00092
00094 SFString _name;
00095 int _id;
00096 int _refCount;
00097 Type *_parent;
00098 MFType _childList;
00099 Component *_component;
00100
00102 static int count;
00103 static MFType _typeList;
00104 static std::list<X3DActor *> _actorList;
00105 static bool _functionDefinition;
00106
00107 void printDerivationTree(SFString tab) const;
00108 };
00109
00110 }
00111
00112 #endif