ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::IPCMat Class Reference

#include <IPCMat.h>

Collaboration diagram for Trk::IPCMat:

Classes

struct  MsgBuf

Public Member Functions

 IPCMat (IMessageSvc *msgSvc)
 ~IPCMat ()
 IPCMat (const IPCMat &)=delete
IPCMatoperator= (const IPCMat &)=delete
StatusCode init (void)
StatusCode allocate (int)
StatusCode write (const std::string &, bool)
StatusCode end ()
StatusCode incMat (uint32_t, uint32_t, double)
StatusCode incVec (uint32_t, double)
StatusCode scaleMat (int)
StatusCode scaleVec (int)
StatusCode setScale (int)
StatusCode setVersion (float, bool)
StatusCode reSize (int)
StatusCode removeModule (int)
StatusCode removeAlignPar (int)
void summary ()

Private Member Functions

 IPCMat ()
const std::string & name () const

Private Attributes

IMessageSvc * m_msgSvc {}
int m_ncalls {}
int m_msgid {}
std::string m_name
MsgStream * m_log {}
pid_t m_ipcmat_pid {}
struct Trk::IPCMat::MsgBuf m_ipcmat_msgp

Detailed Description

Definition at line 37 of file IPCMat.h.

Constructor & Destructor Documentation

◆ IPCMat() [1/3]

Trk::IPCMat::IPCMat ( IMessageSvc * msgSvc)

Definition at line 22 of file IPCMat.cxx.

23 : m_msgSvc(msgSvc),
24 m_ncalls(0),
25 m_msgid(0),
26 m_name("GlobAlign::IPCMat"),
27 m_log(new MsgStream(msgSvc,name()))
28{
29}
const std::string & name() const
Definition IPCMat.cxx:32
std::string m_name
Definition IPCMat.h:72
MsgStream * m_log
Definition IPCMat.h:73
int m_msgid
Definition IPCMat.h:71
int m_ncalls
Definition IPCMat.h:70
IMessageSvc * m_msgSvc
Definition IPCMat.h:69

◆ ~IPCMat()

Trk::IPCMat::~IPCMat ( )
inline

Definition at line 42 of file IPCMat.h.

42{}

◆ IPCMat() [2/3]

Trk::IPCMat::IPCMat ( const IPCMat & )
delete

◆ IPCMat() [3/3]

Trk::IPCMat::IPCMat ( )
private

Member Function Documentation

◆ allocate()

StatusCode Trk::IPCMat::allocate ( int size)

Definition at line 238 of file IPCMat.cxx.

238 {
239 //MsgStream log(m_msgSvc,name());
240 if (m_log->level()>=MSG::INFO) {
241 *m_log << MSG::INFO; m_log->setColor(MSG::BLUE);
242 *m_log << "in IPCMat::ipcmat_allocate" << endmsg;
243 }
244
246 m_ipcmat_msgp.data.n = size;
247
248 if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
249 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
250 << " Error number is " << errno << endmsg;
251 return StatusCode::FAILURE;
252 }
253
254 return StatusCode::SUCCESS;
255}
#define endmsg
#define M_ALLOCATE
Definition IPCMat.h:17
struct Trk::IPCMat::MsgBuf m_ipcmat_msgp

◆ end()

StatusCode Trk::IPCMat::end ( )

Definition at line 324 of file IPCMat.cxx.

324 {
325 //MsgStream log(m_msgSvc,name());
326
327 m_ipcmat_msgp.mtype = M_END;
328 if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
329 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
330 << " Error number is " << errno << endmsg;
331 return StatusCode::FAILURE;
332 }
333
334 // let chid finish its jobs
335 wait4(m_ipcmat_pid, nullptr, 0, nullptr);
336 return StatusCode::SUCCESS;
337}
#define M_END
Definition IPCMat.h:29
pid_t m_ipcmat_pid
Definition IPCMat.h:74

◆ incMat()

StatusCode Trk::IPCMat::incMat ( uint32_t a,
uint32_t b,
double c )

