XdkWrl: proto.h Source File

Home | Hierarchy | Members | Alphabetical | Related Pages

# proto.h

Go to the documentation of this file.

    00001 #ifndef XDKWRL_PROTO_H
    00002 #define XDKWRL_PROTO_H
    00003
    00004 #include <xdkwrl/node.h>
    00005 #include <xdkwrl/fieldtypes/mfnode.h>
    00006 #include <xdkwrl/fieldtypes/mfstring.h>
    00007 #include <list>
    00008 #include <map>
    00009
    00010 namespace wrl
    00011 {
    00012   class ProtoInstance;
    00013   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00014   // Interface of DeclaredNodeWithBindings
    00015   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00016   class DeclaredNodeWithBindings : public DeclaredNode
    00017   {
    00018   public:
    00019     DeclaredNodeWithBindings(const char* name="");
    00020     typedef std::pair<std::string,std::string> Binding;
    00021     typedef std::map<Node*,std::list<Binding> > BindingMap;
    00022     void bindFields(Node* n,const char* to, const char* from);
    00023     void bindEventsIn(Node* n,const char* to, const char* from);
    00024     void bindEventsOut(Node* n,const char* to, const char* from);
    00025     inline const BindingMap& fieldBindings() const;
    00026     inline const BindingMap& eventInBindings() const;
    00027     inline const BindingMap& eventOutBindings() const;
    00028     virtual void setField(const FieldHandle& f,const SFBool&);
    00029     virtual void setField(const FieldHandle& f,const SFColor&);
    00030     virtual void setField(const FieldHandle& f,const SFFloat&);
    00031     virtual void setField(const FieldHandle& f,const SFImage&);
    00032     virtual void setField(const FieldHandle& f,const SFInt32&);
    00033     virtual void setField(const FieldHandle& f,const SFNode&);
    00034     virtual void setField(const FieldHandle& f,const SFRotation&);
    00035     virtual void setField(const FieldHandle& f,const SFString&);
    00036     virtual void setField(const FieldHandle& f,const SFTime&);
    00037     virtual void setField(const FieldHandle& f,const SFVec2f&);
    00038     virtual void setField(const FieldHandle& f,const SFVec3f&);
    00039     virtual void setField(const FieldHandle& f,const MFColor&);
    00040     virtual void setField(const FieldHandle& f,const MFFloat&);
    00041     virtual void setField(const FieldHandle& f,const MFInt32&);
    00042     virtual void setField(const FieldHandle& f,const MFNode&);
    00043     virtual void setField(const FieldHandle& f,const MFRotation&);
    00044     virtual void setField(const FieldHandle& f,const MFString&);
    00045     virtual void setField(const FieldHandle& f,const MFTime&);
    00046     virtual void setField(const FieldHandle& f,const MFVec2f&);
    00047     virtual void setField(const FieldHandle& f,const MFVec3f&);
    00048   protected:
    00049     void propagateBindings();
    00050     BindingMap fieldBindings_;
    00051     BindingMap eventInBindings_;
    00052     BindingMap eventOutBindings_;
    00053   };
    00054   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00055   // Interface of ProtoDeclaration
    00056   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00057   class ProtoDeclaration : public DeclaredNodeWithBindings
    00058   {
    00059   public:
    00060     ProtoDeclaration(const char* nodeTypeId,const char* name="");
    00061     virtual bool isSetToDefaultValue(unsigned int i) const;
    00062     inline const char* typeName() const;
    00063     void setNodes(const MFNode&);
    00064     inline const MFNode& nodes() const;
    00065     virtual Node* duplicate() const;
    00066     virtual Node* duplicate(std::map<const Node*,Node*>&) const;
    00067
    00068     virtual inline bool isExtern() const;
    00069     virtual inline bool hasNodes() const;
    00070   private:
    00071     friend class ProtoInstance;
    00072     std::string        nodeTypeId_;
    00073     MFNode             nodes_;
    00074   };
    00075   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00076   // Interface of ExternProtoDeclaration
    00077   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00078   class ExternProtoDeclaration : public ProtoDeclaration
    00079   {
    00080   public:
    00081     ExternProtoDeclaration(const char* nodeTypeId,const char* name="");
    00082     MFString urls;
    00083     virtual inline bool isExtern() const;
    00084     virtual inline bool hasNodes() const;
    00085     bool getExternalDeclaration();
    00086   private:
    00087     bool loaded_;
    00088   };
    00089   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00090   // Interface of ProtoInstance
    00091   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    00092   class ProtoInstance : public DeclaredNodeWithBindings
    00093   {
    00094   public:
    00095     ProtoInstance(const ProtoDeclaration* d,const char* name="");
    00096     inline const char* typeName() const;
    00097     virtual bool isSetToDefaultValue(unsigned int i) const;
    00098     inline const ProtoDeclaration* declaration() const;
    00099     virtual Node* duplicate() const;
    00100     virtual Node* duplicate(std::map<const Node*,Node*>&) const;
    00101     inline const MFNode& nodes() const;
    00102   private:
    00103     ProtoInstance(const char* name="");
    00104     const ProtoDeclaration* declaration_;
    00105     MFNode                  nodes_;
    00106   };
    00107   //************************************************************
    00108   // Implementation of DeclaredNodeWithBindings
    00109   //************************************************************
    00110   inline const DeclaredNodeWithBindings::BindingMap&
    00111   DeclaredNodeWithBindings::fieldBindings() const
    00112   {
    00113     return fieldBindings_;
    00114   }
    00115   inline const DeclaredNodeWithBindings::BindingMap&
    00116   DeclaredNodeWithBindings::eventInBindings() const
    00117   {
    00118     return eventInBindings_;
    00119   }
    00120   inline const DeclaredNodeWithBindings::BindingMap&
    00121   DeclaredNodeWithBindings::eventOutBindings() const
    00122   {
    00123     return eventOutBindings_;
    00124   }
    00125   //************************************************************
    00126   // Implementation of ProtoDeclaration
    00127   //************************************************************
    00128   inline const char*
    00129   ProtoDeclaration::typeName() const
    00130   {
    00131     return nodeTypeId_.c_str();
    00132   }
    00133   inline const MFNode&
    00134   ProtoDeclaration::nodes() const
    00135   {
    00136     return nodes_;
    00137   }
    00138   inline bool
    00139   ProtoDeclaration::isExtern() const
    00140   {
    00141     return false;
    00142   }
    00143   /*!
    00144    * Return true if the Proto declaration is loaded. The only case where it
    00145    * returns false is for an extern proto not loaded.
    00146    */
    00147   inline bool
    00148   ProtoDeclaration::hasNodes() const
    00149   {
    00150     return true;
    00151   }
    00152   //************************************************************
    00153   // Implementation of ExternProtoDeclaration
    00154   //************************************************************
    00155   inline bool
    00156   ExternProtoDeclaration::isExtern() const
    00157   {
    00158     return true;
    00159   }
    00160   inline bool
    00161   ExternProtoDeclaration::hasNodes() const
    00162   {
    00163     return loaded_;
    00164   }
    00165   //************************************************************
    00166   // Implementation of ProtoInstance
    00167   //************************************************************
    00168   inline const ProtoDeclaration*
    00169   ProtoInstance::declaration() const
    00170   {
    00171     return declaration_;
    00172   }
    00173   inline const char*
    00174   ProtoInstance::typeName() const
    00175   {
    00176     return declaration_->typeName();
    00177   }
    00178   inline const MFNode&
    00179   ProtoInstance::nodes() const
    00180   {
    00181     return nodes_;
    00182   }
    00183 };
    00184
    00185 #endif // XDKWRL_PROTO_H
    00186
    00187 // Local variables section.
    00188 // This is only used by emacs!
    00189 // Local Variables:
    00190 // ff-search-directories: ("." "../../src/xdkwrl/")
    00191 // End:

Generated on 28 Jun 2006 with version 1.4.4. |