Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

InterCom.hpp

00001 #ifndef ZTT_DCS_INTER_COM_HPP
00002 #define ZTT_DCS_INTER_COM_HPP
00003 
00004 #include "FeeClient.hpp"
00005 #include "FeePacket.hpp"
00006 #include "FeeItemInfo.hpp"
00007 #include "FeeAckInfo.hpp"
00008 #include "FeeMsgInfo.hpp"
00009 #include "Logger.hpp"
00010 #include <boost/scoped_ptr.hpp>
00011 #include <boost/shared_ptr.hpp>
00012 #include "FeeAckInfo.hpp"
00013 #include "FeeServerMap.hpp"
00014 #include "FedServer.hpp"
00015 #include "DataAccess.hpp"
00016 
00017 #include <vector>
00018 
00019 
00020 
00021 namespace ztt { namespace dcs {
00022 
00026 #define INTERCOM_VERSION "0.7.2"
00027 
00028 
00029 #ifdef WIN32
00030 #define CLEAR_SCREEN "cls"
00031 #else
00032 #define CLEAR_SCREEN "clear"
00033 #endif
00034 
00035 
00036 /*
00037  * Remember interCom - error defines can have values from -60 to -79.
00038  * The area -70 to -79 is especially reserved for FeeAckInfos.
00039  * This area is reserved for interCom. Success is always 0.
00040  */
00041 
00045 #define INTERCOM_SUCCESS 0
00046 
00050 #define INTERCOM_WRONG_STATE -60
00051 
00056 #define CHECK_DNS_TRIES 3
00057 
00062 #define CHECK_DNS_TIMEOUT 5
00063 
00064 
00065 //class FedServer;
00066 //class DataAccess;
00067 
00080 class InterCom {
00081         public:
00082 
00083         static void setConfigDir(const std::string& configDir);
00094         static InterCom* createInterCom();
00095 
00099                 ~InterCom();
00100 
00104                 void subscribe();
00105 
00109                 void run(bool interactive=true);
00110 
00115                 void setUp();
00116 
00123 //              void returnResult(DimInfo* current);
00124          // !! Has been deprecated. Use instead the polymorph calls in
00125                  // FeeInfo !!
00126 
00127 #ifdef __DEBUG
00128 
00134                 void sendCommandMU();
00135 
00136 
00140         void doRandomCmnd();
00141 #endif
00142 
00151                 int sendCommand(char* target, boost::shared_ptr<FeePacket> pFeePacket);
00152 
00164         int executeCommand(char* data, int size);
00165 
00184                 boost::shared_ptr<FeePacket> createFeePacket(char* payload, int size,
00185                 bool checksumFlag = false, FlagBits feeServerFlag = NO_FLAGS,
00186                                 bool huffmanFlag = false);
00187 
00188                 boost::shared_ptr<FeePacket> createBroadCastFeePacket(char* payload, int size,
00189                 bool checksumFlag = false, FlagBits feeServerFlag = NO_FLAGS,
00190                                 std::vector<char*>* feeserverCollection = NULL,bool huffmanFlag = false);
00196                 std::vector<FeeItemInfo* >* getFeeItemInfoCollection();
00197 
00203                 std::vector<FeeAckInfo* >* getFeeAckInfoCollection();
00204 
00210         std::vector<FeeMsgInfo* >* getFeeMsgInfoCollection();
00221         void setLogEntry(unsigned int type, char* source, char* description);
00230         bool validateServerName(const char* serverName);
00234                 FeeServerMap* getFeeServerMap();
00240                 void setFeeServerMap(FeeServerMap);
00241 
00242         private:
00243 
00251                 InterCom();
00252 
00257         static InterCom* pInstance;
00258 
00267         bool isDimDnsUp();
00268 
00275         void stopAllFeeServer();
00276 
00280                 ACE_Thread_Mutex mutex;
00284                 ACE_Thread_Mutex mutexFeePack;
00285 
00286 
00287 #ifdef __DEBUG
00288 
00291                 void showAbout();
00292 
00297         void showFeeServers();
00298 
00302         void updateFeeServerMU();
00303 #endif
00304 
00305 
00311                 std::vector<FeeItemInfo*> mFeeItemInfoCollection;
00312 
00318                 std::vector<FeeAckInfo*> mFeeAckInfoCollection;
00319 
00325         std::vector<FeeMsgInfo*> mFeeMsgInfoCollection;
00326 
00331                 boost::scoped_ptr<FeeClient> mClient;
00332 
00337                 boost::scoped_ptr<FedServer> mFedServer;
00338 
00343                 boost::shared_ptr<DataAccess> mDataAx;
00344 
00349                 boost::scoped_ptr<Logger> mLogger;
00350 
00358                 FeeServerMap mServerMap;
00359 
00361                 //std::vector<char* > mServerCol;
00362 
00364                 std::vector<char* > mServiceCol;
00365                 
00366 
00367 };  // end of class
00368 
00369 inline std::vector<FeeItemInfo* >* InterCom::getFeeItemInfoCollection() {
00370         // ev. change pointer to const pointer ???
00371         return &mFeeItemInfoCollection;
00372 }
00373 
00374 inline std::vector<FeeAckInfo* >* InterCom::getFeeAckInfoCollection() {
00375         // ev. change pointer to const pointer ???
00376         return &mFeeAckInfoCollection;
00377 }
00378 
00379 inline std::vector<FeeMsgInfo* >* InterCom::getFeeMsgInfoCollection() {
00380         // ev. change pointer to const pointer ???
00381         return &mFeeMsgInfoCollection;
00382 }
00383 
00384 inline void InterCom::setLogEntry(unsigned int type, char* source, char* description) {
00385     mLogger->createLogMessage(type, source, description);
00386 }
00387 inline FeeServerMap* InterCom::getFeeServerMap(){
00388         return &mServerMap;
00389 }
00390 inline void InterCom::setFeeServerMap(const FeeServerMap map){
00391         mServerMap = map;
00392 }
00393 } } // end of namespace
00394 
00395 
00396 #endif

Generated on Fri Mar 30 02:54:34 2007 for InterComLayer by doxygen 1.3.5