Definition at line 39 of file IPCMat.cxx.

39 {
40 //MsgStream log(m_msgSvc,name());
41
42 m_ipcmat_msgp.mtype = M_INCR_M;
43 m_ipcmat_msgp.data.matrix.i = a;
44 m_ipcmat_msgp.data.matrix.j = b;
45 m_ipcmat_msgp.data.matrix.v = c;
46
47 if (msgsnd(m_msgid,&m_ipcmat_msgp, sizeof(long)+2*sizeof(uint32_t)+sizeof(double),0)<0) {
48 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " Error number is " << errno << endmsg;
49 return StatusCode::FAILURE;
50 }
51
52 return StatusCode::SUCCESS;
53}
#define M_INCR_M
Definition IPCMat.h:18
static Double_t a

◆ incVec()

StatusCode Trk::IPCMat::incVec ( uint32_t a,
double c )

Definition at line 58 of file IPCMat.cxx.

58 {
59 //MsgStream log(m_msgSvc,name());
60
61 m_ipcmat_msgp.mtype = M_INCR_V;
62 m_ipcmat_msgp.data.matrix.i = a;
63 m_ipcmat_msgp.data.matrix.j = 0;
64 m_ipcmat_msgp.data.matrix.v = c;
65
66 if (m_log->level()>=MSG::DEBUG)
67 *m_log << MSG::DEBUG << "call number " << std::setw(8) << m_ncalls
68 << endmsg;
69
70 if (msgsnd(m_msgid,&m_ipcmat_msgp, sizeof(long)+2*sizeof(uint32_t)+sizeof(double),0)<0) {
71 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
72 << " Error number is " << errno << endmsg;
73 return StatusCode::FAILURE;
74 }
75
76 m_ncalls++;
77 return StatusCode::SUCCESS;
78}
#define M_INCR_V
Definition IPCMat.h:19

◆ init()

StatusCode Trk::IPCMat::init ( void )

Definition at line 177 of file IPCMat.cxx.

177 {
178 //MsgStream log(m_msgSvc,name());
179 if (m_log->level()>=MSG::INFO) {
180 *m_log << MSG::INFO; m_log->setColor(MSG::BLUE);
181 *m_log << "in IPCMat::ipcmat_init" << endmsg;
182 }
183
184 key_t key;
185
186 if ((key = ftok("/dev/null", 69)) == -1) {
187 *m_log << MSG::ERROR << "Unable to get key" << endmsg;
188 return StatusCode::FAILURE;
189 }
190 else{
191 if (m_log->level()>=MSG::INFO)
192 *m_log << MSG::INFO << "Got key " << key << endmsg;
193 }
194
195 // destroy message queue if existed
196 msgctl(m_msgid, IPC_RMID, nullptr);
197
198 m_msgid = msgget(key, IPC_CREAT | 0666);
199 if(m_msgid < 0) {
200 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " key: " << key
201 << " Error number is " << errno << endmsg;
202 return StatusCode::FAILURE;
203 }else{
204 if (m_log->level()>=MSG::INFO)
205 *m_log << MSG::INFO << "m_msgid = " << m_msgid << endmsg;
206 }
207
208 // fork receiver
209 if ((m_ipcmat_pid = fork()) < 0) {
210 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " key: " << key
211 << " Error number is " << errno << endmsg;
212 return StatusCode::FAILURE;
213 }
214 if (m_log->level()>=MSG::INFO)
215 *m_log << MSG::INFO << "ipcmat_pid = " << m_ipcmat_pid << endmsg;
216
217 if (m_ipcmat_pid == 0)
218 {
219 // ipcmatr compiled in 64 bits using same struct for message queue
220 // as declared in IPCMat.h. Must be in PATH
221 if (execlp("ipcmatr", "", NULL) < 0)
222 {
223 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " key: " << key
224 << " Error number is " << errno << endmsg;
225 return StatusCode::FAILURE;
226 }
227 }
228
229 // let the children start
230 sleep(1);
231
232 return StatusCode::SUCCESS;
233}

◆ name()

