Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef AESOP_TYPEINST_H__
00034 #define AESOP_TYPEINST_H__
00035
00036
00037 #include "aesop-base/aesop-base.h"
00038
00039 #include "datahash/datahash.h"
00040 #include "datahash/datahash_util.h"
00041 #include "geometry/placement.h"
00042 #include "story/story.h"
00043
00044
00045 namespace aesop {
00046
00047
00141
00144
00145 class ComponentData {
00146 public:
00147
00148 virtual ~ComponentData(void) throw();
00149
00150
00151
00153 virtual void dump(IN const char * txt) const throw();
00154 };
00155
00156
00157
00173 class Instance {
00174 public:
00175
00176 virtual ~Instance(void) throw();
00177
00178
00179
00181 virtual const char * getInstanceId(void) const throw() = 0;
00182
00184 virtual const char * getTypeId(void) const throw() = 0;
00185
00187 virtual placement_t& getPlacement(void) throw() = 0;
00188
00191 virtual void setComponentData(IN const char * componentName,
00192 IN smart_ptr<ComponentData>& data) = 0;
00193
00195 virtual smart_ptr<ComponentData> getComponentData(
00196 IN const char * componentName) = 0;
00197
00199 virtual const Datahash * getTypeComponentData(
00200 IN const char * componentName) = 0;
00201
00204 virtual void setInstanceData(IN const char * componentName,
00205 IN smart_ptr<Datahash>& data) = 0;
00206
00211 virtual smart_ptr<Datahash> getInstanceData(
00212 IN const char * componentName) = 0;
00213
00215 virtual void dump(IN const char * txt) throw() = 0;
00216
00217
00218 static smart_ptr<Instance> parse(IO std::istream& stream);
00219 static smart_ptr<Instance> create(IN const char * instanceId,
00220 IN const char * typeId);
00221 };
00222
00223
00224
00226 typedef std::vector<smart_ptr<Instance> > vec_instance_t;
00227
00228
00230 typedef void (*instance_iteration_fn)(IN smart_ptr<Instance>& instance,
00231 IN void * context);
00232
00233
00234
00245 class TypeComponentLoader {
00246 public:
00247
00248 virtual ~TypeComponentLoader(void) throw();
00249
00250
00251
00253 virtual const char * getComponentName(void) const throw() = 0;
00254
00256 virtual const char * getLoaderName(void) const throw() = 0;
00257
00259 virtual bool isMyFormat(IN const Datahash * componentData,
00260 IN const char * path) const = 0;
00261
00263 virtual smart_ptr<ComponentData> loadTS(
00264 IN smart_ptr<Instance>& instance,
00265 IN const Datahash * componentData,
00266 IN const char * path) = 0;
00267 };
00268
00269
00271 void initializeTypeInstanceLibrary(IN smart_ptr<story::Story>& story);
00272
00273
00276 void registerTypeComponentLoader(IN smart_ptr<aesop::TypeComponentLoader>& tcl);
00277
00278
00279
00281 void loadInstances(IO std::istream& stream,
00282 OUT vec_instance_t& instances);
00283
00284
00285
00293 const char * getKeyWithOverrides(IN const char * keyName,
00294 IN const Datahash * instanceData,
00295 IN const Datahash * typeData,
00296 IN const Datahash * modelData,
00297 IN eDatahash_Flag flag);
00298
00299
00300 };
00301
00302 #endif // AESOP_TYPEINST_H__
00303