00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027
00029
00030 #ifndef __PROTODECLARATION_H__
00031 #define __PROTODECLARATION_H__
00032
00033 #include "X3DPrototypeInstance.h"
00034 #include "PrototypeInstance.h"
00035 #include <list>
00036
00037 namespace H3D {
00038
00043 class H3DAPI_API ProtoDeclaration {
00044 public:
00047 class H3DAPI_API FieldDeclaration {
00048 public:
00049 FieldDeclaration( const string &_name = "",
00050 const X3DTypes::X3DType &_type = X3DTypes::UNKNOWN_X3D_TYPE,
00051 const Field::AccessType &_access_type = Field::INPUT_OUTPUT,
00052 const string &_value = "" ) :
00053 name( _name ),
00054 type( _type ),
00055 access_type( _access_type ),
00056 value( _value ) {
00057
00058 }
00059
00060 string name;
00061 X3DTypes::X3DType type;
00062 Field::AccessType access_type;
00063 string value;
00064 };
00065
00069 ProtoDeclaration( const string &_name,
00070 const string &_body = "" ) :
00071 name( _name ),
00072 body( _body ){}
00073
00075 const string &getProtoBody() {
00076 return body;
00077 }
00078
00080 void setProtoBody( const string &_body ) {
00081 body = _body;
00082 }
00083
00085 const string& getName() {
00086 return name;
00087 }
00088
00090 void setName( const string &_name ) {
00091 name = _name;
00092 }
00093
00095 void addFieldDeclaration( const string &name,
00096 const X3DTypes::X3DType &type,
00097 const Field::AccessType &access_type,
00098 const string &value = "" ) {
00099 field_declarations.push_back( FieldDeclaration( name, type, access_type, value ) );
00100 }
00101
00104 FieldDeclaration *getFieldDeclaration( const string& name ) {
00105 for( list< FieldDeclaration >::iterator i = field_declarations.begin();
00106 i != field_declarations.end(); i++ ) {
00107 if( (*i).name == name ) {
00108 return &(*i);
00109 }
00110 }
00111 return NULL;
00112 }
00113
00115 X3DPrototypeInstance *newProtoInstance();
00116 protected:
00117 string name;
00118 string body;
00119 std::list< FieldDeclaration > field_declarations;
00120 };
00121
00122 }
00123
00124 #endif