const std::string & Trk::IPCMat::name ( ) const
private

Definition at line 32 of file IPCMat.cxx.

32 {
33 return m_name;
34}

◆ operator=()

IPCMat & Trk::IPCMat::operator= ( const IPCMat & )
delete

◆ removeAlignPar()

StatusCode Trk::IPCMat::removeAlignPar ( int alpar)

Definition at line 159 of file IPCMat.cxx.

159 {
160 //MsgStream log(m_msgSvc,name());
161
163 m_ipcmat_msgp.data.n = alpar;
164
165 if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
166 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
167 << " Error number is " << errno << endmsg;
168 return StatusCode::FAILURE;
169 }
170
171 return StatusCode::SUCCESS;
172}
#define M_REMOVE_PAR
Definition IPCMat.h:26

◆ removeModule()

StatusCode Trk::IPCMat::removeModule ( int mod)

Definition at line 141 of file IPCMat.cxx.

141 {
142 //MsgStream log(m_msgSvc,name());
143
145 m_ipcmat_msgp.data.n = mod;
146
147 if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
148 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
149 << " Error number is " << errno << endmsg;
150 return StatusCode::FAILURE;
151 }
152
153 return StatusCode::SUCCESS;
154}
#define M_REMOVE_MOD
Definition IPCMat.h:25

◆ reSize()

StatusCode Trk::IPCMat::reSize ( int newsize)

Definition at line 122 of file IPCMat.cxx.

122 {
123 //MsgStream log(m_msgSvc,name());
124 if (m_log->level()>=MSG::INFO)
125 *m_log << MSG::INFO << "in ipcmat_resize" << endmsg;
126
127 m_ipcmat_msgp.mtype = M_RESIZE;
128 m_ipcmat_msgp.data.n = newsize;
129
130 if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
131 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " Error number is " << errno << endmsg;
132 return StatusCode::FAILURE;
133 }
134
135 return StatusCode::SUCCESS;
136}
#define M_RESIZE
Definition IPCMat.h:24

◆ scaleMat()

StatusCode Trk::IPCMat::scaleMat ( int scale)

Definition at line 83 of file IPCMat.cxx.

83 {
84 //MsgStream log(m_msgSvc,name());
85 if (m_log->level()>=MSG::INFO)
86 *m_log << MSG::INFO << "in ipcmat_scaleMat with scale=" << scale << endmsg;
87
89 m_ipcmat_msgp.data.scale = scale;
90
91 if (msgsnd(m_msgid,&m_ipcmat_msgp, sizeof(long)+sizeof(double),0)<0) {
92 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
93 << " Error number is " << errno << endmsg;
94 return StatusCode::FAILURE;
95 }
96
97 return StatusCode::SUCCESS;
98}
#define M_SCALE_M
Definition IPCMat.h:20

◆ scaleVec()

StatusCode Trk::IPCMat::scaleVec ( int scale)

Definition at line 103 of file IPCMat.cxx.

103 {
104 //MsgStream log(m_msgSvc,name());
105 if (m_log->level()>=MSG::INFO)
106 *m_log << MSG::INFO << "in ipcmat_scaleVec with scale=" << scale << endmsg;
107
108 m_ipcmat_msgp.mtype = M_SCALE_V;
109 m_ipcmat_msgp.data.scale = scale;
110
111 if (msgsnd(m_msgid,&m_ipcmat_msgp, sizeof(long)+sizeof(double),0)<0) {
112 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__ << " Error number is " << errno << endmsg;
113 return StatusCode::FAILURE;
114 }
115
116 return StatusCode::SUCCESS;
117}
#define M_SCALE_V
Definition IPCMat.h:21

◆ setScale()

StatusCode Trk::IPCMat::setScale ( int scale)

Definition at line 260 of file IPCMat.cxx.

