fipa_acl  1.4
envelope_generator.cpp
Go to the documentation of this file.
1 #include "envelope_generator.h"
2 #include <stdexcept>
3 #include <boost/assign/list_of.hpp>
4 #include <base-logging/Logging.hpp>
5 
8 
9 namespace fipa {
10 namespace acl {
11 
12 std::map<representation::Type, EnvelopeFormatPtr > EnvelopeGenerator::msFormats = boost::assign::map_list_of
13  (representation::BITEFFICIENT, boost::shared_ptr<EnvelopeFormat>(new BitefficientEnvelopeFormat()) )
14  (representation::XML, boost::shared_ptr<EnvelopeFormat>(new XMLEnvelopeFormat()) );
15 
16 std::string EnvelopeGenerator::create(const ACLEnvelope& envelope, const representation::Type& type)
17 {
18  std::map<representation::Type, EnvelopeFormatPtr >::const_iterator it = msFormats.find(type);
19 
20  if( it != msFormats.end())
21  {
22  return it->second->apply(envelope);
23  } else
24  {
25  char buffer[512];
26  snprintf(buffer, 512, "fipa::acl::EnvelopeGenerator: envelope format of type '%s' is unknown", representation::TypeTxt[type].c_str());
27  LOG_ERROR("%s", buffer);
28  throw std::runtime_error(buffer);
29  }
30 }
31 
32 
33 } // end namespace acl
34 } // end namespace fipa
static std::string create(const ACLEnvelope &msg, const representation::Type &acl_representation)
ACLMessage envelope (also typed as fipa::acl::Letter) includes the base envelope and updated fields...
Definition: acl_envelope.h:349
const std::string TypeTxt[]
Definition: types.h:28
Foundation of Physical Intelligent Agents.
Definition: conversation.cpp:6