ProtoDeclaration.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
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

Generated on Thu Aug 24 12:38:33 2006 for H3D API by  doxygen 1.4.5