FEDRA emulsion software from the OPERA Collaboration
MessageManager Class Reference

#include <MessageManager.h>

Inheritance diagram for MessageManager:
Collaboration diagram for MessageManager:

Public Member Functions

void AddGetModuleParamsNode (const char *module_,...)
 
void AddGetPathParamsNode (const char *lib_, const char *path_,...)
 
void AddMarksNode (int brick_, int plate_, const char *mapext_)
 
void AddSetModuleParamsNode (const char *module_,...)
 
void AddSetPathParamsNode (const char *lib_, const char *path_,...)
 
void AddStartNode (const char *lib_, const char *path_, const char *comment_)
 
void AddStopNode ()
 
void Clean ()
 
void CreateMessage ()
 
void FillBuff ()
 
void FillBuffOuter (uint8 *buf_, uint32 size_)
 
uint8GetBuf ()
 
uint32 GetBufSize ()
 
 MessageManager ()
 

Private Attributes

std::vector< uint8m_messBuf
 
uint32 m_messId
 
std::string m_xml
 
TiXmlDocument m_xmlDoc
 
TiXmlElementm_xmlDocAddPtr
 
- Private Attributes inherited from PAVProtocol
uint32 m_headerSize
 

Additional Inherited Members

- Private Member Functions inherited from PAVProtocol
uint32 Crc32 (uint32 len_, const uint8 *buf_)
 
 PAVProtocol ()
 
virtual bool ReadMessage (uint8 *buf_, uint32 size_, std::vector< uint8 > &dstbuf_)
 
virtual bool ReadMessageRaw (uint8 *buf_, uint32 size_, std::vector< uint8 > &dstbuf_)
 
virtual bool WriteMessage (std::vector< uint8 > &buf_, const void *srcbuf_, uint32 srcsize_)
 
virtual bool WriteMessageRaw (std::vector< uint8 > &buf_, const void *srcbuf_, uint32 srcsize_)
 
virtual ~PAVProtocol ()
 

Constructor & Destructor Documentation

◆ MessageManager()

MessageManager::MessageManager ( )
inline
16  :m_messId(0), m_xmlDoc("mess")
17  {};
uint32 m_messId
Definition: MessageManager.h:50
TiXmlDocument m_xmlDoc
Definition: MessageManager.h:51

Member Function Documentation

◆ AddGetModuleParamsNode()

void MessageManager::AddGetModuleParamsNode ( const char *  module_,
  ... 
)
42  {//ToDo: unix-compatible?
44  gmp.SetAttribute("module", module_);
45 
46  char* var;
47  va_list args;
48  va_start(args, module_);
49  while((var = va_arg(args, char *)) != NULL){
50  TiXmlElement vare(var);
51  gmp.InsertEndChild(vare);
52  }
53  va_end(args);
54 
56 };
#define PAVPROT_NODE_GMP
Definition: PAVProtocolDef.h:52
TiXmlElement * m_xmlDocAddPtr
Definition: MessageManager.h:52
Definition: tinyxml.h:941
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Definition: tinyxml.cpp:214
#define NULL
Definition: nidaqmx.h:84

◆ AddGetPathParamsNode()

void MessageManager::AddGetPathParamsNode ( const char *  lib_,
const char *  path_,
  ... 
)
81  {//ToDo: unix-compatible?
83  gpp.SetAttribute("lib", lib_);
84  gpp.SetAttribute("path", path_);
85 
86  char* var;
87  va_list args;
88  va_start(args, path_);
89  var = va_arg(args, char *);
90  while(var){
91  TiXmlElement vare(var);
92  gpp.InsertEndChild(vare);
93  var = va_arg(args, char *);
94  }
95  va_end(args);
96 
98 };
#define PAVPROT_NODE_GPP
Definition: PAVProtocolDef.h:54

◆ AddMarksNode()

void MessageManager::AddMarksNode ( int  brick_,
int  plate_,
const char *  mapext_ 
)
34  {
36  marks.SetAttribute("brick", brick_);
37  marks.SetAttribute("plate", plate_);
38  marks.SetAttribute("mapext", mapext_);
40 };
#define PAVPROT_NODE_MARKS
Definition: PAVProtocolDef.h:55

◆ AddSetModuleParamsNode()

void MessageManager::AddSetModuleParamsNode ( const char *  module_,
  ... 
)
58  {//ToDo: unix-compatible?
60  smp.SetAttribute("module", module_);
61 
62  char* var, *val;
63  va_list args;
64  va_start(args, module_);
65  while((var = va_arg(args, char *)) != NULL){
66  val = va_arg(args, char *);
67  if(val != NULL){
68  TiXmlElement vare(var);
69  vare.SetAttribute("val", val);
70  smp.InsertEndChild(vare);
71  }else{
72  printf("Value is not provided for parameter <%s> in module <%s>\n", var, module_);
73  break;
74  };
75  }
76  va_end(args);
77 
79 };
#define PAVPROT_NODE_SMP
Definition: PAVProtocolDef.h:51

