Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove persistant callbacks #109

Merged
merged 15 commits into from
Nov 26, 2015
Merged

Conversation

pan-
Copy link
Member

@pan- pan- commented Nov 23, 2015

This pull request improve CallChainOfFunctionPointersWithContext, FunctionPointerWithContext and provide a way to unregister callbacks previously registered in a callchain.

Changes in FunctionPointerWithContext are not minor, goals were to provide function pointer semantic and value semantic:

  • support of copy constructor and assignement
  • support of equality operator
  • support of function call operator
  • support of safe comparison to bool
  • call does not call the next FunctionPointerWithContext, it is not its responsibility any more. This change can be seen as a breaking one. FunctionPointerWithContext needs to handle less things, is it a list, a node of a list, a call chain ? Unfortunately, mixing responsibilities hurt and I was forced to make this change if I wanted to make callback called only once worked.

CallChainOfFunctionPointersWithContext improvements:

  • support some semantic of function pointer (comparison to bool and operator call).
  • Provide detach operation, this operation remove a function pointer from the callchain, it is also allowed to remove a FunctionPointer while it is called.
  • Handle calls of the callchain, it is not recursive anymore and it support the removal of any nodes while the callchain is traversed.

DiscoveredCharacteristic improvements:

  • read operation support continuation (callback)
  • write operation support continuation (callback)

Gap improvements:

  • multiple timeout event handlers can be attached and detached
  • multiple connection event handlers can be attached and detached
  • multiple disconnection event handlers can be attached and detached

GattClient improvements:

  • multiple read event handlers can be attached and detached
  • multiple write event handlers can be attached and detached
  • multiple HVX event handlers can be attached and detached

GattServer improvements:

  • multiple data sent event handlers can be attached and detached
  • multiple data read event handlers can be attached and detached
  • multiple data written event handlers can be attached and detached
  • EventCallback_t is now a FunctionPointerwithContext instead of a plain function pointer

ServiceDiscovery callbacks are FunctionPointerWithcontext instances instead of plain function pointer

*
* @oaram toDetach FunctionPointerWithContext to detach from this callchain
*
* @return true if a function pointer has been detached and false otherwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to return true if detach was successful. currently the doc-header doesn't match the function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups sorry about this, I will fix it right away

onHVXCallbackChain.add(callback);
}

HVXCallbackChain_t& onHVX() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a documentation header. it might be good to add a code-example showing its use

@rgrover
Copy link
Contributor

rgrover commented Nov 24, 2015

looks good other than the comments made already. This is a useful contribution.

Add SafeBool class which allow to easily declare a safe bool operator in
c++03.

CallChainOfFunctionPointerswithContext:
  - unify syntax of add
  - detach function now return true if a function has been detached and
    false otherwise
  - Explanations about function call operator
  - use safe bool idiom
  - explanations about iterator and why it is mutable

FunctionPointerWithContext:
  - fix call propagation
  - use safe bool idiom

Gap:
  - add documentation
  - onRadioNotification does mot call initRadioNotification anymore

GattClient:
  - documentation

GattServer:
  - documentation
rgrover added a commit that referenced this pull request Nov 26, 2015
@rgrover rgrover merged commit 7de3434 into ARMmbed:develop Nov 26, 2015
@rgrover
Copy link
Contributor

rgrover commented Nov 26, 2015

this is a new feature. this pushes ble to v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants