fipa_acl  1.4
Public Member Functions | List of all members
fipa::acl::MessagePrinter Class Reference

Allows printing of a newly constructed fipa::acl::Message. More...

#include <message_printer.h>

Public Member Functions

 MessagePrinter ()
 
 ~MessagePrinter ()
 
void print (const fipa::acl::Message &msg) const
 

Detailed Description

Allows printing of a newly constructed fipa::acl::Message.

Definition at line 11 of file message_printer.h.

Constructor & Destructor Documentation

◆ MessagePrinter()

fipa::acl::MessagePrinter::MessagePrinter ( )

Definition at line 5 of file message_printer.cpp.

6 {
7 }

◆ ~MessagePrinter()

fipa::acl::MessagePrinter::~MessagePrinter ( )

Definition at line 9 of file message_printer.cpp.

10 {
11 }

Member Function Documentation

◆ print()

void fipa::acl::MessagePrinter::print ( const fipa::acl::Message msg) const

Print the output of a fipa message to stdout

Parameters
msg

Definition at line 13 of file message_printer.cpp.

14 {
15  printf("FIPA Message read:\n");
16  printf("id: %x\n", msg.header.id);
17 
18  if( (msg.header.id & ! 0xfa) == 0) printf("\tid is FA\n");
19  else if( (msg.header.id & ! 0xfb) == 0 ) printf("\tid is FB\n");
20  else if( (msg.header.id & ! 0xfc) == 0 ) printf("\tid is FC\n");
21  else printf("\tWARNING: id is unknown\n");
22 
23 
24  printf("version: %x\n", msg.header.version);
25  printf("performative(type): %s\n", msg.type.c_str());
26 
27  printf("msg-parameters count: %d\n",(int) msg.parameters.size());
28  for(uint32_t i=0; i < msg.parameters.size(); i++)
29  {
30  message::Parameter mp = msg.parameters[i];
31  printf("\tparameter #%d: %s\n",i, mp.name.c_str());
32 
33  if(mp.name == "sender")
34  {
35  AgentIdentifierPrinter aidPrinter;
36  fipa::acl::AgentIdentifier& aid = boost::get<fipa::acl::AgentIdentifier>(mp.data);
37  aidPrinter.print(aid);
38  } else if(mp.name == "receiver")
39  {
40  AgentIdentifierPrinter aidPrinter;
41  std::vector<fipa::acl::AgentIdentifier> aids = boost::get<std::vector<fipa::acl::AgentIdentifier> >(mp.data);
42  int length = aids.size();
43 
44  printf("Receiver: \n");
45  for(int i = 0; i < length; i++)
46  {
47  aidPrinter.print(aids[i]);
48  }
49 
50 
51  } else if(mp.name == "content")
52  {
53  fipa::acl::ByteSequence bs = boost::get<fipa::acl::ByteSequence>(mp.data);
54  printf("encoding: %s\n", bs.encoding.c_str());
55 
56  std::string printBytes = bs.toPrettyString();
57  printf("content: %s\n", printBytes.c_str());
58  } else if(mp.name == "reply-with")
59  {
60  std::string replyWith = boost::get<std::string>(mp.data);
61  printf("ReplyWith: %s\n", replyWith.c_str());
62  } else if(mp.name == "reply-by")
63  {
64  fipa::acl::DateTime dt = boost::get<fipa::acl::DateTime>(mp.data);
65  std::string dtString = dt.toString();
66  printf("DateTime: %s\n", dtString.c_str());
67 
68  } else if(mp.name == "in-reply-to")
69  {
70  std::string inReplyTo = boost::get<std::string>(mp.data);
71  printf("InReplyTo: %s\n", inReplyTo.c_str());
72 
73  } else if(mp.name == "reply-to")
74  {
75  AgentIdentifierPrinter aidPrinter;
76  std::vector<fipa::acl::AgentIdentifier> aids = boost::get<std::vector<fipa::acl::AgentIdentifier> >(mp.data);
77  int length = aids.size();
78 
79  printf("ReplyTo: \n");
80  for(int i = 0; i < length; i++)
81  {
82  aidPrinter.print(aids[i]);
83  }
84 
85 
86  } else if(mp.name == "language")
87  {
88  std::string language = boost::get<std::string>(mp.data);
89  printf("Language: %s\n", language.c_str());
90 
91 
92  } else if(mp.name == "encoding")
93  {
94  std::string encoding = boost::get<std::string>(mp.data);
95  printf("Encoding: %s\n", encoding.c_str());
96 
97 
98  } else if(mp.name == "ontology")
99  {
100 
101  std::string ontology = boost::get<std::string>(mp.data);
102  printf("Ontology: %s\n", ontology.c_str());
103 
104 
105  } else if(mp.name == "protocol")
106  {
107  std::string protocol = boost::get<std::string>(mp.data);
108  printf("Protocol: %s\n", protocol.c_str());
109 
110 
111  } else if(mp.name == "conversation-id")
112  {
113  std::string conversationId = boost::get<std::string>(mp.data);
114  printf("Conversation-id: %s\n", conversationId.c_str());
115 
116 
117  }
118 
119  }
120 
121 }
std::vector< message::Parameter > parameters
Definition: types.h:85
std::string toPrettyString() const
Representation of a byte sequence. We also embed information about the encoding.
std::string toString() const
Definition: date_time.cpp:9
Definition for AgentIdentifier.
Definition: agent_id.h:30
char version
Definition: types.h:34
std::string type
Definition: types.h:84
Header header
Definition: types.h:83

The documentation for this class was generated from the following files: