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

Generated on 5 Jan 2007 with version 1.5.1. |