00001 #ifndef __INSTANTIO_NODETYPE_H
00002 #define __INSTANTIO_NODETYPE_H
00003
00004 #ifdef _MSC_VER
00005 # pragma once
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "InstantIODef.h"
00027 #include "Field.h"
00028 #include "Node.h"
00029 #include <string>
00030 #include <map>
00031 #include <vector>
00032 #include <memory>
00033 #ifdef __sgi
00034 # include <assert.h>
00035 #else
00036 # include <cassert>
00037 #endif
00038 #ifdef _MSC_VER
00039 # pragma warning (push)
00040 # pragma warning (disable: 4251)
00041 #endif
00042
00043
00044 namespace InstantIO
00045 {
00046
00047
00089 class INSTANTIO_DLLMAPPING NodeType
00090 {
00091 public:
00092
00094 typedef Node *(*CreateNodeMethod)();
00095
00117 NodeType(const std::string &name,
00118 CreateNodeMethod createMethod,
00119 const char *shortDescription = 0,
00120 const char *longDescription = 0,
00121 const char *author = 0,
00122 Field *fields = 0,
00123 unsigned int numFields = 0);
00124
00126 ~NodeType();
00127
00129 typedef std::vector<NodeType*> NodeTypeVector;
00130
00135 static void getTypes(NodeTypeVector &types);
00136
00143 static const NodeType *findType(std::string name);
00144
00150 inline const std::string &getName() const { return name_; }
00151
00158 inline const std::string &getShortDescription() const { return shortDescription_; }
00159
00166 inline const std::string &getLongDescription() const { return longDescription_; }
00167
00174 inline const std::string &getAuthor() const { return author_; }
00175
00181 inline const Field *getFields() const { return fields_; }
00182
00190 const Field *getField(const std::string &name) const;
00191
00196 inline unsigned int numFields() const { return numFields_; }
00197
00202 static std::auto_ptr<Node> newInstance(const std::string &type)
00203 ;
00204
00209 inline std::auto_ptr<Node> newInstance() const
00210 {
00211 assert(createMethod_ != 0);
00212 return std::auto_ptr<Node>(createMethod_());
00213 }
00214
00215 private:
00216
00218 NodeType(const NodeType &);
00219
00221 const NodeType &operator=(const NodeType &);
00222
00229 static const NodeType *internalFindType(std::string name);
00230
00232 std::string name_;
00233
00235 std::string shortDescription_;
00236
00238 std::string longDescription_;
00239
00241 std::string author_;
00242
00244 Field *fields_;
00245
00247 unsigned int numFields_;
00248
00250 typedef std::map<std::string, Field*> FieldMap;
00251
00253 FieldMap fieldMap_;
00254
00256 CreateNodeMethod createMethod_;
00257
00259 typedef std::map<std::string, NodeType*> TypeMap;
00260
00262 static TypeMap *types_;
00263
00265 static bool loadLib ( const std::string &pluginName );
00266
00267 };
00268
00269
00270 }
00271
00272
00273 #ifdef _MSC_VER
00274 # pragma warning (pop)
00275 #endif
00276
00277 #endif // __INSTANTIO_NODETYPE_H