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
00034
00035
00036 BehaviorTemplatePtr entry =
00037 BEHAVIOR_TEMPLATE_CAST(this->_checkInstArgs(key, initArgs));
00038
00039 CHECK_SHARED(entry);
00040
00041
00042 BehaviorInstancePtr instance(new BehaviorInstance());
00043 instance->SetTemplate(key);
00044
00045
00046 this->_doInstantiate(instance, entry, initArgs);
00047
00048
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