bool NFCClassModule::AddClassInclude(const char* pstrClassFilePath, NF_SHARE_PTR<NFIClass> pClass) { if (pClass->Find(pstrClassFilePath)) { return false; } ////////////////////////////////////////////////////////////////////////// std::string strFile = pPluginManager->GetConfigPath() + pstrClassFilePath; std::string strContent; pPluginManager->GetFileContent(strFile, strContent); rapidxml::xml_document<> xDoc; xDoc.parse<0>((char*)strContent.c_str()); ////////////////////////////////////////////////////////////////////////// //support for unlimited layer class inherits rapidxml::xml_node<>* root = xDoc.first_node(); rapidxml::xml_node<>* pRropertyRootNode = root->first_node("Propertys"); if (pRropertyRootNode) { AddPropertys(pRropertyRootNode, pClass); } ////////////////////////////////////////////////////////////////////////// //and record rapidxml::xml_node<>* pRecordRootNode = root->first_node("Records"); if (pRecordRootNode) { AddRecords(pRecordRootNode, pClass); } rapidxml::xml_node<>* pComponentRootNode = root->first_node("Components"); if (pComponentRootNode) { AddComponents(pComponentRootNode, pClass); } //pClass->mvIncludeFile.push_back( pstrClassFilePath ); //and include file rapidxml::xml_node<>* pIncludeRootNode = root->first_node("Includes"); if (pIncludeRootNode) { for (rapidxml::xml_node<>* includeNode = pIncludeRootNode->first_node(); includeNode; includeNode = includeNode->next_sibling()) { const char* pstrIncludeFile = includeNode->first_attribute("Id")->value(); //std::vector<std::string>::iterator it = std::find( pClass->mvIncludeFile.begin(), pClass->mvIncludeFile..end(), pstrIncludeFile ); if (AddClassInclude(pstrIncludeFile, pClass)) { pClass->Add(pstrIncludeFile); } } } return true; }
bool NFCClassModule::AddClass(const char* pstrClassFilePath, NF_SHARE_PTR<NFIClass> pClass) { NF_SHARE_PTR<NFIClass> pParent = pClass->GetParent(); while (pParent) { //inherited some properties form class of parent std::string strFileName = ""; pParent->First(strFileName); while (!strFileName.empty()) { if (pClass->Find(strFileName)) { strFileName.clear(); continue; } if (AddClassInclude(strFileName.c_str(), pClass)) { pClass->Add(strFileName); } strFileName.clear(); pParent->Next(strFileName); } pParent = pParent->GetParent(); } ////////////////////////////////////////////////////////////////////////// if (AddClassInclude(pstrClassFilePath, pClass)) { pClass->Add(pstrClassFilePath); } //file.close(); return true; }
bool NFCEventProcessModule::AddClassCallBack(const std::string& strClassName, const CLASS_EVENT_FUNCTOR_PTR& cb) { NF_SHARE_PTR<NFCClassEventList> pEventList = mxClassEventInfoEx.GetElement(strClassName); if (nullptr == pEventList) { pEventList = NF_SHARE_PTR<NFCClassEventList>(NF_NEW NFCClassEventList()); mxClassEventInfoEx.AddElement(strClassName, pEventList); } assert(NULL != pEventList); pEventList->Add(cb); return true; }
bool NFCEventProcessModule::RemoveEventCallBack(const NFIDENTID& objectID, const int nEventID/*, const EVENT_PROCESS_FUNCTOR_PTR& cb*/) { NF_SHARE_PTR<NFCObjectEventInfo> pObjectEventInfo = mObjectEventInfoMapEx.GetElement(objectID); if (nullptr != pObjectEventInfo) { NF_SHARE_PTR<NFEventList> pEventInfo = pObjectEventInfo->GetElement(nEventID); if (pEventInfo.get()) { NF_SHARE_PTR<NFList<int>> pList = mRemoveEventListEx.GetElement(objectID); if (!pList.get()) { pList = NF_SHARE_PTR<NFList<int>>(NF_NEW NFList<int>()); mRemoveEventListEx.AddElement(objectID, pList); } pList->Add(nEventID); return true; } } return false; }
bool NFCEventProcessModule::AddEventCallBack(const NFIDENTID& objectID, const int nEventID, const EVENT_PROCESS_FUNCTOR_PTR& cb) { NF_SHARE_PTR<NFCObjectEventInfo> pObjectEventInfo = mObjectEventInfoMapEx.GetElement(objectID); if (!pObjectEventInfo.get()) { pObjectEventInfo = NF_SHARE_PTR<NFCObjectEventInfo>(NF_NEW NFCObjectEventInfo()); mObjectEventInfoMapEx.AddElement(objectID, pObjectEventInfo); } assert(nullptr != pObjectEventInfo); NF_SHARE_PTR<NFEventList> pEventInfo = pObjectEventInfo->GetElement(nEventID); if (!pEventInfo) { pEventInfo = NF_SHARE_PTR<NFEventList>(NF_NEW NFEventList()); pObjectEventInfo->AddElement(nEventID, pEventInfo); } assert(nullptr != pEventInfo); pEventInfo->Add(cb); return true; }
bool NFCClassModule::AddClassInclude(const char* pstrClassFilePath, NF_SHARE_PTR<NFIClass> pClass) { if (pClass->Find(pstrClassFilePath)) { return false; } ////////////////////////////////////////////////////////////////////////// rapidxml::xml_document<> xDoc; char* pData = NULL; int nDataSize = 0; std::string strFile = pPluginManager->GetConfigPath() + pstrClassFilePath; rapidxml::file<> fdoc(strFile.c_str()); nDataSize = fdoc.size(); pData = new char[nDataSize + 1]; strncpy(pData, fdoc.data(), nDataSize); pData[nDataSize] = 0; xDoc.parse<0>(pData); ////////////////////////////////////////////////////////////////////////// //support for unlimited layer class inherits rapidxml::xml_node<>* root = xDoc.first_node(); rapidxml::xml_node<>* pRropertyRootNode = root->first_node("Propertys"); if (pRropertyRootNode) { AddPropertys(pRropertyRootNode, pClass); } ////////////////////////////////////////////////////////////////////////// //and record rapidxml::xml_node<>* pRecordRootNode = root->first_node("Records"); if (pRecordRootNode) { AddRecords(pRecordRootNode, pClass); } rapidxml::xml_node<>* pComponentRootNode = root->first_node("Components"); if (pComponentRootNode) { AddComponents(pComponentRootNode, pClass); } //pClass->mvIncludeFile.push_back( pstrClassFilePath ); //and include file rapidxml::xml_node<>* pIncludeRootNode = root->first_node("Includes"); if (pIncludeRootNode) { for (rapidxml::xml_node<>* includeNode = pIncludeRootNode->first_node(); includeNode; includeNode = includeNode->next_sibling()) { const char* pstrIncludeFile = includeNode->first_attribute("Id")->value(); //std::vector<std::string>::iterator it = std::find( pClass->mvIncludeFile.begin(), pClass->mvIncludeFile..end(), pstrIncludeFile ); if (AddClassInclude(pstrIncludeFile, pClass)) { pClass->Add(pstrIncludeFile); } } } ////////////////////////////////////////////////////////////////////////// if (NULL != pData) { delete []pData; } ////////////////////////////////////////////////////////////////////////// return true; }