#include "rgooseNodeFactory.h" #define LOG( X ) m_pLog->Log( "NFAC", this, X ) #define LOG_ERROR( X ) m_pLog->Log( "NFAC", this, _LOG_ERROR, X ) argusNodeFactory * argusNodeFactory::_instance = 0; /** * Returns the single instance of the object. */ argusNodeFactory* argusNodeFactory::getInstance() { // check if the instance has been created yet if (0 == _instance) { // if not, then create it _instance = new argusNodeFactory; } // return the single instance return _instance; }; argusNodeFactory::argusNodeFactory(){ m_pLog = basicLogCollection::getInstance(); m_pDBC = NULL; }; argusNodeFactory::~argusNodeFactory(){ if( m_vNetNodes.size() > 0 ){ for( vectorNetNodes::iterator index = m_vNetNodes.begin(); index < m_vNetNodes.end(); index++ ){ switch( (*index)->type ){ //case ARGUS_ANALOG_STATIC_CAMERA: delete( (chucha*) (*index) ); break; case ARGUS_IP_STATIC_CAMERA: delete( (ARGUS_Camera*) (*index) ); break; }; }; m_vNetNodes.clear(); }; }; void argusNodeFactory::setDBC(ARGUS_DBC * tPtr){ if( (m_pDBC == NULL) && (tPtr != NULL) ) m_pDBC = tPtr; }; bool argusNodeFactory::loadNodes( uint32_t SiteID ){ if(m_pDBC == NULL) return false; m_nSiteID = SiteID; DBC_INT_LIST *tList = NULL; tList = m_pDBC->listNodes( SiteID ); if( tList != NULL ) { for(int index=0; index< tList->size(); index++) { createNode( tList->at(index) ); }; tList->clear(); delete( tList ); return true; }; return false; }; argusNetNode *argusNodeFactory::createNode( int id ){ argusNetNode *tVal = NULL; if( m_pDBC != NULL ){ DBC_NODE_DATA *tData = NULL; tData = m_pDBC->getNodeData( id ); if( tData!= NULL ) { switch( tData->type ) { case ARGUS_ANALOG_STATIC_CAMERA: #ifdef DEBUG LOG("Creating Analog Static Camera"); #endif break; case ARGUS_ANALOG_PTZ_CAMERA: #ifdef DEBUG LOG("Creating Analog PTZ Camera"); #endif break; case ARGUS_IP_STATIC_CAMERA: #ifdef DEBUG LOG("Creating Network Static Camera"); #endif break; case ARGUS_IP_PTZ_CAMERA: #ifdef DEBUG LOG("Creating Network PTZ Camera"); #endif break; case ARGUS_IP_UART_GATEWAY: #ifdef DEBUG LOG("Creating Ethernet to UART Gateway"); #endif break; case ARGUS_IP_VIDEO_SERVER: #ifdef DEBUG LOG("Creating Network Video Encoder"); #endif break; case ARGUS_LFS_SENSOR: #ifdef DEBUG LOG("Creating LFS Sensor"); #endif break; case ARGUS_ALS_SENSOR: #ifdef DEBUG LOG("Creating ALS Sensor"); #endif break; case ARGUS_PLS_200_SENSOR: #ifdef DEBUG LOG("Creating PLS200 Sensor"); #endif break; case ARGUS_PLS_360_SENSOR: #ifdef DEBUG LOG("Creating PLS360 Sensor"); #endif break; case ARGUS_3D_SENSOR: #ifdef DEBUG LOG("Creating 3D Sensor"); #endif break; case ARGUS_JAMER: #ifdef DEBUG LOG("Creating RF Jamer"); #endif break; case ARGUS_NET_PLS_200: #ifdef DEBUG LOG("Creating Network-PLS200 Sensor"); #endif break; case ARGUS_DRONE_CONTROL: #ifdef DEBUG LOG("Creating Drone Controll"); #endif break; }; free(tData); }; }; if( tVal != NULL ) m_vNetNodes.push_back( tVal ); return tVal; }; #undef LOG #undef LOG_ERROR