00001 00007 /* 00008 Coordinates broadcast of a data type from a Controller/Seq 00009 to all other Controller/Sequencer type objects (they must 00010 run in a thread!) 00011 */ 00012 00013 #ifndef _BCASTOBJ_H 00014 #define _BCASTOBJ_H 00015 00016 #include "BroadcastMgr.h" 00017 #include "BroadcastClient.h" 00018 #include "common.h" 00019 00020 template <class T> class SimpleBroadcastObject : public BroadcastClient { 00021 00022 public: 00023 00024 SimpleBroadcastObject(int id) : BroadcastClient(id) { 00025 if ( sizeof(T) > BCASTMSGSIZE ) { 00026 NAMD_bug("SimpleBroadcastObject instantiated on class larger than BCASTMSGSIZE"); 00027 } 00028 } 00029 ~SimpleBroadcastObject() { } 00030 00031 T get(int tag) { 00032 T tmp; 00033 while ( BroadcastMgr::Object()->getbuf(*this, tag, (void*)(&tmp)) < 0 ) { 00034 suspendFor(tag); 00035 } 00036 return tmp; 00037 } 00038 00039 void publish(int tag,const T &t ) { 00040 BroadcastMgr::Object()->send(*this, tag, (void*)(&t), sizeof(T)); 00041 } 00042 00043 }; 00044 00045 #endif
1.3.9.1