CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InitMsgBuilder.cc
Go to the documentation of this file.
4 #include <cassert>
5 #include <cstring>
6 #include <cstdint>
7 #include <unistd.h>
8 
10  uint32 run, const Version& v,
11  const char* release_tag,
12  const char* process_name,
13  const char* output_module_label,
14  uint32 output_module_id,
15  const Strings& hlt_names,
16  const Strings& hlt_selections,
17  const Strings& l1_names,
18  uint32 adler_chksum):
19  buf_((uint8*)buf),size_(size)
20 {
22  // fixed length parts
23  new (&h->version_) Version(v);
24  convert(run,h->run_);
25  // variable length parts
26  uint32 tag_len = strlen(release_tag);
27  assert(tag_len < 0x00ff);
28  uint8* pos = buf_+sizeof(InitHeader);
29 
30  *pos++ = tag_len; // length of release tag
31  memcpy(pos,release_tag,tag_len); // copy release tag in
32  pos += tag_len;
33 
34  //Lets put Process Name (Length and then Name) right after release_tag
35  uint32 process_name_len = strlen(process_name);
36  assert(process_name_len < 0x00ff);
37  //Put process_name_len
38  *pos++ = process_name_len;
39  //Put process_name
40  memcpy(pos,process_name,process_name_len);
41  pos += process_name_len;
42 
43  // output module label next
44  uint32 outmod_label_len = strlen(output_module_label);
45  assert(outmod_label_len < 0x00ff);
46  *pos++ = outmod_label_len;
47  memcpy(pos,output_module_label,outmod_label_len);
48  pos += outmod_label_len;
49 
50  // output module ID next
51  convert(output_module_id, pos);
52  pos += sizeof(char_uint32);
53 
54  pos = MsgTools::fillNames(hlt_names,pos);
55  pos = MsgTools::fillNames(hlt_selections,pos);
56  pos = MsgTools::fillNames(l1_names,pos);
57 
58  // adler32 check sum of data blob
59  convert(adler_chksum, pos);
60  pos = pos + sizeof(uint32);
61 
62  data_addr_ = pos + sizeof(char_uint32);
63  setDataLength(0);
64 
65  // Two news fileds added to InitMsg in Proto V3 init_header_size, and event_header_size.
66  //Set the size of Init Header Start of buf to Start of desc.
67  convert((uint32)(data_addr_ - buf_), h->init_header_size_);
68 
69  // 18-Apr-2008, KAB: create a dummy event message so that we can
70  // determine the expected event header size. (Previously, the event
71  // header size was hard-coded.)
72  std::vector<bool> dummyL1Bits(l1_names.size());
73  std::vector<char> dummyHLTBits(hlt_names.size());
74  const uint32 TEMP_BUFFER_SIZE = 256;
75  char msgBuff[TEMP_BUFFER_SIZE]; // not large enough for a real event!
76  uint32_t adler32 = 0;
77  char host_name[255];
78  int got_host = gethostname(host_name, 255);
79  if(got_host != 0) strcpy(host_name, "noHostNameFoundOrTooLong");
80  EventMsgBuilder dummyMsg(&msgBuff[0], TEMP_BUFFER_SIZE, 0, 0, 0, 0, 0,
81  dummyL1Bits, (uint8*) &dummyHLTBits[0],
82  hlt_names.size(), adler32, host_name);
83 
84  //Size of Event Header
85  uint32 eventHeaderSize = dummyMsg.headerSize();
86  convert(eventHeaderSize, h->event_header_size_);
87 }
88 
90 {
91  convert(len,data_addr_-sizeof(char_uint32));
93  new (&h->header_) Header(Header::INIT, data_addr_ - buf_ + len);
94 }
95 
96 
98 {
99 
100  HeaderView v(buf_);
101  return v.size();
102 }
103 
104 
106 {
108  return convert32(h->run_);
109 }
110 
Header header_
Definition: InitMessage.h:59
std::vector< std::string > Strings
Definition: MsgTools.h:18
assert(m_qm.get())
char_uint32 event_header_size_
Definition: InitMessage.h:63
uint8 * data_addr_
void setDataLength(uint32 registry_length)
uint32 size() const
InitMsgBuilder(void *msg_mem, uint32 size, uint32 run, const Version &v, const char *release_tag, const char *process_name, const char *output_module_label, uint32 output_module_id, const Strings &hlt_names, const Strings &hlt_selections, const Strings &l1_names, uint32 adler32_chksum)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Version version_
Definition: InitMessage.h:60
unsigned int uint32
Definition: MsgTools.h:13
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
uint32 size() const
Definition: MsgHeader.h:35
char_uint32 run_
Definition: InitMessage.h:61
uint32 convert32(char_uint32 v)
Definition: MsgTools.h:30
unsigned char uint8
Definition: MsgTools.h:11
uint8 * fillNames(const Strings &names, uint8 *pos)
Definition: MsgTools.h:75
uint32 headerSize() const
size_(0)
Definition: OwnArray.h:181
uint32 run() const
tuple size
Write out results.
char_uint32 init_header_size_
Definition: InitMessage.h:62