Skip to content

Improve ble docs #5392

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

Merged
merged 50 commits into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7254ceb
BLE: Improve ArrayView documentation.
pan- Oct 17, 2017
37c26a2
BLE: Improve BLE.h documentation.
pan- Oct 18, 2017
c49c71c
BLE: Update blecommon documentation.
pan- Oct 19, 2017
fef7bf8
BLE: Update BLEInstanceBase documentation.
pan- Oct 19, 2017
d0b57d7
BLE: Update BLEProtocol documentation
pan- Oct 19, 2017
e0b28ea
BLE: Update BLETypes.h documentation.
pan- Oct 23, 2017
4a21b74
BLE: Improve CallChainOfFunctionPointersWithContext.h documentation.
pan- Oct 23, 2017
b193f9b
BLE: Improce DiscoveredCharacteristic.h documentation.
pan- Oct 23, 2017
9577735
BLE: Improve CharacteristicDescriptorDiscovery.h documentation.
pan- Oct 23, 2017
b163f32
BLE: Improve DiscoveredCharacteristicDescriptor.h documentation.
pan- Oct 23, 2017
d7936e1
BLE: Improve DiscoveredService.h documentation.
pan- Oct 23, 2017
95950ad
BLE: Improve FunctionPointerWithContext.h documentation.
pan- Oct 23, 2017
ae7a5ee
Update GapAdvertisingData.h
pan- Oct 24, 2017
282740a
BLE: Improve GapAdvertisingParams.h documentation.
pan- Oct 24, 2017
4209e88
BLE: Improve GapScanningParams.h documentation.
pan- Oct 24, 2017
76722fe
BLE: Improve SafeBool.h documentation.
pan- Oct 24, 2017
a03192f
BLE: Improve UUID.h documentation.
pan- Oct 24, 2017
e3252da
BLE: Improve ServiceDiscovery.h documentation.
pan- Oct 24, 2017
a7b4d6a
BLE: Improve GattCallbackParamTypes.h documentation.
pan- Oct 24, 2017
7f22d25
BLE: Improve GattServerEvents.h documentation.
pan- Oct 24, 2017
e4a097f
BLE: Imrpove deprecated.h documentation.
pan- Oct 24, 2017
075e1db
BLE: Improve Gap.h documentation.
pan- Oct 27, 2017
1c2685c
BLE: Improve GattClient.h documentation.
pan- Oct 27, 2017
67b47ca
BLE: Group GattServer documented elements
pan- Oct 27, 2017
3c3592a
BLE: Update documentation.
pan- Oct 30, 2017
2038e72
Copy edit ArrayView.h
Oct 30, 2017
96429c5
Copy edit BLE.h
Oct 30, 2017
25ad0f3
Copy edit BLEInstanceBase.h
Oct 30, 2017
3cbe391
BLE: Update BLE.h comments.
pan- Nov 6, 2017
0f91ea2
Copy edit CallChainOfFunctionPointersWithContext.h
Nov 7, 2017
c9931f3
Copy edit CharacteristicDescriptorDiscovery.h
Nov 7, 2017
08ba159
Copy edit DiscoveredCharacteristic.h
Nov 7, 2017
7a4ac93
Copy edit DiscoveredCharacteristicDescriptor.h
Nov 7, 2017
4bf95bc
Copy edit DiscoveredService.h
Nov 7, 2017
bd39a6e
Copy edit FunctionPointerWithContext.h
Nov 7, 2017
69a06a9
Copy edit GattServerEvents.h
Nov 7, 2017
739b59b
Copy edit GattService.h
Nov 7, 2017
6e45541
Copy edit SafeBool.h
Nov 7, 2017
4702ff2
Copy edit GapAdvertisingParams.h
Nov 7, 2017
71bc3f7
Copy edit blecommon.h
Nov 7, 2017
1720a48
Copy edit UUID.h
Nov 7, 2017
fcb50dd
Copy edit ServiceDiscovery.h
Nov 7, 2017
9052cf4
Copy edit GattAttribute.h
Nov 7, 2017
91fa78d
Copy edit GapScanningParams.h
Nov 7, 2017
5178f89
Copy edit GattCallbackParamTypes.h
Nov 7, 2017
6e20887
Copy edit GattServer.h
Nov 7, 2017
3a80f8b
Copy edit Gap.h
Nov 8, 2017
6f7f5ae
Copy edit GattClient.h
Nov 8, 2017
bdf0cbb
Copy edit GapAdvertisingData.h
Nov 8, 2017
3dc28ce
Copy edit GattCharacteristic.h
Nov 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 139 additions & 32 deletions features/FEATURE_BLE/ble/ArrayView.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,72 +20,141 @@
#include <stddef.h>
#include <stdint.h>

/**
* @addtogroup ble
* @{
* @addtogroup common
* @{
*/

/**
* @file
*/

