[499051] Eliminate warnings from compiling and sonar in opcua
cleanup the opcua code
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=499051
Change-Id: Ic364630642a5f82d2225f685d160a841bbb07df3
Signed-off-by: Jose Cabral <cabral@fortiss.org>
diff --git a/src/com/opc_ua/opcua_action_info.cpp b/src/com/opc_ua/opcua_action_info.cpp
index c748484..a039c52 100644
--- a/src/com/opc_ua/opcua_action_info.cpp
+++ b/src/com/opc_ua/opcua_action_info.cpp
@@ -18,7 +18,7 @@
const char *const CActionInfo::mActionNames[] = { "READ", "WRITE", "CREATE_METHOD", "CALL_METHOD", "SUBSCRIBE", "CREATE_OBJECT", "CREATE_VARIABLE",
"DELETE_OBJECT", "DELETE_VARIABLE" };
-CActionInfo::CActionInfo(COPC_UA_Layer &paLayer, UA_ActionType paAction, CIEC_STRING &paEndpoint) :
+CActionInfo::CActionInfo(COPC_UA_Layer &paLayer, UA_ActionType paAction, const CIEC_STRING &paEndpoint) :
mAction(paAction), mLayer(paLayer), mEndpoint(paEndpoint) {
}
diff --git a/src/com/opc_ua/opcua_action_info.h b/src/com/opc_ua/opcua_action_info.h
index de9d077..122d9b7 100644
--- a/src/com/opc_ua/opcua_action_info.h
+++ b/src/com/opc_ua/opcua_action_info.h
@@ -58,7 +58,7 @@
* @param paAction The action to be executed
* @param paEndpoint The endpoint of a remote OPC UA in case the action is to be executed remotely. An empty endpoint means that the action is to be executed locally
*/
- explicit CActionInfo(COPC_UA_Layer &paLayer, UA_ActionType paAction, CIEC_STRING &paEndpoint);
+ explicit CActionInfo(COPC_UA_Layer &paLayer, UA_ActionType paAction, const CIEC_STRING &paEndpoint);
/**
* Destructor of the class
diff --git a/src/com/opc_ua/opcua_client_config_parser.cpp b/src/com/opc_ua/opcua_client_config_parser.cpp
index 843d542..b21a9fc 100644
--- a/src/com/opc_ua/opcua_client_config_parser.cpp
+++ b/src/com/opc_ua/opcua_client_config_parser.cpp
@@ -26,7 +26,7 @@
#endif // UA_ENABLE_ENCRYPTION
};
-bool CUA_ClientConfigFileParser::loadConfig(std::string &paFileLocation, std::string &paEndpoint, UA_ConfigFromFile &paResult) {
+bool CUA_ClientConfigFileParser::loadConfig(const std::string &paFileLocation, const std::string &paEndpoint, UA_ConfigFromFile &paResult) {
bool retVal = true;
UA_StatusCode retValOpcUa = UA_STATUSCODE_GOOD;
@@ -78,10 +78,7 @@
case CConfigFileParser::eEndOfFile:
moreLinesToRead = false;
break;
- case CConfigFileParser::eWrongLine:
- case CConfigFileParser::eFileNotOpened:
- case CConfigFileParser::eInternalError:
- default:
+ default: // eWrongLine, eFileNotOpened, eInternalError
retVal = false;
moreLinesToRead = false;
break;
@@ -129,7 +126,7 @@
}
#ifdef UA_ENABLE_ENCRYPTION
-bool CUA_ClientConfigFileParser::loadFileIntoBytestring(std::string &paFileLocation, UA_ByteString &paResult) {
+bool CUA_ClientConfigFileParser::loadFileIntoBytestring(const std::string &paFileLocation, UA_ByteString &paResult) {
bool retVal = false;
FILE *file = fopen(paFileLocation.c_str(), "rb"); //read binary
diff --git a/src/com/opc_ua/opcua_client_config_parser.h b/src/com/opc_ua/opcua_client_config_parser.h
index f33bfe8..ccca1ee 100644
--- a/src/com/opc_ua/opcua_client_config_parser.h
+++ b/src/com/opc_ua/opcua_client_config_parser.h
@@ -55,7 +55,7 @@
* @param paResult Place to store the results
* @return True if no error occurred, false otherwise
*/
- static bool loadConfig(std::string &paFileLocation, std::string &paEndpoint, UA_ConfigFromFile &paResult);
+ static bool loadConfig(const std::string &paFileLocation, const std::string &paEndpoint, UA_ConfigFromFile &paResult);
private:
explicit CUA_ClientConfigFileParser();
@@ -89,7 +89,7 @@
* @param paResult Place to store the result
* @return True if no error occurred, false otherwise
*/
- static bool loadFileIntoBytestring(std::string &paFileLocation, UA_ByteString &paResult);
+ static bool loadFileIntoBytestring(const std::string &paFileLocation, UA_ByteString &paResult);
#endif //UA_ENABLE_ENCRYPTION
};
diff --git a/src/com/opc_ua/opcua_client_information.cpp b/src/com/opc_ua/opcua_client_information.cpp
index f256e53..bf52a6f 100644
--- a/src/com/opc_ua/opcua_client_information.cpp
+++ b/src/com/opc_ua/opcua_client_information.cpp
@@ -267,7 +267,7 @@
mActionsReferencingIt.erase(&paActionInfo);
}
-bool CUA_ClientInformation::isActionInitialized(CActionInfo& paActionInfo) {
+bool CUA_ClientInformation::isActionInitialized(const CActionInfo &paActionInfo) {
CCriticalRegion clientRegion(mClientMutex);
bool retVal = true;
for(CSinglyLinkedList<CActionInfo *>::Iterator itClientInformation = mActionsToBeInitialized.begin(); itClientInformation != mActionsToBeInitialized.end();
@@ -325,26 +325,24 @@
itNodePair != paActionInfo.getNodePairInfo().end();
++itNodePair, runnerHelper++) {
- if(!somethingFailed) {
- if("" != (*itNodePair)->mBrowsePath) { //if browsepath was given, look for NodeId, even if NodeID was also provided
- UA_NodeId *nodeId;
- UA_StatusCode retVal = COPC_UA_Helper::getRemoteNodeForPath(*mClient, (*itNodePair)->mBrowsePath.getValue(), 0, &nodeId); //we don't care about the parent
+ if(!somethingFailed && "" != (*itNodePair)->mBrowsePath) { //if browsepath was given, look for NodeId, even if NodeID was also provided
+ UA_NodeId *nodeId;
+ UA_StatusCode retVal = COPC_UA_Helper::getRemoteNodeForPath(*mClient, (*itNodePair)->mBrowsePath.getValue(), 0, &nodeId); //we don't care about the parent
- if(UA_STATUSCODE_GOOD != retVal) {
- DEVLOG_ERROR("[OPC UA CLIENT]: The index %u of the FB %s could not be initialized because the requested nodeId was not found. Error: %s\n",
- runnerHelper, paActionInfo.getLayer().getCommFB()->getInstanceName(), UA_StatusCode_name(retVal));
- somethingFailed = true;
- } else {
- if((*itNodePair)->mNodeId) {
- if(!UA_NodeId_equal((*itNodePair)->mNodeId, nodeId)) { //if NodeId was provided, check if found is the same
- DEVLOG_ERROR("[OPC UA CLIENT]: The call from FB %s failed the found nodeId of the method doesn't match the provided one\n",
- paActionInfo.getLayer().getCommFB()->getInstanceName());
- somethingFailed = true;
- }
- UA_NodeId_delete(nodeId);
- } else {
- (*itNodePair)->mNodeId = nodeId;
+ if(UA_STATUSCODE_GOOD != retVal) {
+ DEVLOG_ERROR("[OPC UA CLIENT]: The index %u of the FB %s could not be initialized because the requested nodeId was not found. Error: %s\n",
+ runnerHelper, paActionInfo.getLayer().getCommFB()->getInstanceName(), UA_StatusCode_name(retVal));
+ somethingFailed = true;
+ } else {
+ if((*itNodePair)->mNodeId) {
+ if(!UA_NodeId_equal((*itNodePair)->mNodeId, nodeId)) { //if NodeId was provided, check if found is the same
+ DEVLOG_ERROR("[OPC UA CLIENT]: The call from FB %s failed the found nodeId of the method doesn't match the provided one\n",
+ paActionInfo.getLayer().getCommFB()->getInstanceName());
+ somethingFailed = true;
}
+ UA_NodeId_delete(nodeId);
+ } else {
+ (*itNodePair)->mNodeId = nodeId;
}
}
}
@@ -473,9 +471,9 @@
return false;
}
-bool CUA_ClientInformation::addMonitoringItem(UA_MonitoringItemInfo& paMonitoringInfo, UA_NodeId& paNodeId) {
+bool CUA_ClientInformation::addMonitoringItem(UA_MonitoringItemInfo &paMonitoringInfo, const UA_NodeId &paNodeId) {
- UA_MonitoredItemCreateRequest monRequest = UA_MonitoredItemCreateRequest_default(paNodeId);
+ const UA_MonitoredItemCreateRequest monRequest = UA_MonitoredItemCreateRequest_default(paNodeId);
UA_MonitoredItemCreateResult monResponse = UA_Client_MonitoredItems_createDataChange(mClient, mSubscriptionInfo->mSubscriptionId, UA_TIMESTAMPSTORETURN_BOTH,
monRequest, static_cast<void *>(&paMonitoringInfo.mVariableInfo), CUA_RemoteCallbackFunctions::subscriptionValueChangedCallback, 0);
if(UA_STATUSCODE_GOOD == monResponse.statusCode) {
@@ -507,7 +505,7 @@
}
}
-void CUA_ClientInformation::uninitializeSubscribeAction(CActionInfo& paActionInfo) {
+void CUA_ClientInformation::uninitializeSubscribeAction(const CActionInfo &paActionInfo) {
if(mSubscriptionInfo) {
CSinglyLinkedList<UA_MonitoringItemInfo> toDelete;
for(CSinglyLinkedList<UA_MonitoringItemInfo>::Iterator itMonitoringItemInfo = mSubscriptionInfo->mMonitoredItems.begin();
@@ -638,7 +636,7 @@
void CUA_ClientInformation::CUA_RemoteCallbackFunctions::callMethodAsyncCallback(UA_Client *, void *paUserdata, UA_UInt32,
void *paResponse) {
- UA_CallResponse *response = static_cast<UA_CallResponse*>(paResponse);
+ const UA_CallResponse *response = static_cast<UA_CallResponse*>(paResponse);
bool somethingFailed = false;
diff --git a/src/com/opc_ua/opcua_client_information.h b/src/com/opc_ua/opcua_client_information.h
index 8a9f184..ccbcdc8 100644
--- a/src/com/opc_ua/opcua_client_information.h
+++ b/src/com/opc_ua/opcua_client_information.h
@@ -147,7 +147,7 @@
* @param paActionInfo Action to be checked
* @return True if the action was already initialized, false otherwise
*/
- bool isActionInitialized(CActionInfo& paActionInfo);
+ bool isActionInitialized(const CActionInfo &paActionInfo);
/**
* Class containing all remote callback functions that are called by the OPC UA stack
@@ -316,7 +316,7 @@
* @param paNodeId NodeId of the variable to monitor
* @return True if no error occurred, false otherwise
*/
- bool addMonitoringItem(UA_MonitoringItemInfo& paMonitoringInfo, UA_NodeId& paNodeId);
+ bool addMonitoringItem(UA_MonitoringItemInfo &paMonitoringInfo, const UA_NodeId &paNodeId);
/**
* Increments the amount of missing async calls to be performed. A subscription keeps always the missing calls at least at
@@ -338,7 +338,7 @@
* Uninitialze a subscription action
* @param paActionInfo Action to be uninitialized
*/
- void uninitializeSubscribeAction(CActionInfo& paActionInfo);
+ void uninitializeSubscribeAction(const CActionInfo &paActionInfo);
/**
* Reset the subscription information.
diff --git a/src/com/opc_ua/opcua_helper.cpp b/src/com/opc_ua/opcua_helper.cpp
index 99863c9..e4546c7 100644
--- a/src/com/opc_ua/opcua_helper.cpp
+++ b/src/com/opc_ua/opcua_helper.cpp
@@ -47,13 +47,13 @@
}
template<>
-size_t convertFromIECToOPCUASpecific<CIEC_TIME_OF_DAY, UA_DateTime>(const CIEC_ANY & paSrc, void *paDest) {
+size_t convertFromIECToOPCUASpecific<CIEC_TIME_OF_DAY, UA_DateTime>(const CIEC_ANY&, void*) {
//TODO how convert TOD to UA_DateTime?
return 0;
}
template<>
-size_t convertFromOPCUAToIECSpecific<CIEC_TIME_OF_DAY, UA_DateTime>(const void *paSrc, CIEC_ANY &paDest) {
+size_t convertFromOPCUAToIECSpecific<CIEC_TIME_OF_DAY, UA_DateTime>(const void*, CIEC_ANY&) {
//TODO how convert UA_DateTime to TOD?
return 0;
}
@@ -120,7 +120,6 @@
} else {
return getExternalOPCUATypeFromAny(paAnyType);
}
- return 0;
}
size_t COPC_UA_Helper::convertToOPCUAType(const CIEC_ANY& paSrcAny, void *paDest) {
@@ -327,7 +326,7 @@
return retVal;
}
-int COPC_UA_Helper::getFolderOffset(UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt) {
+int COPC_UA_Helper::getFolderOffset(const UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt) {
int foundFolderOffset = -1;
if(UA_STATUSCODE_GOOD == paBrowsePathsResults[paFolderCnt - 1].statusCode) {
foundFolderOffset = 0;
@@ -337,7 +336,7 @@
return foundFolderOffset;
}
-void COPC_UA_Helper::copyNodeIds(UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt, int paFoundFolderOffset, UA_NodeId **paParentNodeId,
+void COPC_UA_Helper::copyNodeIds(const UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt, int paFoundFolderOffset, UA_NodeId **paParentNodeId,
UA_NodeId **paFoundNodeId) {
*paFoundNodeId = UA_NodeId_new();
UA_NodeId_copy(&paBrowsePathsResults[paFoundFolderOffset + paFolderCnt - 1].targets[0].targetId.nodeId, *paFoundNodeId);
diff --git a/src/com/opc_ua/opcua_helper.h b/src/com/opc_ua/opcua_helper.h
index adb7b6f..70f6b26 100644
--- a/src/com/opc_ua/opcua_helper.h
+++ b/src/com/opc_ua/opcua_helper.h
@@ -221,7 +221,7 @@
* @param folderCnt Number of folders in the paBrowsePathsResults
* @return The offset to first existing folder, -1 if no folder exist
*/
- static int getFolderOffset(UA_BrowsePathResult *paBrowsePathsResults, size_t folderCnt);
+ static int getFolderOffset(const UA_BrowsePathResult *paBrowsePathsResults, size_t folderCnt);
/**
* Copy the found node id and its parent from a browse result
@@ -231,7 +231,7 @@
* @param paParentNodeId Place to store the parent node ID
* @param paFolderCnt Size of the browse result
*/
- static void copyNodeIds(UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt, int paFoundFolderOffset, UA_NodeId **paParentNodeId,
+ static void copyNodeIds(const UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt, int paFoundFolderOffset, UA_NodeId **paParentNodeId,
UA_NodeId **paFoundNodeId);
};
diff --git a/src/com/opc_ua/opcua_local_handler.cpp b/src/com/opc_ua/opcua_local_handler.cpp
index a560a97..a92b764 100644
--- a/src/com/opc_ua/opcua_local_handler.cpp
+++ b/src/com/opc_ua/opcua_local_handler.cpp
@@ -451,11 +451,11 @@
itMain != paActionInfo.getNodePairInfo().end() && UA_STATUSCODE_GOOD == retVal; ++itMain, indexOfNodePair++) {
CSinglyLinkedList<UA_NodeId*> presentNodes;
- bool isNodePresent = false;
- retVal = getNode(**itMain, presentNodes, &isNodePresent);
+ bool nodeExists = false;
+ retVal = getNode(**itMain, presentNodes, &nodeExists);
if(UA_STATUSCODE_GOOD == retVal) {
- if(isNodePresent) {
+ if(nodeExists) {
retVal = handleExistingVariable(paActionInfo, **itMain, variables[indexOfNodePair], indexOfNodePair, paWrite);
handlePresentNodes(presentNodes, referencedNodes, UA_STATUSCODE_GOOD != retVal);
@@ -546,11 +546,9 @@
if(!paWrite) {
retVal = registerVariableCallBack(*variableInformation.mReturnedNodeId, paActionInfo, paIndexOfNodePair);
}
- if(UA_STATUSCODE_GOOD == retVal) {
- if(!paNodePairInfo.mNodeId) {
- paNodePairInfo.mNodeId = UA_NodeId_new();
- UA_NodeId_copy(variableInformation.mReturnedNodeId, paNodePairInfo.mNodeId);
- }
+ if(UA_STATUSCODE_GOOD == retVal && !paNodePairInfo.mNodeId) {
+ paNodePairInfo.mNodeId = UA_NodeId_new();
+ UA_NodeId_copy(variableInformation.mReturnedNodeId, paNodePairInfo.mNodeId);
}
}
}
@@ -558,7 +556,7 @@
return retVal;
}
-UA_StatusCode COPC_UA_Local_Handler::createVariableNode(CCreateVariableInfo &paCreateVariableInfo) {
+UA_StatusCode COPC_UA_Local_Handler::createVariableNode(const CCreateVariableInfo &paCreateVariableInfo) {
UA_NodeId requestedNodeId;
if(paCreateVariableInfo.mRequestedNodeId) {
@@ -670,11 +668,11 @@
CSinglyLinkedList<CActionInfo::CNodePairInfo*>::Iterator itMethodNodePairInfo = paActionInfo.getNodePairInfo().begin();
- bool isNodePresent = false;
- UA_StatusCode retVal = getNode(**itMethodNodePairInfo, presentNodes, &isNodePresent);
+ bool nodeExists = false;
+ UA_StatusCode retVal = getNode(**itMethodNodePairInfo, presentNodes, &nodeExists);
if(UA_STATUSCODE_GOOD == retVal) {
- if(isNodePresent) {
+ if(nodeExists) {
UA_NodeId parent = UA_NODEID_NUMERIC(0, UA_NS0ID_ROOTFOLDER);
@@ -772,7 +770,7 @@
const SFBInterfaceSpec *interfaceFB = paActionInfo.getLayer().getCommFB()->getFBInterfaceSpec();
const CIEC_ANY *dataToSend = paActionInfo.getDataToSend();
- CIEC_ANY *dataToReceive = paActionInfo.getDataToReceive();
+ const CIEC_ANY *dataToReceive = paActionInfo.getDataToReceive();
paCreateMethodInfo.mOutputArguments = static_cast<UA_Argument*>(UA_Array_new(paCreateMethodInfo.mOutputSize, &UA_TYPES[UA_TYPES_ARGUMENT]));
paCreateMethodInfo.mInputArguments = static_cast<UA_Argument*>(UA_Array_new(paCreateMethodInfo.mInputSize, &UA_TYPES[UA_TYPES_ARGUMENT]));
@@ -918,12 +916,12 @@
++itInstance;
CSinglyLinkedList<UA_NodeId*> referencedNodes;
- bool isNodePresent = false;
+ bool nodeExists = false;
//check if an instance is already present
- retVal = getNode(**itInstance, referencedNodes, &isNodePresent);
+ retVal = getNode(**itInstance, referencedNodes, &nodeExists);
if(UA_STATUSCODE_GOOD == retVal) {
- if(!isNodePresent) {
+ if(!nodeExists) {
CIEC_STRING nodeName;
retVal = splitAndCreateFolders((*itInstance)->mBrowsePath, nodeName, referencedNodes);
@@ -968,7 +966,7 @@
return retVal;
}
-UA_StatusCode COPC_UA_Local_Handler::createObjectNode(CCreateObjectInfo &paCreateObjectInfo) {
+UA_StatusCode COPC_UA_Local_Handler::createObjectNode(const CCreateObjectInfo &paCreateObjectInfo) {
UA_StatusCode retVal = UA_STATUSCODE_BADINTERNALERROR;
@@ -1024,12 +1022,12 @@
CSinglyLinkedList<CActionInfo::CNodePairInfo*>::Iterator itInstance = paActionInfo.getNodePairInfo().back();
CSinglyLinkedList<UA_NodeId*> referencedNodes;
- bool isNodePresent = false;
+ bool nodeExists = false;
//check if an instance is already present
- retVal = getNode(**itInstance, referencedNodes, &isNodePresent);
+ retVal = getNode(**itInstance, referencedNodes, &nodeExists);
if(UA_STATUSCODE_GOOD == retVal) {
- if(!isNodePresent) {
+ if(!nodeExists) {
CIEC_STRING nodeName;
retVal = splitAndCreateFolders((*itInstance)->mBrowsePath, nodeName, referencedNodes);
@@ -1038,7 +1036,7 @@
initializeCreateInfo(nodeName, (**itInstance), referencedNodes.isEmpty() ? 0 : *(referencedNodes.back()), createInformation);
createInformation.mVariableTypeNodeId = (*itVariableTypeNodePairInfo)->mNodeId;
- UA_NodeId* dataValueTypeNodeId = (*itDataValueTypeNodePairInfo)->mNodeId;
+ const UA_NodeId *dataValueTypeNodeId = (*itDataValueTypeNodePairInfo)->mNodeId;
createInformation.mTypeConvert = UA_findDataType(dataValueTypeNodeId);
createInformation.mAllowWrite = true;
@@ -1081,35 +1079,32 @@
}
bool COPC_UA_Local_Handler::isNodePresent(CActionInfo::CNodePairInfo &paNodePairInfo) {
- bool isNodePresent = false;
+ bool nodeExists = false;
CSinglyLinkedList<UA_NodeId*> referencedNodes;
- UA_StatusCode retVal = getNode(paNodePairInfo, referencedNodes, &isNodePresent);
+ UA_StatusCode retVal = getNode(paNodePairInfo, referencedNodes, &nodeExists);
if(UA_STATUSCODE_GOOD == retVal) {
- if(isNodePresent) {
- isNodePresent = true;
- }
//we don't need the nodes from the type
for(CSinglyLinkedList<UA_NodeId*>::Iterator itPresentNodes = referencedNodes.begin(); itPresentNodes != referencedNodes.end(); ++itPresentNodes) {
UA_NodeId_delete(*itPresentNodes);
}
referencedNodes.clearAll();
}
- return isNodePresent;
+ return nodeExists;
}
UA_StatusCode COPC_UA_Local_Handler::executeDeleteObject(CActionInfo &paActionInfo) {
- bool isNodePresent = false;
+ bool nodeExists = false;
CSinglyLinkedList<CActionInfo::CNodePairInfo*>::Iterator itInstance = paActionInfo.getNodePairInfo().begin();
CSinglyLinkedList<UA_NodeId*> referencedNodes;
//look for instance
- UA_StatusCode retVal = getNode(**itInstance, referencedNodes, &isNodePresent);
+ UA_StatusCode retVal = getNode(**itInstance, referencedNodes, &nodeExists);
if(UA_STATUSCODE_GOOD == retVal) {
- if(isNodePresent) {
+ if(nodeExists) {
retVal = UA_Server_deleteNode(mUaServer, *(*itInstance)->mNodeId, true);
} else {
DEVLOG_ERROR("[OPC UA LOCAL]: The instance of the object to delete could not be found for FB %s\n",
@@ -1126,7 +1121,7 @@
return retVal;
}
-void COPC_UA_Local_Handler::initializeCreateInfo(CIEC_STRING &paNodeName, CActionInfo::CNodePairInfo &paNodePairInfo, const UA_NodeId *paParentNodeId,
+void COPC_UA_Local_Handler::initializeCreateInfo(CIEC_STRING &paNodeName, const CActionInfo::CNodePairInfo &paNodePairInfo, const UA_NodeId *paParentNodeId,
CCreateInfo &paResult) {
COPC_UA_Helper::getBrowsenameFromNodeName(paNodeName.getValue(), scmDefaultBrowsenameNameSpace, *paResult.mBrowseName); //this cannot fail here anymore, since it was checked already with getNode
paResult.mRequestedNodeId = paNodePairInfo.mNodeId;
@@ -1161,7 +1156,7 @@
if(!*paIsPresent) {
UA_NodeId_delete(*it);
} else {
- paFoundNodeIds.pushBack((*it));
+ paFoundNodeIds.pushBack(*it);
}
}
COPC_UA_Helper::releaseBrowseArgument(*browsePaths, pathCount);
@@ -1206,7 +1201,8 @@
return retVal;
}
-UA_StatusCode COPC_UA_Local_Handler::storeAlreadyExistingNodes(UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt, size_t *paFirstNonExistingNode,
+UA_StatusCode COPC_UA_Local_Handler::storeAlreadyExistingNodes(const UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt,
+ size_t *paFirstNonExistingNode,
CSinglyLinkedList<UA_NodeId*> &paCreatedNodeIds) {
size_t foundFolderOffset = 0;
int retVal; // no unsigned, because we need to check for -1
@@ -1311,7 +1307,7 @@
return retVal;
}
-UA_StatusCode COPC_UA_Local_Handler::splitAndCreateFolders(CIEC_STRING &paBrowsePath, CIEC_STRING &paNodeName,
+UA_StatusCode COPC_UA_Local_Handler::splitAndCreateFolders(const CIEC_STRING &paBrowsePath, CIEC_STRING &paNodeName,
CSinglyLinkedList<UA_NodeId*> &paRreferencedNodes) {
CIEC_STRING folders;
UA_StatusCode retVal = UA_STATUSCODE_BADINTERNALERROR;
@@ -1356,7 +1352,8 @@
return retVal;
}
-void COPC_UA_Local_Handler::handlePresentNodes(CSinglyLinkedList<UA_NodeId*> &paPresentNodes, CSinglyLinkedList<UA_NodeId*> &paReferencedNodes, bool paFailed) {
+void COPC_UA_Local_Handler::handlePresentNodes(const CSinglyLinkedList<UA_NodeId*> &paPresentNodes, CSinglyLinkedList<UA_NodeId*> &paReferencedNodes,
+ bool paFailed) {
for(CSinglyLinkedList<UA_NodeId*>::Iterator itPresendNodes = paPresentNodes.begin(); itPresendNodes != paPresentNodes.end(); ++itPresendNodes) {
if(paFailed) {
UA_NodeId_delete(*itPresendNodes);
@@ -1374,12 +1371,12 @@
return *justPushed;
}
-void COPC_UA_Local_Handler::removeMethodCall(CLocalMethodCall &toRemove) {
+void COPC_UA_Local_Handler::removeMethodCall(const CLocalMethodCall &toRemove) {
CCriticalRegion criticalRegion(mMethodCallsMutex);
mMethodCalls.erase(toRemove);
}
-COPC_UA_Local_Handler::CLocalMethodCall* COPC_UA_Local_Handler::getLocalMethodCall(CLocalMethodInfo &paActionInfo) {
+COPC_UA_Local_Handler::CLocalMethodCall* COPC_UA_Local_Handler::getLocalMethodCall(const CLocalMethodInfo &paActionInfo) {
CCriticalRegion criticalRegion(mMethodCallsMutex);
CLocalMethodCall *retVal = 0;
for(CSinglyLinkedList<CLocalMethodCall>::Iterator it = mMethodCalls.begin(); it != mMethodCalls.end(); ++it) {
diff --git a/src/com/opc_ua/opcua_local_handler.h b/src/com/opc_ua/opcua_local_handler.h
index f0cf78e..bddbb7b 100644
--- a/src/com/opc_ua/opcua_local_handler.h
+++ b/src/com/opc_ua/opcua_local_handler.h
@@ -282,7 +282,8 @@
* @param paParentNodeId Information containing the parent node ID
* @param paResult Place to store the results
*/
- void initializeCreateInfo(CIEC_STRING &paNodeName, CActionInfo::CNodePairInfo &paNodePairInfo, const UA_NodeId *paParentNodeId, CCreateInfo &paResult);
+ void initializeCreateInfo(CIEC_STRING &paNodeName, const CActionInfo::CNodePairInfo &paNodePairInfo, const UA_NodeId *paParentNodeId,
+ CCreateInfo &paResult);
/**
* Context passed to a variable node in the OPC UA stack, which is returned when the variable is written from a client.
@@ -335,7 +336,7 @@
*/
class UA_ParentNodeHandler {
public:
- UA_ParentNodeHandler(UA_NodeId &paParentNodeId, UA_NodeId *paMethodNodeId, CLocalMethodInfo &paActionInfo) :
+ UA_ParentNodeHandler(const UA_NodeId &paParentNodeId, UA_NodeId *paMethodNodeId, CLocalMethodInfo &paActionInfo) :
mParentNodeId(UA_NodeId_new()), mMethodNodeId(paMethodNodeId), mActionInfo(paActionInfo) {
UA_NodeId_copy(&paParentNodeId, mParentNodeId);
}
@@ -401,7 +402,7 @@
* @param paCreateVariableInfo Information needed to create the variable
* @return UA_STATUSCODE_GOOD on success, other value otherwise
*/
- UA_StatusCode createVariableNode(CCreateVariableInfo &paCreateVariableInfo);
+ UA_StatusCode createVariableNode(const CCreateVariableInfo &paCreateVariableInfo);
/**
* Update a variable node value from a IEC61499 data object.
@@ -506,7 +507,7 @@
* @param paCreateObjectInfo Information needed to create the object
* @return UA_STATUSCODE_GOOD on success, other value otherwise
*/
- UA_StatusCode createObjectNode(CCreateObjectInfo &paCreateObjectInfo);
+ UA_StatusCode createObjectNode(const CCreateObjectInfo &paCreateObjectInfo);
/**
* Checks if a node, specified in node pair info, exists in the local server
@@ -552,7 +553,7 @@
* @param paCreatedNodeIds Place to store the existing Node IDs
* @return UA_STATUSCODE_GOOD on success, other value otherwise
*/
- UA_StatusCode storeAlreadyExistingNodes(UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt, size_t *paFirstNonExistingNode,
+ UA_StatusCode storeAlreadyExistingNodes(const UA_BrowsePathResult *paBrowsePathsResults, size_t paFolderCnt, size_t *paFirstNonExistingNode,
CSinglyLinkedList<UA_NodeId*> &paCreatedNodeIds);
/**
@@ -570,7 +571,7 @@
* @param paRreferencedNodes List of nodes that are used by this browsename. It will include all folders, but not the end node since it was not created yet
* @return UA_STATUSCODE_GOOD is no problem occurred, other value otherwise
*/
- UA_StatusCode splitAndCreateFolders(CIEC_STRING &paBrowsePath, CIEC_STRING &paNodeName, CSinglyLinkedList<UA_NodeId*> &paRreferencedNodes);
+ UA_StatusCode splitAndCreateFolders(const CIEC_STRING &paBrowsePath, CIEC_STRING &paNodeName, CSinglyLinkedList<UA_NodeId*> &paRreferencedNodes);
/**
* Split a string into folders and node name. The provided place for store of the folder and node name are only
@@ -589,7 +590,7 @@
* @param paReferencedNodes Place to store the NodeIds if paFailed is true
* @param paFailed True if the NodeIds should be deleted, false if they need to be copied into paReferencedNodes
*/
- void handlePresentNodes(CSinglyLinkedList<UA_NodeId*> &paPresentNodes, CSinglyLinkedList<UA_NodeId*> &paReferencedNodes, bool paFailed);
+ void handlePresentNodes(const CSinglyLinkedList<UA_NodeId*> &paPresentNodes, CSinglyLinkedList<UA_NodeId*> &paReferencedNodes, bool paFailed);
/**
* Maximum time a local method can take to finish execution without producing an error
@@ -641,14 +642,14 @@
* Removes a method call from the list when the method is finished
* @param toDelete Call to remove
*/
- void removeMethodCall(CLocalMethodCall &toRemove);
+ void removeMethodCall(const CLocalMethodCall &toRemove);
/**
* Look for the oldest method call of an action
* @param paActionInfo Action on which the call was triggered
* @return The method call. 0 if an external call for the action was not triggered
*/
- CLocalMethodCall* getLocalMethodCall(CLocalMethodInfo &paActionInfo);
+ CLocalMethodCall* getLocalMethodCall(const CLocalMethodInfo &paActionInfo);
/**
* Default value for the namespace of the browsename for all created nodes
diff --git a/src/com/opc_ua/opcua_remote_handler.cpp b/src/com/opc_ua/opcua_remote_handler.cpp
index 556e07a..eb9c3f1 100644
--- a/src/com/opc_ua/opcua_remote_handler.cpp
+++ b/src/com/opc_ua/opcua_remote_handler.cpp
@@ -43,18 +43,18 @@
void COPC_UA_Client_IterationList::addClient(CUA_ClientInformation& paClientInformation) {
if(paClientInformation.isClientValid()) {
- CCriticalRegion iterationListRegion(mNewClientsMutex);
- addClientToList(paClientInformation, mNewClients);
+ CCriticalRegion iterationListRegion(getNewClientsMutex());
+ addClientToList(paClientInformation, getNewClients());
mNeedsIteration.inc();
mNewClientsPresent = true;
}
}
void COPC_UA_Client_IterationList::removeClient(CUA_ClientInformation& paClientInformation) {
- CCriticalRegion iterationListRegion(mIterationClientsMutex);
- CCriticalRegion newClientsRegion(mNewClientsMutex);
- mNewClients.erase(&paClientInformation); //client could still be in the newList
- mIterationClients.erase(&paClientInformation);
+ CCriticalRegion iterationListRegion(getIterationClientsMutex());
+ CCriticalRegion newClientsRegion(getNewClientsMutex());
+ getNewClients().erase(&paClientInformation); //client could still be in the newList
+ getIterationClients().erase(&paClientInformation);
}
void COPC_UA_Client_IterationList::run() {
@@ -93,13 +93,13 @@
}
void COPC_UA_Client_IterationList::updateClientList() {
- CCriticalRegion iterationListRegion(mIterationClientsMutex);
- CCriticalRegion newClientsRegion(mNewClientsMutex);
- for(CSinglyLinkedList<CUA_ClientInformation *>::Iterator itClientInformation = mNewClients.begin(); itClientInformation != mNewClients.end();
+ CCriticalRegion iterationListRegion(getIterationClientsMutex());
+ CCriticalRegion newClientsRegion(getNewClientsMutex());
+ for(CSinglyLinkedList<CUA_ClientInformation*>::Iterator itClientInformation = getNewClients().begin(); itClientInformation != getNewClients().end();
++itClientInformation) {
- addClientToList(**itClientInformation, mIterationClients);
+ addClientToList(**itClientInformation, getIterationClients());
}
- mNewClients.clearAll();
+ getNewClients().clearAll();
mNewClientsPresent = false;
}
@@ -208,7 +208,7 @@
UA_StatusCode COPC_UA_Remote_Handler::getClientAndAddAction(CActionInfo& paActionInfo) {
UA_StatusCode retVal = UA_STATUSCODE_BADINTERNALERROR;
- CUA_ClientInformation *clientInfo = getClient(paActionInfo.getEndpoint());
+ const CUA_ClientInformation *clientInfo = getClient(paActionInfo.getEndpoint());
if(clientInfo) {
addActionToClient(paActionInfo);
retVal = UA_STATUSCODE_GOOD;
@@ -285,10 +285,11 @@
}
bool COPC_UA_Remote_Handler::handleClients() {
- CCriticalRegion iterationCriticalRegion(mIterationClientsMutex); //this is needed because removing a client from the list could cause trouble
+ CCriticalRegion iterationCriticalRegion(getIterationClientsMutex()); //this is needed because removing a client from the list could cause trouble
CSinglyLinkedList<CUA_ClientInformation *> failedClients;
bool asyncIsNeeded = false;
- for(CSinglyLinkedList<CUA_ClientInformation *>::Iterator itClientInformation = mIterationClients.begin(); itClientInformation != mIterationClients.end();
+ for(CSinglyLinkedList<CUA_ClientInformation*>::Iterator itClientInformation = getIterationClients().begin();
+ itClientInformation != getIterationClients().end();
++itClientInformation) {
CCriticalRegion criticalRegionClienMutex((*itClientInformation)->getMutex());
if((*itClientInformation)->isAsyncNeeded()) {
@@ -309,10 +310,10 @@
DEVLOG_ERROR("[OPC UA REMOTE]: There was a problem checking remote %s.\n", (*itClientInformation)->getEndpoint().getValue());
//we cannot use COPC_UA_Client_IterationList::remove here because it locks mIterationClientsMutex
- CCriticalRegion newClientsRegion(mNewClientsMutex);
+ CCriticalRegion newClientsRegion(getNewClientsMutex());
CCriticalRegion criticalRegionClienMutex((*itClientInformation)->getMutex());
- mIterationClients.erase(*itClientInformation);
- mNewClients.erase(*itClientInformation); //client could still be in the newList
+ getIterationClients().erase(*itClientInformation);
+ getNewClients().erase(*itClientInformation); //client could still be in the newList
(*itClientInformation)->uninitializeClient(); //reset all in client and pass it back to the connection handler
(*itClientInformation)->configureClient();
addClientToConnectionHandler(**itClientInformation);
@@ -331,10 +332,11 @@
}
bool COPC_UA_Remote_Handler::UA_ConnectionHandler::handleClients() {
- CCriticalRegion clientsClientsRegion(mIterationClientsMutex);
+ CCriticalRegion clientsClientsRegion(getIterationClientsMutex());
CSinglyLinkedList<CUA_ClientInformation *> clientsToRemove;
bool needsRetry = false;
- for(CSinglyLinkedList<CUA_ClientInformation *>::Iterator itClientInformation = mIterationClients.begin(); itClientInformation != mIterationClients.end();
+ for(CSinglyLinkedList<CUA_ClientInformation*>::Iterator itClientInformation = getIterationClients().begin();
+ itClientInformation != getIterationClients().end();
++itClientInformation) {
CCriticalRegion clientRegion((*itClientInformation)->getMutex());
if((*itClientInformation)->handleClientState()) {
@@ -353,7 +355,7 @@
if(isAlive() && !clientsToRemove.isEmpty()) {
for(CSinglyLinkedList<CUA_ClientInformation *>::Iterator itClientInformation = clientsToRemove.begin(); itClientInformation != clientsToRemove.end();
++itClientInformation) {
- mIterationClients.erase(*itClientInformation);
+ getIterationClients().erase(*itClientInformation);
}
}
return needsRetry;
diff --git a/src/com/opc_ua/opcua_remote_handler.h b/src/com/opc_ua/opcua_remote_handler.h
index ce7c640..b29df41 100644
--- a/src/com/opc_ua/opcua_remote_handler.h
+++ b/src/com/opc_ua/opcua_remote_handler.h
@@ -78,11 +78,45 @@
*/
void resumeIterationLoop();
+ /**
+ * Access to private member mIterationClients
+ * @return mIterationClients
+ */
+
+ CSinglyLinkedList<CUA_ClientInformation*>& getIterationClients() {
+ return mIterationClients;
+ }
+
+ /**
+ * Access to private member mIterationClientsMutex
+ * @return mIterationClientsMutex
+ */
+ CSyncObject& getIterationClientsMutex() {
+ return mIterationClientsMutex;
+ }
+
+ /**
+ * Access to private member mNewClients
+ * @return mNewClients
+ */
+ CSinglyLinkedList<CUA_ClientInformation*>& getNewClients() {
+ return mNewClients;
+ }
+
+ /**
+ * Access to private member mIterationClients
+ * @return mNewClientsMutex
+ */
+ CSyncObject& getNewClientsMutex() {
+ return mNewClientsMutex;
+ }
+
+ private:
/**
* List of clients on which the iteration is done
*/
- CSinglyLinkedList<CUA_ClientInformation *> mIterationClients;
+ CSinglyLinkedList<CUA_ClientInformation*> mIterationClients;
/**
* Mutex to access the list of clients which is iterated
@@ -92,16 +126,14 @@
/**
* List of new clients. It serves as a buffer that is latter added to the main iteration list
*/
- CSinglyLinkedList<CUA_ClientInformation *> mNewClients;
+ CSinglyLinkedList<CUA_ClientInformation*> mNewClients;
- /**
+ /**
* Mutex to access the list of new clients
*/
CSyncObject mNewClientsMutex;
- private:
-
/**
* Adds a client to a list. If the client is already present, no client is added
* @param paClientInformation Client to be added
diff --git a/src/core/utils/configFileParser.cpp b/src/core/utils/configFileParser.cpp
index cb0045b..6f18537 100644
--- a/src/core/utils/configFileParser.cpp
+++ b/src/core/utils/configFileParser.cpp
@@ -14,7 +14,7 @@
#include "../../arch/devlog.h"
#include "parameterParser.h"
-CConfigFileParser::CConfigFileParser(std::string &paFileLocation) {
+CConfigFileParser::CConfigFileParser(const std::string &paFileLocation) {
mConfigFile = fopen(paFileLocation.c_str(), "r");
if(0 != mConfigFile) {
DEVLOG_INFO("[CConfigFileParser]: Configuration file %s opened\n", paFileLocation.c_str());
diff --git a/src/core/utils/configFileParser.h b/src/core/utils/configFileParser.h
index 1381b04..9440481 100644
--- a/src/core/utils/configFileParser.h
+++ b/src/core/utils/configFileParser.h
@@ -40,7 +40,7 @@
* Constructor
* @param paFileLocation location of the configuration file to be parsed
*/
- explicit CConfigFileParser(std::string &paFileLocation);
+ explicit CConfigFileParser(const std::string &paFileLocation);
/**
* Destructor