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

DDS.cxx

Go to the documentation of this file.
00001 
00002 //                                                                         // 
00003 // DDS                                                                     //
00004 //                                                                         //
00005 // Package: DDS (Data Dispatcher System).                                  //
00006 //                                                                         //
00007 // S. Kasahara 05/2001                                                     //
00008 //                                                                         //
00009 // Purpose: Define data types and provide general purpose utility methods  // 
00010 //          to the data dispatcher system package.                         //
00011 //                                                                         //
00013 
00014 #include "TString.h"  // for use of ToLower method
00015 
00016 #include "MessageService/MsgService.h"
00017 #include "Dispatcher/DDS.h"
00018 
00019 CVSID("$Id: DDS.cxx,v 1.19 2006/11/05 20:31:13 schubert Exp $");
00020 
00021 // Definition of methods (alphabetical order)
00022 // ******************************************
00023 
00024 const char* DDS::AsString(EDataSource datasource) {
00025   //  Purpose:  Convert enumerated data source to a data source string.
00026   //
00027   //  Argument: datasource   enumerated EDataSource described in DDS.h.
00028   //
00029   //  Return:  data source string of type const char*. If data source is
00030   //           unknown, returns "Unknown".
00031   //
00032   //  Contact:   S. Kasahara
00033   //
00034 
00035   switch ( datasource ) {
00036     case kDaq: 
00037       return "DAQ";
00038     case kDcs: 
00039       return "DCS";
00040     default:
00041       MSG("DDS",Msg::kWarning) 
00042       << "DDS::AsString called with unknown message type" 
00043       << (int)datasource << endl;
00044       return "Unknown";
00045   }//end of switch
00046 
00047 }
00048 
00049 const char* DDS::AsString(EKeepUpMode keepupmode) {
00050   //  Purpose:  Convert enumerated keepup mode to a keepup mode string.
00051   //
00052   //  Argument: keepupmode   enumerated EKeepUpMode described in DDS.h.
00053   //
00054   //  Return:  keepup mode string of type const char*. If keepup mode is
00055   //           unknown, returns "Unknown".
00056   //
00057   //  Contact:   S. Kasahara
00058   //
00059 
00060   switch ( keepupmode ) {
00061     case kAll: 
00062       return "All";
00063     case kFileKeepUp: 
00064       return "FileKeepUp";
00065     case kRecordKeepUp: 
00066       return "RecordKeepUp";
00067     default:
00068       MSG("DDS",Msg::kWarning) 
00069       << "DDS::AsString called with unknown keepup mode" 
00070       << (int)keepupmode << endl;
00071       return "Unknown";
00072   }//end of switch
00073 
00074 }
00075 
00076 const char* DDS::AsString(EMessageType messagetype) {
00077   //  Purpose:  Convert enumerated message type to a message string.
00078   //
00079   //  Argument: messagetype: enumerated EMessageType described in DDS.h.
00080   //
00081   //  Return:  message string of type const char*. If message type is
00082   //           unknown, returns "Unknown".
00083   //
00084   //  Contact:   S. Kasahara
00085   //
00086 
00087   switch ( messagetype ) {
00088     case kData: 
00089       return "Data";
00090     case kStatus: 
00091       return "Status";
00092     case kGoToFile:
00093       return "GoToFile";
00094     case kNext: 
00095       return "Next";
00096     case kSubscribe:  
00097       return "Subscribe";
00098     case kShutdown:
00099       return "Shutdown";
00100     case kPermissionDenied:
00101       return "PermissionDenied";
00102     case kSaturated:
00103       return "Saturated";
00104     case kFileError:
00105       return "FileError";
00106     case kTimeoutNewFile:
00107       return "TimeoutNewFile";
00108     case kTimeoutNewRecord:
00109       return "TimeoutNewRecord";
00110     case kInvalidSelection:
00111       return "InvalidSelection";
00112     case kMessageUnknown:
00113       return "MessageUnknown";
00114     case kOk:
00115       return "Ok";
00116     case kSocketError:
00117       return "SocketError";
00118     case kSystemError:
00119       return "SystemError";
00120     case kError:
00121       return "Error";
00122     case kInactive:
00123       return "Inactive";
00124     default:
00125       MSG("DDS",Msg::kWarning) 
00126       << "DDS::AsString called with unknown message type" 
00127       << (int)messagetype << endl;
00128       return "Unknown";
00129   }//end of switch
00130 
00131 }
00132 
00133 const char* DDS::AsString(EClientType clienttype) {
00134   //  Purpose:  Convert enumerated client type to a client string.
00135   //
00136   //  Argument: clienttype: enumerated EClientType described in DDS.h.
00137   //
00138   //  Return:  client type as string.  If unknown, returns "Unknown".
00139   //
00140   //  Contact:   S. Kasahara
00141   //
00142 
00143   switch ( clienttype ) {
00144     case kOnlineMonitor:
00145       return "OnlineMonitor";
00146     case kDatabaseUpdater:
00147       return "DatabaseUpdater";
00148     case kEventDisplay:
00149       return "EventDisplay";
00150     case kOther:
00151       return "Other";
00152     case kUnknownClientType:
00153       return "Unknown";
00154     default:
00155       MSG("DDS",Msg::kWarning)
00156       << "DDS::AsString called with unknown client type"
00157       << (int)clienttype << endl;
00158       return "Unknown";
00159   }//end of switch
00160 
00161 }
00162 
00163 int DDS::GetKeepUpCode(const char* keepupmode) {
00164   //  Purpose:  Convert text string keepup mode to an enumerated code.
00165   //
00166   //  Argument: keepupmode  string  
00167   //
00168   //  Return:  returns -1 if no match
00169   //
00170   //  Contact:   S. Kasahara
00171   //
00172 
00173   TString tmpstr(keepupmode);
00174   tmpstr.ToLower();
00175   if      ( strcmp(tmpstr.Data(),"all") == 0 ) return DDS::kAll;
00176   else if ( strcmp(tmpstr.Data(),"filekeepup") == 0 ) return DDS::kFileKeepUp;
00177   else if (strcmp(tmpstr.Data(),"recordkeepup")==0) return DDS::kRecordKeepUp;
00178   return -1;
00179 
00180 }
00181 
00182 int DDS::GetDataSourceCode(const char* datasource) {
00183   //  Purpose:  Convert text string datasource to an enumerated code.
00184   //
00185   //  Argument: datasource  string  
00186   //
00187   //  Return:  returns -1 if no match
00188   //
00189   //  Contact:   S. Kasahara
00190   //
00191 
00192   TString tmpstr(datasource);
00193   tmpstr.ToLower();
00194   if      ( strcmp(tmpstr.Data(),"daq") == 0 ) return DDS::kDaq;
00195   else if ( strcmp(tmpstr.Data(),"dcs") == 0 ) return DDS::kDcs;
00196   return -1;
00197 
00198 }
00199 
00200 DDS::EClientType DDS::GetClientType(const char* clienttype) {
00201   //  Purpose:  Convert text string clienttype to an enumerated code.
00202   //
00203   //  Argument: clienttype  string  
00204   //
00205   //  Return:  returns -1 if no match
00206   //
00207   //  Contact:   S. Kasahara
00208   //
00209 
00210   TString tmpstr(clienttype);
00211   tmpstr.ToLower();
00212   if (strcmp(tmpstr.Data(),"onlinemonitor")  ==0) return DDS::kOnlineMonitor;
00213   if (strcmp(tmpstr.Data(),"databaseupdater")==0) return DDS::kDatabaseUpdater;
00214   if (strcmp(tmpstr.Data(),"eventdisplay")   ==0) return DDS::kEventDisplay;
00215   if (strcmp(tmpstr.Data(),"other")          ==0) return DDS::kOther;
00216   if (strcmp(tmpstr.Data(),"unknown")      ==0) return DDS::kUnknownClientType;
00217   MSG("DDS",Msg::kWarning) << "DDS::GetClientType called with unknown"
00218                            << "\nclienttype " << clienttype 
00219                            << " Return DDS::kUnknownClientType." << endl;
00220   return DDS::kUnknownClientType;
00221 
00222 }
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 

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