namespace ble {

/**
* Immutable view to an array.
*
* Array views encapsulate the pointer to an array and its size into a single
* object; however, it does not manage the lifetime of the array viewed.
* You can use instances of ArrayView to replace the traditional pair of pointer
* and size arguments in function calls.
*
* You can use the size member function to query the number of elements present
* in the array, and overloads of the subscript operator allow code using
* this object to access to the content of the array viewed.
*
* @note You can create ArrayView instances with the help of the function
* template make_ArrayView() and make_const_ArrayView().
*
* @tparam T type of objects held by the array.
*/
template<typename T>
struct ArrayView {

/**
* construct an array view to an empty array
* Construct a view to an empty array.
*
* @post a call to size() will return 0, and data() will return NULL.
*/
ArrayView() : _array(0), _size(0) { }

/**
* construct an array view from a pointer.
* and its size.
* Construct an array view from a pointer to a buffer and its size.
*
* @param array_ptr Pointer to the array data
* @param array_size Number of elements of T present in the array.
*
* @post a call to size() will return array_size and data() will return
* array_tpr.
*/
ArrayView(T* array_ptr, size_t array_size) :
_array(array_ptr), _size(array_size) { }

/**
* Construct an array view from the reference to an array.
*
* @param elements Reference to the array viewed.
*
* @tparam Size Number of elements of T presents in the array.
*
* @post a call to size() will return Size, and data() will return
* a pointer to elements.
*/
template<size_t Size>
ArrayView(T (&elements)[Size]):
_array(elements), _size(Size) { }

/**
* Return the size of the array viewed.
*
* @return The number of elements present in the array viewed.
*/
size_t size() const {
size_t size() const
{
return _size;
}

/**
* Access to a mutable element of the array.
*
* @param index Element index to access.
*
* @return A reference to the element at the index specified in input.
*
* @pre index shall be less than size().
*/
T& operator[](size_t index) {
T& operator[](size_t index)
{
return _array[index];
}

/**
* Access to an immutable element of the array.
*
* @param index Element index to access.
*
* @return A const reference to the element at the index specified in input.
*
* @pre index shall be less than size().
*/
const T& operator[](size_t index) const {
const T& operator[](size_t index) const
{
return _array[index];
}

/**
* Get the pointer to the array
* Get the raw pointer to the array.
*
* @return The raw pointer to the array.
*/
T* data() {
T* data()
{
return _array;
}

/**
* Get the pointer to the const array
* Get the raw const pointer to the array.
*
* @return The raw pointer to the array.
*/
const T* data() const {
const T* data() const
{
return _array;
}

/**
* Equality operator
* Equality operator.
*
* @param lhs Left hand side of the binary operation.
* @param rhs Right hand side of the binary operation.
*
* @return True if arrays in input have the same size and the same content
* and false otherwise.
*/
friend bool operator==(const ArrayView& lhs, const ArrayView& rhs) {
friend bool operator==(const ArrayView& lhs, const ArrayView& rhs)
{
if (lhs.size() != rhs.size()) {
return false;
}
Expand All @@ -99,8 +168,15 @@ struct ArrayView {

/**
* Not equal operator
*
* @param lhs Left hand side of the binary operation.
* @param rhs Right hand side of the binary operation.
*
* @return True if arrays in input do not have the same size or the same
* content and false otherwise.
*/
friend bool operator!=(const ArrayView& lhs, const ArrayView& rhs) {
friend bool operator!=(const ArrayView& lhs, const ArrayView& rhs)
{
return !(lhs == rhs);
}

Expand All @@ -111,55 +187,86 @@ struct ArrayView {


/**
* Generate an array view from a C/C++ array.
* This helper avoid the typing of template parameter when ArrayView are
* Generate an array view from a reference to a C/C++ array.
*
* @tparam T Type of elements held in elements.
* @tparam Size Number of items held in elements.
*
* @param elements The reference to the array viewed.
*
* @return The ArrayView to elements.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
* @param elements The array viewed.
* @return The array_view to elements.
*/
template<typename T, size_t Size>
ArrayView<T> make_ArrayView(T (&elements)[Size]) {
ArrayView<T> make_ArrayView(T (&elements)[Size])
{
return ArrayView<T>(elements);
}

/**
* Generate an array view from a C/C++ pointer and the size of the array.
* This helper avoid the typing of template parameter when ArrayView are
*
* @tparam T Type of elements held in array_ptr.
*
* @param array_ptr The pointer to the array to viewed.
* @param array_size The number of T elements in the array.
*
* @return The ArrayView to array_ptr with a size of array_size.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
* @param array_ptr The pointer to the array to view.
* @param array_size The size of the array.
* @return The array_view to array_ptr with a size of array_size.
*/
template<typename T>
ArrayView<T> make_ArrayView(T* array_ptr, size_t array_size) {
ArrayView<T> make_ArrayView(T* array_ptr, size_t array_size)
{
return ArrayView<T>(array_ptr, array_size);
}

/**
* Generate a const array view from a C/C++ array.
* This helper avoid the typing of template parameter when ArrayView are
* created 'inline'.
* Generate a const array view from a reference to a C/C++ array.
*
* @tparam T Type of elements held in elements.
* @tparam Size Number of items held in elements.
*
* @param elements The array viewed.
* @return The ArrayView to elements.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
*/
template<typename T, size_t Size>
ArrayView<const T> make_const_ArrayView(T (&elements)[Size]) {
ArrayView<const T> make_const_ArrayView(T (&elements)[Size])
{
return ArrayView<const T>(elements);
}

/**
* Generate a const array view from a C/C++ pointer and the size of the array.
* This helper avoid the typing of template parameter when ArrayView are
* created 'inline'.
* @param array_ptr The pointer to the array to view.
* @param array_size The size of the array.
*
* @tparam T Type of elements held in array_ptr.
*
* @param array_ptr The pointer to the array to viewed.
* @param array_size The number of T elements in the array.
*
* @return The ArrayView to array_ptr with a size of array_size.
*
* @note This helper avoids the typing of template parameter when ArrayView is
* created 'inline'.
*/
template<typename T>
ArrayView<const T> make_const_ArrayView(T* array_ptr, size_t array_size) {
ArrayView<const T> make_const_ArrayView(T* array_ptr, size_t array_size)
{
return ArrayView<const T>(array_ptr, array_size);
}

} // namespace ble

/**
* @}
* @}
*/


#endif /* BLE_ARRAY_VIEW_H_ */
Loading