fipa_acl  1.4
main.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <fipa_acl/conversation_monitor.h>
3 #include <getopt.h>
4 #include <cstdlib>
5 
6 using namespace fipa::acl;
7 
8 int main(int argc, char** argv)
9 {
10  std::string protocolfile;
11  bool useXML = false;
12 
13  int opt;
14  if(argc == 1)
15  {
16  printf("usage: %s -f <protocolfile>\n", argv[0]);
17  return 0;
18  }
19 
20  while( (opt = getopt(argc, argv, "f:hx")) != -1)
21  {
22  switch(opt)
23  {
24  case 'f':
25  protocolfile = std::string(optarg);
26  break;
27  case 'x':
28  useXML = true;
29  break;
30  case 'h':
31  default:
32  printf("usage: %s -f <protocolfile>\n", argv[0]);
33  return 0;
34 
35  }
36  }
37 
38  printf("Load specification of: %s\n", protocolfile.c_str());
39  try {
40  StateMachineReader reader;
41  StateMachine statemachine = reader.loadSpecification(protocolfile);
42  if(useXML)
43  {
44  printf("%s", statemachine.toXML().c_str());
45  } else{
46  printf("%s", statemachine.toString().c_str());
47  }
48  } catch(std::runtime_error& e)
49  {
50  printf("Runtime error: %s\n", e.what());
51  }
52 
53  return 0;
54 }
55 
56 
57 
58 
std::string toXML() const
implements a XML parser that generates a state machine from a given spec. file; uses the tinyXML libr...
std::string toString() const
StateMachine loadSpecification(const std::string &file)
int main(int argc, char **argv)
Definition: main.cpp:8
Agent Communication Language.
Definition: conversation.cpp:6