src/engine/MessageTemplateTable.h

Go to the documentation of this file.
00001 
00012 #ifndef MESSAGETEMPLATETABLE_H
00013 #define MESSAGETEMPLATETABLE_H
00014 
00015 #include <boost/shared_ptr.hpp>
00016 #include "TemplateTable.h"
00017 #include "MessageTemplate.h"
00018 #include "MessageInstance.h"
00019 
00020 namespace green
00021 {
00026         class MessageTemplateTable :
00027                         public TemplateTable
00028         {
00029                 public:
00030                         
00031                         Key AddEntry(const Name& name, MessageTemplatePtr entry)
00032                         {
00033                                 CHECK_SHARED(entry);
00034                                 return TemplateTable::AddEntry(name, entry);
00035                         }
00036                         
00045                         MessageInstancePtr
00046                                         Instantiate(Key key, ArgListPtr initArgs) const
00047                         {
00048                                 CHECK_SHARED(initArgs);
00049                                 MessageTemplatePtr entry =
00050                                                 MESSAGE_TEMPLATE_CAST(this->_checkInstArgs(key, initArgs));
00051                                                         
00052                                 // create a new instance with entry as its template
00053                                                 MessageInstancePtr instance(new MessageInstance());
00054                                                 instance->SetTemplate(key);
00055                                                 
00056                                 // now fill in the default values and such from the template
00057                                                 this->_doInstantiate(instance, entry, initArgs);
00058                                 
00059                                 // and return the instance
00060                                                 return instance;
00061                         }
00062                 
00063         };
00064         typedef boost::shared_ptr<MessageTemplateTable> MessageTemplateTablePtr;
00065 }
00066 #endif

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