File tree Expand file tree Collapse file tree 4 files changed +21
-14
lines changed Expand file tree Collapse file tree 4 files changed +21
-14
lines changed Original file line number Diff line number Diff line change 19
19
20
20
#include " BLELocalAttribute.h"
21
21
22
+ std::map<BLELocalAttribute*,int > BLELocalAttribute::_refCount;
23
+
22
24
BLELocalAttribute::BLELocalAttribute (const char * uuid) :
23
- _uuid(uuid),
24
- _refCount(0 )
25
+ _uuid(uuid)
25
26
{
26
27
}
27
28
@@ -51,14 +52,15 @@ enum BLEAttributeType BLELocalAttribute::type() const
51
52
52
53
int BLELocalAttribute::retain ()
53
54
{
54
- _refCount++;
55
+ _refCount[ this ] ++;
55
56
56
- return _refCount;
57
+ return _refCount[ this ] ;
57
58
}
58
59
59
60
int BLELocalAttribute::release ()
60
61
{
61
- _refCount--;
62
+ _refCount[this ]--;
63
+ if (_refCount[this ] == 0 ) _refCount.erase (this );
62
64
63
- return _refCount;
65
+ return _refCount[ this ] ;
64
66
}
Original file line number Diff line number Diff line change 22
22
23
23
#include " utility/BLEUuid.h"
24
24
25
+ #include < map>
26
+
25
27
#define BLE_ATTRIBUTE_TYPE_SIZE 2
26
28
27
29
enum BLEAttributeType {
@@ -54,7 +56,7 @@ class BLELocalAttribute
54
56
55
57
private:
56
58
BLEUuid _uuid;
57
- int _refCount;
59
+ static std::map<BLELocalAttribute*, int > _refCount;
58
60
};
59
61
60
62
#endif
Original file line number Diff line number Diff line change 21
21
22
22
#include " BLERemoteAttribute.h"
23
23
24
+ std::map<BLERemoteAttribute*,int > BLERemoteAttribute::_refCount;
25
+
24
26
BLERemoteAttribute::BLERemoteAttribute (const uint8_t uuid[], uint8_t uuidLen) :
25
- _uuid(BLEUuid::uuidToString(uuid, uuidLen)),
26
- _refCount(0 )
27
+ _uuid(BLEUuid::uuidToString(uuid, uuidLen))
27
28
{
28
29
}
29
30
@@ -38,14 +39,15 @@ const char* BLERemoteAttribute::uuid() const
38
39
39
40
int BLERemoteAttribute::retain ()
40
41
{
41
- _refCount++;
42
+ _refCount[ this ] ++;
42
43
43
- return _refCount;
44
+ return _refCount[ this ] ;
44
45
}
45
46
46
47
int BLERemoteAttribute::release ()
47
48
{
48
- _refCount--;
49
+ _refCount[this ]--;
50
+ if (_refCount[this ] == 0 ) _refCount.erase (this );
49
51
50
- return _refCount;
52
+ return _refCount[ this ] ;
51
53
}
Original file line number Diff line number Diff line change 21
21
#define _BLE_REMOTE_ATTRIBUTE_H_
22
22
23
23
#include < Arduino.h>
24
+ #include < map>
24
25
25
26
class BLERemoteAttribute
26
27
{
@@ -35,7 +36,7 @@ class BLERemoteAttribute
35
36
36
37
private:
37
38
String _uuid;
38
- int _refCount;
39
+ static std::map<BLERemoteAttribute*, int > _refCount;
39
40
};
40
41
41
42
#endif
You can’t perform that action at this time.
0 commit comments