src/engine/BehaviorTemplateTable.h

Go to the documentation of this file.
00001 
00012 #ifndef BEHAVIORTEMPLATETABLE_H
00013 #define BEHAVIORTEMPLATETABLE_H
00014                 
00015 #include <boost/shared_ptr.hpp>
00016 #include "TemplateTable.h"
00017 #include "BehaviorTemplate.h"
00018 #include "BehaviorInstance.h"
00019 
00020 namespace green
00021 {
00022 
00026         class BehaviorTemplateTable : public TemplateTable
00027         {
00028                 public:
00029                         
00030                         BehaviorInstancePtr InstantiateBehavior(Key key, ArgListPtr initArgs) const
00031                         {
00032                                 CHECK_SHARED(initArgs);
00033 //                              BehaviorInstancePtr ret;
00034 //                              ret = BEHAVIOR_INSTANCE_CAST(this->Instantiate(key, initArgs));
00035 //                              return ret;
00036                                 BehaviorTemplatePtr entry =
00037                                                 BEHAVIOR_TEMPLATE_CAST(this->_checkInstArgs(key, initArgs));
00038                                 
00039                                 CHECK_SHARED(entry);
00040                                 
00041                                 // create a new instance with entry as its template
00042                                 BehaviorInstancePtr instance(new BehaviorInstance());
00043                                 instance->SetTemplate(key);
00044                                 
00045                                 // now fill in the default values and such from the template
00046                                 this->_doInstantiate(instance, entry, initArgs);
00047                                 
00048                                 // and return the instance
00049                                 return instance;
00050                         }
00051         };
00052         typedef boost::shared_ptr<BehaviorTemplateTable> BehaviorTemplateTablePtr;
00053         #define BEHAVIOR_TEMPLATE_TABLE_CAST(x) boost::dynamic_pointer_cast<BehaviorTemplateTable>(x)
00054 }
00055 
00056 #endif

Generated on Fri Apr 27 10:27:37 2007 for Green Engine by  doxygen 1.5.1