30 #ifndef __PROTODECLARATION_H__
31 #define __PROTODECLARATION_H__
40 class PrototypeVector;
60 const X3DTypes::X3DType &_type = X3DTypes::UNKNOWN_X3D_TYPE,
62 const string &_value =
"" ) :
65 access_type( _access_type ),
72 X3DTypes::X3DType type;
86 const string &_body =
"",
87 const vector<string > &_body_extra = vector<string>(),
88 X3D::PrototypeVector *_existing_protos = NULL );
106 body_extra.push_back( _body );
132 const X3DTypes::X3DType &type,
134 const string &value =
"" ) {
136 if( field_declaration ) {
137 if( field_declaration->external ) {
138 string error_message =
"";
139 if( field_declaration->type != type )
141 "Warning: Value for \"type\" attribute of \"field\" element with name"
142 + _name +
" does not match the value in found ExternProto. Attribute is ignored.";
143 if( error_message ==
"" &&
144 field_declaration->access_type != access_type )
146 "Warning: Value for \"access_type\" attribute of \"field\" element with name"
147 + _name +
" does not match the value in found ExternProto. Attribute is ignored.";
149 field_declaration->value =
"";
152 field_declaration->external =
false;
153 return error_message;
155 return "\"field\" element with name " + _name
156 +
" already exists. The field will not be added.";
159 field_declarations.push_back(
FieldDeclaration(_name, type, access_type, value ) );
166 for( list< FieldDeclaration >::iterator i = field_declarations.begin();
167 i != field_declarations.end(); ++i ) {
168 if( (*i).name == _name ) {
180 for( list< FieldDeclaration >::iterator i = field_declarations.begin();
181 i != field_declarations.end(); ++i ) {
182 (*i).external = is_external;
195 vector< string > body_extra;
196 std::list< FieldDeclaration > field_declarations;
200 X3D::PrototypeVector *existing_protos;
204 const string &body_string );
208 const string &body_string );
Contains the DEFNodes class.
Header file for PrototypeInstance, X3D scene-graph node.
Header file for X3DPrototypeInstance, X3D scene-graph node.
AccessType
The different access types that a field can have.
Definition: Field.h:53
@ INPUT_OUTPUT
No restrictions on access to the field values or routes.
Definition: Field.h:69
Class that contains information about a field that is part of the prototype declaration.
Definition: ProtoDeclaration.h:57
The ProtoDeclaration class contains information about a PROTO node from the X3D standard.
Definition: ProtoDeclaration.h:53
FieldDeclaration * getFieldDeclaration(const string &_name)
Get the field declaration of the given name.
Definition: ProtoDeclaration.h:165
const vector< string > & getProtoBodyExtra()
Get the proto body extras.
Definition: ProtoDeclaration.h:110
const string & getName()
Get the name of the prototype.
Definition: ProtoDeclaration.h:115
void addProtoBodyExtra(const string &_body)
Add one part of proto body that is not the main proto body(i.e.
Definition: ProtoDeclaration.h:105
void setName(const string &_name)
Get the name of the prototype.
Definition: ProtoDeclaration.h:120
void setProtoBody(const string &_body)
Set the string with the internal scenegraph of the prototype.
Definition: ProtoDeclaration.h:99
string addFieldDeclaration(const string &_name, const X3DTypes::X3DType &type, const Field::AccessType &access_type, const string &value="")
Add a field to the prototype.
Definition: ProtoDeclaration.h:131
const string & getProtoBody()
Get the string with the internal scenegraph of the prototype.
Definition: ProtoDeclaration.h:94
void setFieldDeclarationsExternal(bool is_external)
Call this to set the external property for all contained field declarations.
Definition: ProtoDeclaration.h:179
The PrototypeInstance is an instance of a prototyped node.
Definition: PrototypeInstance.h:43
This abstract node type is the base type for all prototype instances in the X3D system.
Definition: X3DPrototypeInstance.h:65
Provides a mapping between defined DEF names in X3D and the nodes they refer to.
Definition: DEFNodes.h:92
H3D API namespace.
Definition: Anchor.h:38