00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014
00015 #include "Dispatcher/DDSSubscription.h"
00016 #include "MessageService/MsgService.h"
00017 #include "Util/UtilString.h"
00018
00019 std::ostream& operator << (std::ostream& ms, DDSSubscription* sub)
00020 { return sub->Print(ms); }
00021
00022 ClassImp(DDSSubscription)
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 void DDSSubscription::AddStream(Per::EStreamType streamtype, string selection){
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 fStreamMap[Per::AsString(streamtype)] = selection.c_str();
00051
00052 }
00053
00054 DDSSubscription::DDSSubscription(DDS::EDataSource datasource,
00055 DDS::EKeepUpMode keepupmode):
00056 fDataSource(datasource),fKeepUpMode(keepupmode),
00057 fOffLine(false),fMaxSyncDelay(15),fKeepUpWindow(30) {
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 }
00071
00072 DDSSubscription::~DDSSubscription() {
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 }
00083
00084
00085 std::ostream& DDSSubscription::Print(std::ostream& ms) const {
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 ms << " DataSource " << DDS::AsString(fDataSource) << "." << endl;
00097 ms << " KeepUpMode " << DDS::AsString(fKeepUpMode) << "." << endl;
00098 ms << " MaxSyncDelay " << fMaxSyncDelay << "." << endl;
00099 ms << " KeepUpWindow " << fKeepUpWindow << "." << endl;
00100 if (this -> IsOffLine()) ms << " OffLine true." << endl;
00101 else ms << " OffLine false." << endl;
00102
00103 ms << " Number of streams = " << GetNumStream() << endl;
00104 Int_t istream = 0;
00105 for (StreamMapConstItr citr = fStreamMap.begin(); citr != fStreamMap.end();
00106 ++citr) {
00107 ms << " " << ++istream << ")" << "Stream: " << citr->first << ".";
00108 if ( (citr -> second).IsNull() ) {
00109 ms << " No selection cut specified." << endl;
00110 }
00111 else {
00112 ms << " Selection cut: " << citr->second << "." << endl;
00113 }
00114 }
00115
00116 return ms;
00117
00118 }
00119
00120 void DDSSubscription::Print(Option_t* ) const {
00121 Print(std::cout);
00122 }
00123
00124 void DDSSubscription::RemoveStream(Per::EStreamType streamtype) {
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 StreamMapItr itr = fStreamMap.find(Per::AsString(streamtype));
00136 if (itr != fStreamMap.end()) {
00137 fStreamMap.erase(itr);
00138 }
00139
00140 }
00141
00142 void DDSSubscription::Reset() {
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 fStreamMap.clear();
00154
00155 }
00156
00157 void DDSSubscription::SetSelection(Per::EStreamType streamtype, string selection) {
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 fStreamMap[Per::AsString(streamtype)] = selection.c_str();
00176
00177 }
00178
00179 void DDSSubscription::SetSelection(std::string stream, std::string selection) {
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 fStreamMap[stream.c_str()] = selection.c_str();
00197
00198 }
00199
00200 int DDSSubscription::SetStreams(std::string streamList){
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 fStreamMap.clear();
00214 std::vector<std::string> ls;
00215 UtilString::StringTok(ls,streamList,",:; ");
00216
00217 std::vector<std::string>::iterator vitr;
00218 for ( vitr = ls.begin(); vitr != ls.end(); vitr++ ) {
00219 fStreamMap[(*vitr).c_str()] = "";
00220 }
00221 return fStreamMap.size();
00222
00223 }
00224
00225
00226
00227
00228
00229
00230
00231