260 {
261 //MsgStream log(m_msgSvc,name());
262 if (m_log->level()>=MSG::INFO)
263 *m_log << MSG::INFO << "setting m_scale to : " << scale << endmsg;
264
266 m_ipcmat_msgp.data.scale = scale;
267
268 if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
269 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
270 << " Error number is " << errno << endmsg;
271 return StatusCode::FAILURE;
272 }
273
274 return StatusCode::SUCCESS;
275}
#define M_SETSCALE
Definition IPCMat.h:27

◆ setVersion()

StatusCode Trk::IPCMat::setVersion ( float version,
bool isMatrix )

Definition at line 280 of file IPCMat.cxx.

280 {
281 //MsgStream log(m_msgSvc,name());
282
284 m_ipcmat_msgp.data.version = version;
285
286 std::string mType = isMatrix ? "MatVersion" : "VecVersion";
287 if (m_log->level()>=MSG::INFO)
288 *m_log << MSG::INFO << "setting " << mType << " to = " << version << endmsg;
289
290
291 if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(long)+sizeof(uint32_t), IPC_NOWAIT) < 0) {
292 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
293 << " Error number is " << errno << endmsg;
294 return StatusCode::FAILURE;
295 }
296
297 return StatusCode::SUCCESS;
298}
#define M_SETVERSION
Definition IPCMat.h:28

◆ summary()

void Trk::IPCMat::summary ( )

Definition at line 342 of file IPCMat.cxx.

342 {
343 //MsgStream log(m_msgSvc,name());
344
345 if (m_log->level()>=MSG::INFO) {
346 *m_log << MSG::INFO << "++++++++++++++++++++++++++++++++++++++++" << endmsg;
347 *m_log << MSG::INFO << " Total calls = " << m_ncalls << endmsg;
348 *m_log << MSG::INFO << "++++++++++++++++++++++++++++++++++++++++" << endmsg;
349 }
350}

◆ write()

StatusCode Trk::IPCMat::write ( const std::string & ipcname,
bool isMatrix )

Definition at line 303 of file IPCMat.cxx.

303 {
304 //MsgStream log(m_msgSvc,name());
305 if (m_log->level()>=MSG::INFO)
306 *m_log << MSG::INFO << "Writting ipcmat. Selected name is : " << ipcname
307 << endmsg;
308
309 m_ipcmat_msgp.mtype = isMatrix ? M_WRITE_M : M_WRITE_V;
310 strncpy(m_ipcmat_msgp.data.fname, ipcname.c_str(), sizeof(m_ipcmat_msgp.data.fname)-1);
311 m_ipcmat_msgp.data.fname[sizeof(m_ipcmat_msgp.data.fname) - 1] = '\0';
312
313 if (msgsnd(m_msgid, &m_ipcmat_msgp, sizeof(m_ipcmat_msgp)-sizeof(long), IPC_NOWAIT) < 0) {
314 *m_log << MSG::ERROR << "ipcmats: line: " << __LINE__
315 << " Error number is " << errno << endmsg;
316 return StatusCode::FAILURE;
317 }
318 return StatusCode::SUCCESS;
319}
#define M_WRITE_M
Definition IPCMat.h:22
#define M_WRITE_V
Definition IPCMat.h:23

Member Data Documentation

◆ m_ipcmat_msgp

struct Trk::IPCMat::MsgBuf Trk::IPCMat::m_ipcmat_msgp
private

◆ m_ipcmat_pid

pid_t Trk::IPCMat::m_ipcmat_pid {}
private

Definition at line 74 of file IPCMat.h.

74{};

◆ m_log

MsgStream* Trk::IPCMat::m_log {}
private

Definition at line 73 of file IPCMat.h.

73{};

◆ m_msgid

int Trk::IPCMat::m_msgid {}
private

Definition at line 71 of file IPCMat.h.

71{};

◆ m_msgSvc

IMessageSvc* Trk::IPCMat::m_msgSvc {}
private

Definition at line 69 of file IPCMat.h.

69{};

◆ m_name

std::string Trk::IPCMat::m_name
private

Definition at line 72 of file IPCMat.h.

◆ m_ncalls

int Trk::IPCMat::m_ncalls {}
private

Definition at line 70 of file IPCMat.h.

70{};

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