Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DDSSubscription.cxx

Go to the documentation of this file.
00001 
00002 //                                                                           //
00003 // DDSSubscription                                                           //
00004 //                                                                           //
00005 // Package: DDS (Data Dispatcher System).                                    //
00006 //                                                                           //
00007 // S. Kasahara 5/2001                                                        //
00008 //                                                                           //
00009 // Purpose: Subscription class used to specify client's subscription needs   //
00010 //          server.                                                          //
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 // Definition of static data members
00025 // *********************************
00026 
00027 //CVSID("$Id: DDSSubscription.cxx,v 1.15 2005/02/16 05:07:46 schubert Exp $");
00028  
00029 // Definition of methods (alphabetical order)
00030 // ******************************************
00031 
00032 
00033 void DDSSubscription::AddStream(Per::EStreamType streamtype, string selection){
00034   //
00035   // Purpose: Add new stream to subscription list.
00036   //
00037   // Argument: streamtype  stream of type Per::EStreamType to be added.
00038   //           selection   selection cut to be applied to entries in this
00039   //                       stream (default="" => no selection cuts applied).
00040   // 
00041   // Return: none.
00042   //
00043   // Contact: S. Kasahara
00044   //
00045   // Notes: If the requested stream is already in subscription list, the 
00046   //        requested selection string is applied to the existing stream.
00047   //
00048 
00049   // If streamtype is not already in map, this will add it
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   // Purpose: Default constructor for DDSSubscription class.  
00060   //  
00061   // Arguments: datasource  defines source of data
00062   //                        (default = DDS::kDaq)
00063   //            keepupmode  enumerated keepup mode (default = DDS::kFileKeepUp)
00064   //
00065   // Return: n/a.
00066   //
00067   // Contact: S. Kasahara
00068   //
00069 
00070 }
00071 
00072 DDSSubscription::~DDSSubscription() {
00073   // Purpose: Destructor.
00074   //
00075   // Argument: n/a.
00076   //
00077   // Return: n/a.
00078   //
00079   // Contact: S. Kasahara
00080   //
00081 
00082 }
00083 
00084 
00085 std::ostream& DDSSubscription::Print(std::ostream& ms) const {
00086   //
00087   // Purpose: Print DDSSubscription status on std::ostream.
00088   //
00089   // Argument: ms  std::ostream to print on.
00090   //
00091   // Return: std::ostream reference.
00092   //
00093   // Contact: S. Kasahara
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* /* option */) const { 
00121   Print(std::cout); 
00122 }
00123 
00124 void DDSSubscription::RemoveStream(Per::EStreamType streamtype) {
00125   //
00126   // Purpose: Remove stream from subscription list.
00127   //
00128   // Argument: streamtype  requested stream
00129   // 
00130   // Return: none.
00131   //
00132   // Contact: S. Kasahara
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   // Purpose: Remove all streams from subscription list.
00145   //
00146   // Argument: none.
00147   // 
00148   // Return: none.
00149   //
00150   // Contact: S. Kasahara
00151   //
00152 
00153   fStreamMap.clear();
00154 
00155 }
00156 
00157 void DDSSubscription::SetSelection(Per::EStreamType streamtype, string selection) {
00158   //
00159   // Purpose: Modify selection string for requested stream.
00160   //
00161   // Argument: streamtype  stream of type Per::EStreamType.
00162   //           selection   selection cut to be applied to entries in this
00163   //                       stream (default ="" => no selection cuts applied).
00164   // 
00165   // Return: none.
00166   //
00167   // Contact: S. Kasahara
00168   //
00169   // Notes: If the requested stream does not already exist in subscription 
00170   //        list, the stream is added to the list. (Hence this method
00171   //        performs the same function as AddStream.)
00172   //
00173 
00174   // If streamtype is not already in map, this will add it
00175   fStreamMap[Per::AsString(streamtype)] = selection.c_str();
00176 
00177 }
00178 
00179 void DDSSubscription::SetSelection(std::string stream, std::string selection) {
00180    //
00181    // Purpose: Modify selection string for requested stream.
00182    //
00183    // Argument: stream      streamname
00184    //           selection   selection cut to be applied to entries in this
00185    //                       stream (default ="" => no selection cuts applied).
00186    // 
00187    // Return: none.
00188    //
00189    // Contact: S. Kasahara
00190    //
00191    // Notes: If the requested stream does not already exist in subscription 
00192    //        list, the stream is added to the list. 
00193    //
00194  
00195    // If streamtype is not already in map, this will add it
00196    fStreamMap[stream.c_str()] = selection.c_str();
00197  
00198 }
00199 
00200 int DDSSubscription::SetStreams(std::string streamList){
00201   //
00202   // Purpose: Set active streams in subscription to correspond to those
00203   //          in delimiter separated (,;: ) streamList.
00204   //
00205   // Argument: streamList  delimiter (,;: ) separated list of streams.
00206   // 
00207   // Return: Number of streams set.
00208   //
00209   // Contact: S. Kasahara
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 

Generated on Mon Feb 15 11:06:36 2010 for loon by  doxygen 1.3.9.1