renamed isSet to isWrite

This commit is contained in:
john30
2014-12-31 07:42:41 +01:00
parent 91c4aa15dd
commit be8ae316ed
5 changed files with 35 additions and 35 deletions
+1 -1
View File
@@ -544,7 +544,7 @@ result_t BusHandler::handleSymbol()
m_nextSendPos = 0;
m_repeat = false;
Message* message = m_messages->find(m_command);
if (message == NULL || message->isPassive() == false || message->isSet() == true)
if (message == NULL || message->isPassive() == false || message->isWrite() == true)
return setState(bs_skip, RESULT_ERR_INVALID_ARG); // don't know this request or definition has wrong direction, deny
// build response and store in m_response for sending back to requesting master
+3 -3
View File
@@ -143,7 +143,7 @@ void printErrorPos(vector<string>::iterator begin, const vector<string>::iterato
result_t DataField::create(vector<string>::iterator& it,
const vector<string>::iterator end,
DataFieldTemplates* templates,
DataField*& returnField, const bool isSetMessage,
DataField*& returnField, const bool isWriteMessage,
const unsigned char dstAddress)
{
vector<SingleDataField*> fields;
@@ -175,11 +175,11 @@ result_t DataField::create(vector<string>::iterator& it,
hasPartStr = partStr[0] != 0;
if (dstAddress == BROADCAST || isMaster(dstAddress) == true
|| (isSetMessage == true && hasPartStr == false)
|| (isWriteMessage == true && hasPartStr == false)
|| strcasecmp(partStr, "M") == 0) { // master data
partType = pt_masterData;
}
else if ((isSetMessage == false && hasPartStr == false)
else if ((isWriteMessage == false && hasPartStr == false)
|| strcasecmp(partStr, "S") == 0) { // slave data
partType = pt_slaveData;
}
+3 -3
View File
@@ -139,14 +139,14 @@ public:
* @param end the iterator pointing to the end of the definition parts.
* @param templates the @a DataFieldTemplates to be referenced by name, or NULL.
* @param returnField the variable in which to store the created instance.
* @param isSetMessage whether the field is part of a set message (default false).
* @param isWriteMessage whether the field is part of a write message (default false).
* @param dstAddress the destination bus address (default @a SYN for creating a template @a DataField).
* @return @a RESULT_OK on success, or an error code.
* Note: the caller needs to free the created instance.
*/
static result_t create(vector<string>::iterator& it, const vector<string>::iterator end,
DataFieldTemplates* templates, DataField*& returnField,
const bool isSetMessage=false, const unsigned char dstAddress=SYN);
const bool isWriteMessage=false, const unsigned char dstAddress=SYN);
/**
* @brief Returns the length of this field (or contained fields) in bytes.
@@ -235,7 +235,7 @@ protected:
/**
* @brief A single DataField.
* @brief A single @a DataField holding a value.
*/
class SingleDataField : public DataField
{
+17 -17
View File
@@ -32,12 +32,12 @@ using namespace std;
/** the bit mask of the source master number in the message key. */
#define ID_SOURCE_MASK (0x1fLL << (8 * 7))
Message::Message(const string clazz, const string name, const bool isSet,
Message::Message(const string clazz, const string name, const bool isWrite,
const bool isPassive, const string comment,
const unsigned char srcAddress, const unsigned char dstAddress,
const vector<unsigned char> id, DataField* data,
const unsigned int pollPriority)
: m_class(clazz), m_name(name), m_isSet(isSet),
: m_class(clazz), m_name(name), m_isWrite(isWrite),
m_isPassive(isPassive), m_comment(comment),
m_srcAddress(srcAddress), m_dstAddress(dstAddress),
m_id(id), m_data(data), m_pollPriority(pollPriority),
@@ -55,10 +55,10 @@ Message::Message(const string clazz, const string name, const bool isSet,
m_key = key;
}
Message::Message(const bool isSet, const bool isPassive,
Message::Message(const bool isWrite, const bool isPassive,
const unsigned char pb, const unsigned char sb,
DataField* data)
: m_class(), m_name(), m_isSet(isSet),
: m_class(), m_name(), m_isWrite(isWrite),
m_isPassive(isPassive), m_comment(),
m_srcAddress(SYN), m_dstAddress(SYN),
m_data(data), m_pollPriority(0),
@@ -91,7 +91,7 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
{
// [type],[class],name,[comment],[QQ],[ZZ],id,fields...
result_t result;
bool isSet = false, isPassive = false;
bool isWrite = false, isPassive = false;
string defaultName;
unsigned int pollPriority = 0;
size_t defaultPos = 1;
@@ -114,12 +114,12 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
defaultName = str;
}
else if (strncasecmp(str, "W", 1) == 0) { // active set
isSet = true;
isWrite = true;
defaultName = str;
}
else { // any other: passive set/get
isPassive = true;
isSet = strcasecmp(str+len-1, "W") == 0; // if type ends with "w" it is treated as passive set
isWrite = strcasecmp(str+len-1, "W") == 0; // if type ends with "w" it is treated as passive set
defaultName = str;
}
@@ -239,11 +239,11 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
}
}
DataField* data = NULL;
result = DataField::create(it, realEnd, templates, data, isSet, dstAddress==SYN ? ESC : dstAddress);
result = DataField::create(it, realEnd, templates, data, isWrite, dstAddress==SYN ? ESC : dstAddress);
if (result != RESULT_OK) {
return result;
}
returnValue = new Message(clazz, name, isSet, isPassive, comment, srcAddress, dstAddress, id, data, pollPriority);
returnValue = new Message(clazz, name, isWrite, isPassive, comment, srcAddress, dstAddress, id, data, pollPriority);
return RESULT_OK;
}
@@ -289,7 +289,7 @@ result_t Message::prepareMaster(const unsigned char srcAddress, SymbolString& ma
result_t Message::prepareSlave(SymbolString& slaveData)
{
if (m_isPassive == false || m_isSet == true)
if (m_isPassive == false || m_isWrite == true)
return RESULT_ERR_INVALID_ARG; // prepare not possible
SymbolString slave;
@@ -366,10 +366,10 @@ result_t MessageMap::add(Message* message)
return RESULT_ERR_DUPLICATE; // duplicate key
}
bool isPassive = message->isPassive();
bool isSet = message->isSet();
bool isWrite = message->isWrite();
string clazz = strtolower(message->getClass());
string name = strtolower(message->getName());
string nameKey = string(isPassive ? "P" : (isSet ? "W" : "R")) + clazz + FIELD_SEPARATOR + name;
string nameKey = string(isPassive ? "P" : (isWrite ? "W" : "R")) + clazz + FIELD_SEPARATOR + name;
map<string, Message*>::iterator nameIt = m_messagesByName.find(nameKey);
if (nameIt != m_messagesByName.end()) {
return RESULT_ERR_DUPLICATE; // duplicate key
@@ -380,7 +380,7 @@ result_t MessageMap::add(Message* message)
if (isPassive == true)
m_passiveMessageCount++;
nameKey = string(isPassive ? "-P" : (isSet ? "-W" : "-R")) + name; // also store without class
nameKey = string(isPassive ? "-P" : (isWrite ? "-W" : "-R")) + name; // also store without class
nameIt = m_messagesByName.find(nameKey);
if (nameIt == m_messagesByName.end()) {
m_messagesByName[nameKey] = message; // only store first key without class
@@ -428,16 +428,16 @@ result_t MessageMap::addFromFile(vector<string>::iterator& begin, const vector<s
return result;
}
Message* MessageMap::find(const string& clazz, const string& name, const bool isSet, const bool isPassive)
Message* MessageMap::find(const string& clazz, const string& name, const bool isWrite, const bool isPassive)
{
string lclass = strtolower(clazz);
string lname = strtolower(name);
for (int i=0; i<2; i++) {
string key;
if (i == 0)
key = string(isPassive ? "P" : (isSet ? "W" : "R")) + lclass + FIELD_SEPARATOR + lname;
key = string(isPassive ? "P" : (isWrite ? "W" : "R")) + lclass + FIELD_SEPARATOR + lname;
else if (clazz.length() == 0)
key = string(isPassive ? "-P" : (isSet ? "-W" : "-R")) + lname; // second try: without class
key = string(isPassive ? "-P" : (isWrite ? "-W" : "-R")) + lname; // second try: without class
else
continue; // not allowed without class
map<string, Message*>::iterator it = m_messagesByName.find(key);
@@ -478,7 +478,7 @@ deque<Message*> MessageMap::findAll(const string& clazz, const string& name, con
if (withPassive == false)
continue;
}
else if (message->isSet() == true) {
else if (message->isWrite() == true) {
if (withWrite == false)
continue;
}
+11 -11
View File
@@ -46,7 +46,7 @@ public:
* @brief Construct a new instance.
* @param clazz the optional device class.
* @param name the message name (unique within the same class and type).
* @param isSet whether this is a set message.
* @param isWrite whether this is a write message.
* @param isPassive true if message can only be initiated by a participant other than us,
* false if message can be initiated by any participant.
* @param comment the comment.
@@ -56,7 +56,7 @@ public:
* @param data the @a DataField for encoding/decoding the message.
* @param pollPriority the priority for polling, or 0 for no polling at all.
*/
Message(const string clazz, const string name, const bool isSet,
Message(const string clazz, const string name, const bool isWrite,
const bool isPassive, const string comment,
const unsigned char srcAddress, const unsigned char dstAddress,
const vector<unsigned char> id, DataField* data,
@@ -64,14 +64,14 @@ public:
/**
* @brief Construct a new temporary instance.
* @param isSet whether this is a set message.
* @param isWrite whether this is a write message.
* @param isPassive true if message can only be initiated by a participant other than us,
* false if message can be initiated by any participant.
* @param pb the primary ID byte.
* @param sb the secondary ID byte.
* @param data the @a DataField for encoding/decoding the message.
*/
Message(const bool isSet, const bool isPassive,
Message(const bool isWrite, const bool isPassive,
const unsigned char pb, const unsigned char sb,
DataField* data);
@@ -107,10 +107,10 @@ public:
string getName() const { return m_name; }
/**
* @brief Get whether this is a set message.
* @return whether this is a set message.
* @brief Get whether this is a write message.
* @return whether this is a write message.
*/
bool isSet() const { return m_isSet; }
bool isWrite() const { return m_isWrite; }
/**
* @brief Get whether message can be initiated only by a participant other than us.
@@ -225,8 +225,8 @@ private:
/** the message name (unique within the same class and type). */
const string m_name;
/** whether this is a set message. */
const bool m_isSet;
/** whether this is a write message. */
const bool m_isWrite;
/** true if message can only be initiated by a participant other than us,
* false if message can be initiated by any participant. */
@@ -315,12 +315,12 @@ public:
* @brief Find the @a Message instance for the specified class and name.
* @param clazz the optional device class.
* @param name the message name.
* @param isSet whether this is a set message.
* @param isWrite whether this is a write message.
* @param isPassive whether this is a passive message.
* @return the @a Message instance, or NULL.
* Note: the caller may not free the returned instance.
*/
Message* find(const string& clazz, const string& name, const bool isSet, const bool isPassive=false);
Message* find(const string& clazz, const string& name, const bool isWrite, const bool isPassive=false);
/**
* @brief Find all active get @a Message instances for the specified class and name.