NAMD
BroadcastObject.h
Go to the documentation of this file.
1 
7 /*
8  Coordinates broadcast of a data type from a Controller/Seq
9  to all other Controller/Sequencer type objects (they must
10  run in a thread!)
11 */
12 
13 #ifndef _BCASTOBJ_H
14 #define _BCASTOBJ_H
15 
16 #include "BroadcastMgr.h"
17 #include "BroadcastClient.h"
18 #include "LdbCoordinator.h"
19 #include "common.h"
20 
21 template <class T> class SimpleBroadcastObject : public BroadcastClient {
22 
23  public:
24 
25  const LDObjHandle *ldObjPtr;
26 
27  SimpleBroadcastObject(int id, const LDObjHandle *h = 0) : BroadcastClient(id), ldObjPtr(h) {
28  if ( sizeof(T) > BCASTMSGSIZE ) {
29  NAMD_bug("SimpleBroadcastObject instantiated on class larger than BCASTMSGSIZE");
30  }
31  }
33 
34  T get(int tag) {
35  T tmp;
37  while ( BroadcastMgr::Object()->getbuf(*this, tag, (void*)(&tmp)) < 0 ) {
38  suspendFor(tag);
39  }
41  return tmp;
42  }
43  int getSize() {
44  return BroadcastMgr::Object()->boidSize();
45  }
46  int getBcastSize() {
48  }
49  int getTaggedSize() {
51  }
52  void publish(int tag,const T &t ) {
53  BroadcastMgr::Object()->send(*this, tag, (void*)(&t), sizeof(T));
54  }
55 
56 };
57 
58 #endif
void startWork(const LDObjHandle &handle)
SimpleBroadcastObject(int id, const LDObjHandle *h=0)
void pauseWork(const LDObjHandle &handle)
int boidBroadcastSize()
Definition: BroadcastMgr.C:28
const LDObjHandle * ldObjPtr
void send(BroadcastClient &b, int tag, void *buf, size_t)
Definition: BroadcastMgr.C:69
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int boidTaggedMsgSize()
Definition: BroadcastMgr.C:38
static LdbCoordinator * Object()
void publish(int tag, const T &t)
void suspendFor(int tag)
static BroadcastMgr * Object()
Definition: BroadcastMgr.h:95
#define BCASTMSGSIZE
Definition: BroadcastMgr.h:22