|
From: <tho...@us...> - 2011-12-31 18:17:03
|
Revision: 619
http://openautomation.svn.sourceforge.net/openautomation/?rev=619&view=rev
Author: thomas_s
Date: 2011-12-31 18:16:57 +0000 (Sat, 31 Dec 2011)
Log Message:
-----------
improved creation of xPLMessage objects
Modified Paths:
--------------
xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp
xPLHAL/branches/thomas_s_dev/src/xplmessage.cpp
xPLHAL/branches/thomas_s_dev/src/xplmessage.h
Modified: xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp 2011-12-31 14:53:57 UTC (rev 618)
+++ xPLHAL/branches/thomas_s_dev/src/devicemanager.cpp 2011-12-31 18:16:57 UTC (rev 619)
@@ -172,11 +172,10 @@
}
else {
// try to get at least the current config
- xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
source,
"config", "current",
- command_request) );
+ {{"command", "request"}}) );
m_sigSendXplMessage(msg);
}
}
@@ -227,11 +226,10 @@
// ask device for configuration (if haven't asked it before...)
if( !device.ConfigListSent ) {
- xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
source,
"config", "list",
- command_request) );
+ {{"command", "request"}}));
m_sigSendXplMessage(msg);
mDeviceMap[device.VDI].ConfigListSent = true;
}
@@ -302,11 +300,10 @@
mDeviceMap[device.VDI] = device;
// Throw it a config request anyway, see what turns up..
- xPLMessage::namedValueList command_request; command_request.push_back( std::make_pair( "command", "request" ) );
xPLMessagePtr msg( new xPLMessage(xPL_MESSAGE_COMMAND,
source,
"config", "list",
- command_request) );
+ {{"command", "request"}} ));
m_sigSendXplMessage(msg);
/* // that code below was from the VB - but we don't need it as processConfigList will
// itself send the config.current request...
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessage.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessage.cpp 2011-12-31 14:53:57 UTC (rev 618)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessage.cpp 2011-12-31 18:16:57 UTC (rev 619)
@@ -57,11 +57,17 @@
bool xPLMessage::setTargetFromVDI(const std::string& target)
{
- size_t marker1 = target.find( "-" );
- size_t marker2 = target.find( "." );
- targetVendor = target.substr( 0, marker1 );
- targetDevice = target.substr( marker1+1, marker2 - (marker1+1) );
- targetInstance = target.substr( marker2+1 );
+ if (target == "*") {
+ isBroadcastMessage = true;
+ }
+ else {
+ isBroadcastMessage = false;
+ size_t marker1 = target.find( "-" );
+ size_t marker2 = target.find( "." );
+ targetVendor = target.substr( 0, marker1 );
+ targetDevice = target.substr( marker1+1, marker2 - (marker1+1) );
+ targetInstance = target.substr( marker2+1 );
+ }
return true;
}
@@ -110,6 +116,30 @@
return result;
}
+
+bool xPLMessage::operator==(const xPLMessage& right) const
+{
+ if (type != right.type) return false;
+ if (vendor != right.vendor) return false;
+ if (deviceID != right.deviceID) return false;
+ if (instanceID != right.instanceID) return false;
+ if (msgClass != right.msgClass) return false;
+ if (msgType != right.msgType) return false;
+ if (namedValues != right.namedValues) return false;
+ if (isBroadcastMessage != right.isBroadcastMessage) return false;
+ if (isGroupMessage != right.isGroupMessage) return false;
+ if (targetVendor != right.targetVendor) return false;
+ if (targetDevice != right.targetDevice) return false;
+ if (targetInstance != right.targetInstance) return false;
+ if (targetGroup != right.targetGroup) return false;
+ if (hopcount != right.hopcount) return false;
+ return true;
+}
+
+xPLMessage::operator std::string() const
+{
+ return printXPLMessage();
+}
std::ostream& operator<<(std::ostream& os, const xPLMessage& msg)
{
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessage.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessage.h 2011-12-31 14:53:57 UTC (rev 618)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessage.h 2011-12-31 18:16:57 UTC (rev 619)
@@ -59,6 +59,9 @@
std::string targetGroup;
int hopcount;
+
+ xPLMessage() : hopcount(0), isBroadcastMessage(true), isGroupMessage(false)
+ {}
xPLMessage(
const xPL_MessageType _type,
@@ -69,7 +72,8 @@
const std::string& _msgType,
const namedValueList& _namedValues
) : type(_type), vendor(_vendor), deviceID(_deviceID), instanceID(_instanceID),
- msgClass(_msgClass), msgType(_msgType), namedValues(_namedValues)
+ msgClass(_msgClass), msgType(_msgType), namedValues(_namedValues),
+ hopcount(0), isBroadcastMessage(true), isGroupMessage(false)
{
}
@@ -79,7 +83,8 @@
const std::string& _msgClass,
const std::string& _msgType,
const namedValueList& _namedValues
- ) : type(_type), msgClass(_msgClass), msgType(_msgType), namedValues(_namedValues)
+ ) : type(_type), msgClass(_msgClass), msgType(_msgType), namedValues(_namedValues),
+ hopcount(0), isBroadcastMessage(true), isGroupMessage(false)
{
setSourceFromVDI(_vdi);
}
@@ -93,6 +98,9 @@
bool setTargetFromVDI(const std::string& vdi);
std::string getNamedValue(const std::string& tag) const;
+
+ operator std::string() const;
+ bool operator==(const xPLMessage& right) const;
};
typedef boost::shared_ptr<xPLMessage> xPLMessagePtr;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|