◆ AddSetPathParamsNode()

void MessageManager::AddSetPathParamsNode ( const char *  lib_,
const char *  path_,
  ... 
)
100  {//ToDo: unix-compatible?
102  spp.SetAttribute("lib", lib_);
103  spp.SetAttribute("path", path_);
104 
105  char* var, *val;
106  va_list args;
107  va_start(args, path_);
108  while((var = va_arg(args, char *)) != NULL){
109  val = va_arg(args, char *);
110  if(val != NULL){
111  TiXmlElement vare(var);
112  vare.SetAttribute("val", val);
113  spp.InsertEndChild(vare);
114  }else{
115  printf("Value is not provided for parameter <%s> in lib <%s>, path <%s>\n", var, lib_, path_);
116  break;
117  };
118  }
119  va_end(args);
120 
122 };
#define PAVPROT_NODE_SPP
Definition: PAVProtocolDef.h:53

◆ AddStartNode()

void MessageManager::AddStartNode ( const char *  lib_,
const char *  path_,
const char *  comment_ 
)
25  {
27  start.SetAttribute("lib", lib_);
28  start.SetAttribute("path", path_);
29  TiXmlText comment(comment_);
30  start.InsertEndChild(comment);
32 };
#define PAVPROT_NODE_START
Definition: PAVProtocolDef.h:56
Definition: tinyxml.h:1213

◆ AddStopNode()

void MessageManager::AddStopNode ( )
20  {
23 };
stop
===========================================================================
Definition: CreateParaset_GS_Alg.C:54
#define PAVPROT_NODE_STOP
Definition: PAVProtocolDef.h:57

◆ Clean()

void MessageManager::Clean ( )
4  {
5  m_messId++;
6  m_xml = "";
7  m_xmlDoc.Clear();
8 };
std::string m_xml
Definition: MessageManager.h:45
void Clear()
Delete all the children of this node. Does not affect 'this'.
Definition: tinyxml.cpp:169

◆ CreateMessage()

void MessageManager::CreateMessage ( )
10  {
11  Clean();
14  main.SetAttribute("version", PAVCLIENTVERSION);
15  mess.SetAttribute("id", m_messId);
18 };
#define PAVPROT_NODE_MESS
Definition: PAVProtocolDef.h:58
#define PAVPROT_NODE_ROOT
Definition: PAVProtocolDef.h:50
#define PAVCLIENTVERSION
Definition: PAVProtocol.h:7
void Clean()
Definition: MessageManager.cpp:4
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:698
int main(int argc, char *argv[])
Definition: check_cp.C:436

◆ FillBuff()

void MessageManager::FillBuff ( )
124  {
125  TiXmlPrinter printer;
126  m_xmlDoc.Accept( &printer );
127  printf("%s\n", printer.CStr());//ToDo: verbisity
128  std::string str;
129  str << m_xmlDoc;
130  WriteMessage(m_messBuf, str.c_str(), str.length());
131 };
std::vector< uint8 > m_messBuf
Definition: MessageManager.h:49
virtual bool WriteMessage(std::vector< uint8 > &buf_, const void *srcbuf_, uint32 srcsize_)
Definition: PAVProtocol.cpp:61
virtual bool Accept(TiXmlVisitor *content) const
Definition: tinyxml.cpp:1156
Definition: tinyxml.h:1738
const char * CStr()
Return the result.
Definition: tinyxml.h:1775

◆ FillBuffOuter()

void MessageManager::FillBuffOuter ( uint8 buf_,
uint32  size_ 
)
inline
39  {
40  printf("%s\n", buf_);//ToDo: verbisity
41  WriteMessage(m_messBuf, buf_, size_);
42  };

◆ GetBuf()

uint8* MessageManager::GetBuf ( )
inline
44 {return &m_messBuf[0];};

◆ GetBufSize()

uint32 MessageManager::GetBufSize ( )
inline
45 {return m_messBuf.size();};

Member Data Documentation

◆ m_messBuf

std::vector<uint8> MessageManager::m_messBuf
private

◆ m_messId

uint32 MessageManager::m_messId
private

◆ m_xml

std::string MessageManager::m_xml
private

◆ m_xmlDoc

TiXmlDocument MessageManager::m_xmlDoc
private

◆ m_xmlDocAddPtr

TiXmlElement* MessageManager::m_xmlDocAddPtr
private

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