Improve FunctionPointerWithContext value semantic.

Fix operator== in DiscoveredCharacteristic.
add DiscoveredOperator::operator!=
add a function to set the last handle of a DiscoveredCharacteristic on the
fly
This commit is contained in:
Vincent Coubard 2015-11-17 14:17:38 +00:00
parent 62a1c4a9cc
commit 483cf906db
2 changed files with 24 additions and 4 deletions

View File

@ -154,6 +154,10 @@ public:
return lastHandle;
}
void setLastHandle(GattAttribute::Handle_t last) {
lastHandle = last;
}
GattClient* getGattClient() {
return gattc;
}
@ -167,22 +171,27 @@ public:
}
friend bool operator==(const DiscoveredCharacteristic& rhs, const DiscoveredCharacteristic& lhs) {
return rhs.gattc == rhs.gattc &&
return rhs.gattc == lhs.gattc &&
rhs.uuid == lhs.uuid &&
rhs.props == rhs.props &&
rhs.props == lhs.props &&
rhs.declHandle == lhs.declHandle &&
rhs.valueHandle == lhs.valueHandle &&
rhs.lastHandle == lhs.lastHandle &&
rhs.connHandle == lhs.connHandle;
}
friend bool operator !=(const DiscoveredCharacteristic& rhs, const DiscoveredCharacteristic& lhs) {
return !(rhs == lhs);
}
public:
DiscoveredCharacteristic() : gattc(NULL),
uuid(UUID::ShortUUIDBytes_t(0)),
props(),
declHandle(GattAttribute::INVALID_HANDLE),
valueHandle(GattAttribute::INVALID_HANDLE),
lastHandle(GattAttribute::INVALID_HANDLE) {
lastHandle(GattAttribute::INVALID_HANDLE),
connHandle() {
/* empty */
}

View File

@ -34,7 +34,7 @@ public:
* @param function The void static function to attach (default is none)
*/
FunctionPointerWithContext(void (*function)(ContextType context) = NULL) :
_function(NULL), _caller(NULL), _next(NULL) {
_memberFunctionAndPointer(), _caller(NULL), _next(NULL) {
attach(function);
}
@ -49,6 +49,17 @@ public:
attach(object, member);
}
FunctionPointerWithContext(const FunctionPointerWithContext& that) :
_memberFunctionAndPointer(that._memberFunctionAndPointer), _caller(that._caller), _next(NULL) {
}
FunctionPointerWithContext& operator=(const FunctionPointerWithContext& that) {
_memberFunctionAndPointer = that._memberFunctionAndPointer;
_caller = that._caller;
_next = NULL;
return *this;
}
/** Attach a static function
*
* @param function The void static function to attach (default is none)