X3DAbstractNode.h

Go to the documentation of this file.
00001 #ifndef X3DTK_X3DABSTRACTNODE_H
00002 #define X3DTK_X3DABSTRACTNODE_H
00003 
00004 #include "X3DTypes.h"
00005 #include "X3DFileElement.h"
00006 #include "SFType.h"
00007 #include "Recorder.h"
00008 
00009 namespace X3DTK {
00010 
00011 class FileElement;
00012 
00021 class X3DAbstractNode
00022 {
00023   template<class T, class V> friend class SFNodeFunctor;
00024   template<class T, class V> friend class MFNodeFunctor;
00025   
00026 public:
00028   X3DAbstractNode();
00030   SFNode clone() const;
00032   virtual ~X3DAbstractNode();
00033 
00035   void setName(const SFString &name);
00036 
00038   inline const SFString &getName() const {return _name;};
00040   inline const SFString &getTypeName() const {return _type->getName();};
00042   inline const SFString &getSceneGraphName() const {return _type->getSceneGraphName();};
00044   inline SFType *getType() const {return _type;};
00046   MFNode getChildList();
00048   inline MFNode getParentList() const {return _parentList;};
00049     
00052   bool setChild(SFNode N);
00054   bool removeChild(SFNode N);
00055 
00057   X3DField get(const SFString &name) const; 
00059   void set(const SFString &name, const X3DField &field); 
00061   void loadAttribute(const SFString &name, const SFString &value);
00063   SFString writeAttribute(const SFString &name);
00065   void loadAttributes(const X3DFileElement *element);
00067   void writeAttributes(SFString &output);
00068   
00069 protected:
00073   inline void defineTypeName(const SFString &name, const SFString &component = SFString(""), const SFString &sceneGraph = SFString("")) {defineTempTypeName(this, name, component, sceneGraph);};
00075   template<class T>
00076   inline void defineTempTypeName(T *t, const SFString &name, const SFString &component, const SFString &sceneGraph) {define(Recorder<T>::getTypeName(name, component, sceneGraph));};
00078   inline void define(const TypeName &typeName) {SFType::defineTypeName(&_type, typeName.name, typeName.component, typeName.sceneGraph, typeName.cloner);};  
00080   template<class T, class V>
00081   inline void defineAttribute(const SFString &name, V T:: *member, const V &init);
00083   inline void define(const X3DAttributeRecorder &recorder) {recorder.record(this);};
00085   template<class T, class V>
00086   inline void defineNode(const SFString &name, V T:: *node);
00088   inline void define(const X3DSFNodeRecorder &recorder) {recorder.record(this);};
00090   template<class T, class V>
00091   inline void defineNodes(const SFString &name, MFNode T:: *nodes);
00093   inline void define(const X3DMFNodeRecorder &recorder) {recorder.record(this);};
00094   
00096   static void addParentToChild(SFNode parent, SFNode child);
00098   static void removeParentFromChild(SFNode parent, SFNode child);
00099   
00100 private:   
00102   X3DAbstractNode(const X3DAbstractNode &N);
00104   inline void addOneReference() const {_type->addOneReferenceRecursive();};
00105 
00106   SFString _name;
00107   SFType *_type;
00108   MFNode _parentList;
00109   
00111   void addParent(const SFNode &N);
00113   bool removeParent(const SFNode &N);
00114 };
00115 
00116 }
00117 
00118 #include "X3DAbstractNode.inl"
00119 
00120 #endif

Generated on Mon Jul 12 09:40:01 2004 for X3DToolKit by doxygen 1.3.6