@digitalshieldfe/react-native-backup-card-sdk 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -25
- package/android/build.gradle +49 -4
- package/android/consumer-rules.pro +0 -0
- package/android/proguard-rules.pro +21 -0
- package/android/src/main/AndroidManifest.xml +4 -1
- package/android/src/main/java/com/ziancube/backupcardsdk/BackupCardSdk.kt +478 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/GPChannelNatives.java +41 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/listener/ApiAsyncListener.java +13 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/ApiNfc.java +173 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/ImplNfc.java +39 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/NfcComm.java +115 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/ApduParam.java +67 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/CommList.java +41 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/Utils.java +109 -0
- package/android/src/main/jni/CMakeLists.txt +60 -0
- package/android/src/main/jni/GPChannel/include/GPChannelSDK.h +306 -0
- package/android/src/main/jni/GPChannel/include/context/BaseContext.h +56 -0
- package/android/src/main/jni/GPChannel/include/device/ApduBuilder.hpp +72 -0
- package/android/src/main/jni/GPChannel/include/utility/Apdu.hpp +166 -0
- package/android/src/main/jni/GPChannel/include/utility/Debug.hpp +59 -0
- package/android/src/main/jni/GPChannel/include/utility/Singleton.h +34 -0
- package/android/src/main/jni/GPChannel/include/utility/mutex.h +24 -0
- package/android/src/main/jni/GPChannel/include/utility/trim.hpp +155 -0
- package/android/src/main/jni/GPChannel/include/utility/util.h +104 -0
- package/android/src/main/jni/GPChannel/include/utility/xFactory.hpp +26 -0
- package/android/src/main/jni/GPChannel/include/utility/xManager.hpp +84 -0
- package/android/src/main/jni/GPChannel/src/arm64-v8a/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/arm64-v8a/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/GPChannel/src/armeabi-v7a/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/armeabi-v7a/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/GPChannel/src/x86/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/x86/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/src/implJni.cpp +313 -0
- package/android/src/main/jni/src/implJni.h +9 -0
- package/android/src/main/jni/utils/jsoncpp/AUTHORS +111 -0
- package/android/src/main/jni/utils/jsoncpp/CMakeLists.txt +159 -0
- package/android/src/main/jni/utils/jsoncpp/LICENSE +55 -0
- package/android/src/main/jni/utils/jsoncpp/README.md +135 -0
- package/android/src/main/jni/utils/jsoncpp/amalgamate.py +155 -0
- package/android/src/main/jni/utils/jsoncpp/appveyor.yml +22 -0
- package/android/src/main/jni/utils/jsoncpp/dev.makefile +35 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/__init__.py +6 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/agent_vmw7.json +33 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/agent_vmxp.json +26 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/antglob.py +205 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/batchbuild.py +278 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/fixeol.py +70 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/licenseupdater.py +94 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/tarball.py +52 -0
- package/android/src/main/jni/utils/jsoncpp/doxybuild.py +189 -0
- package/android/src/main/jni/utils/jsoncpp/include/CMakeLists.txt +2 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/allocator.h +98 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/assertions.h +54 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/autolink.h +25 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/config.h +187 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/features.h +61 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/forwards.h +37 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/json.h +15 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/reader.h +411 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/value.h +888 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/version.h +20 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/writer.h +357 -0
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/jsontest.vcproj +119 -0
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/lib_json.vcproj +205 -0
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/test_lib_json.vcproj +130 -0
- package/android/src/main/jni/utils/jsoncpp/makerelease.py +390 -0
- package/android/src/main/jni/utils/jsoncpp/meson.build +103 -0
- package/android/src/main/jni/utils/jsoncpp/pkg-config/jsoncpp.pc.in +9 -0
- package/android/src/main/jni/utils/jsoncpp/src/CMakeLists.txt +5 -0
- package/android/src/main/jni/utils/jsoncpp/src/jsontestrunner/CMakeLists.txt +25 -0
- package/android/src/main/jni/utils/jsoncpp/src/jsontestrunner/main.cpp +333 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/CMakeLists.txt +117 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_reader.cpp +2060 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_tool.h +114 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_value.cpp +1661 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_valueiterator.inl +167 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_writer.cpp +1233 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/version.h.in +20 -0
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/CMakeLists.txt +38 -0
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/jsontest.cpp +457 -0
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/jsontest.h +286 -0
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/main.cpp +2606 -0
- package/android/src/main/jni/utils/jsoncpp/travis.sh +23 -0
- package/android/src/main/jni/utils/jsoncpp/version +1 -0
- package/android/src/main/jni/utils/jsoncpp/version.in +1 -0
- package/android/src/main/jni/utils/logUtils.cpp +108 -0
- package/android/src/main/jni/utils/logUtils.h +87 -0
- package/android/src/main/jni/utils/mSIGNA/stdutils/uchar_vector.h +614 -0
- package/package.json +2 -3
- package/android/libs/backupcardsdk-1.0.0.aar +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* To change this license header, choose License Headers in Project Properties.
|
|
3
|
+
* To change this template file, choose Tools | Templates
|
|
4
|
+
* and open the template in the editor.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* File: mutex.h
|
|
9
|
+
* Author: zxc_work
|
|
10
|
+
*
|
|
11
|
+
* Created on 2020年2月22日, 下午2:08
|
|
12
|
+
*/
|
|
13
|
+
#pragma once
|
|
14
|
+
|
|
15
|
+
#ifndef MUTEX_H
|
|
16
|
+
#define MUTEX_H
|
|
17
|
+
#include <mutex>
|
|
18
|
+
|
|
19
|
+
extern std::mutex _mutex;
|
|
20
|
+
|
|
21
|
+
#define CREATE_THREAD_LOCK_GUARD std::lock_guard<std::mutex> lck(_mutex);
|
|
22
|
+
|
|
23
|
+
#endif /* MUTEX_H */
|
|
24
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//
|
|
2
|
+
// trim.hpp
|
|
3
|
+
// JubSDK
|
|
4
|
+
//
|
|
5
|
+
// Created by panmin on 2019/9/26.
|
|
6
|
+
// Copyright © 2019 JuBiter. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifndef trim_h
|
|
10
|
+
#define trim_h
|
|
11
|
+
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <vector>
|
|
14
|
+
#include <algorithm>
|
|
15
|
+
#include <sstream>
|
|
16
|
+
#include <iostream>
|
|
17
|
+
#include <functional>
|
|
18
|
+
|
|
19
|
+
namespace jub {
|
|
20
|
+
namespace algorithm {
|
|
21
|
+
|
|
22
|
+
namespace detail {
|
|
23
|
+
// template< typename ForwardIteratorT, typename PredicateT >
|
|
24
|
+
// inline ForwardIteratorT trim_end_iter_select(
|
|
25
|
+
// ForwardIteratorT InBegin,
|
|
26
|
+
// ForwardIteratorT InEnd,
|
|
27
|
+
// PredicateT IsSpace,
|
|
28
|
+
// std::forward_iterator_tag )
|
|
29
|
+
// {
|
|
30
|
+
// ForwardIteratorT TrimIt=InBegin;
|
|
31
|
+
//
|
|
32
|
+
// for( ForwardIteratorT It=InBegin; It!=InEnd; ++It )
|
|
33
|
+
// {
|
|
34
|
+
// if ( !IsSpace(*It) )
|
|
35
|
+
// {
|
|
36
|
+
// TrimIt=It;
|
|
37
|
+
// ++TrimIt;
|
|
38
|
+
// }
|
|
39
|
+
// }
|
|
40
|
+
//
|
|
41
|
+
// return TrimIt;
|
|
42
|
+
// }
|
|
43
|
+
//
|
|
44
|
+
// template< typename ForwardIteratorT, typename PredicateT >
|
|
45
|
+
// inline ForwardIteratorT trim_end_iter_select(
|
|
46
|
+
// ForwardIteratorT InBegin,
|
|
47
|
+
// ForwardIteratorT InEnd,
|
|
48
|
+
// PredicateT IsSpace,
|
|
49
|
+
// std::bidirectional_iterator_tag )
|
|
50
|
+
// {
|
|
51
|
+
// for( ForwardIteratorT It=InEnd; It!=InBegin; )
|
|
52
|
+
// {
|
|
53
|
+
// if ( !IsSpace(*(--It)) )
|
|
54
|
+
// return ++It;
|
|
55
|
+
// }
|
|
56
|
+
//
|
|
57
|
+
// return InBegin;
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
template< typename ForwardIteratorT, typename PredicateT >
|
|
61
|
+
inline ForwardIteratorT eTrim_iter_select(ForwardIteratorT InBegin,
|
|
62
|
+
ForwardIteratorT InEnd,
|
|
63
|
+
PredicateT IsSpace,
|
|
64
|
+
std::forward_iterator_tag ) {
|
|
65
|
+
ForwardIteratorT TrimIt=InBegin;
|
|
66
|
+
|
|
67
|
+
for( ForwardIteratorT It=InBegin; It!=InEnd; ++It )
|
|
68
|
+
{
|
|
69
|
+
if ( !IsSpace(*It) )
|
|
70
|
+
{
|
|
71
|
+
TrimIt=It;
|
|
72
|
+
++TrimIt;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return TrimIt;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// // Search for first non matching character from the beginning of the sequence
|
|
80
|
+
// template< typename ForwardIteratorT, typename PredicateT >
|
|
81
|
+
// inline ForwardIteratorT trim_begin(
|
|
82
|
+
// ForwardIteratorT InBegin,
|
|
83
|
+
// ForwardIteratorT InEnd,
|
|
84
|
+
// PredicateT IsSpace )
|
|
85
|
+
// {
|
|
86
|
+
// ForwardIteratorT It=InBegin;
|
|
87
|
+
// for(; It!=InEnd; ++It )
|
|
88
|
+
// {
|
|
89
|
+
// if (!IsSpace(*It))
|
|
90
|
+
// return It;
|
|
91
|
+
// }
|
|
92
|
+
//
|
|
93
|
+
// return It;
|
|
94
|
+
// }
|
|
95
|
+
template< typename ForwardIteratorT, typename PredicateT >
|
|
96
|
+
inline ForwardIteratorT eTrim(ForwardIteratorT InBegin,
|
|
97
|
+
ForwardIteratorT InEnd,
|
|
98
|
+
PredicateT IsSpace ) {
|
|
99
|
+
typename std::iterator_traits<ForwardIteratorT>::iterator_category category;
|
|
100
|
+
return eTrim_iter_select(InBegin, InEnd, IsSpace, category);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
} // namespace detail end
|
|
104
|
+
|
|
105
|
+
template<typename SequenceT>
|
|
106
|
+
inline SequenceT& lTrim(SequenceT &Input) {
|
|
107
|
+
auto p = find_if(Input.begin(), Input.end(), std::not1(std::function<bool(char)>(isspace)));
|
|
108
|
+
Input.erase(Input.begin(), p);
|
|
109
|
+
return Input;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//template<typename SequenceT, typename PredicateT>
|
|
113
|
+
//inline void trim_right_if(SequenceT& Input, PredicateT IsSpace)
|
|
114
|
+
//{
|
|
115
|
+
// Input.erase(
|
|
116
|
+
// ::boost::algorithm::detail::trim_end(
|
|
117
|
+
// ::boost::begin(Input),
|
|
118
|
+
// ::boost::end(Input),
|
|
119
|
+
// IsSpace ),
|
|
120
|
+
// ::boost::end(Input)
|
|
121
|
+
// );
|
|
122
|
+
//}
|
|
123
|
+
template<typename SequenceT, typename PredicateT>
|
|
124
|
+
inline void rTrim_if(SequenceT& Input, PredicateT IsSpace) {
|
|
125
|
+
Input.erase(detail::eTrim(Input.begin(),
|
|
126
|
+
Input.end(),
|
|
127
|
+
IsSpace),
|
|
128
|
+
Input.end());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//boost::algorithm::trim_right
|
|
132
|
+
//template<typename SequenceT>
|
|
133
|
+
//inline void trim_right(SequenceT& Input, const std::locale& Loc=std::locale())
|
|
134
|
+
//{
|
|
135
|
+
// ::boost::algorithm::trim_right_if(
|
|
136
|
+
// Input,
|
|
137
|
+
// is_space(Loc) );
|
|
138
|
+
//}
|
|
139
|
+
template<typename SequenceT>
|
|
140
|
+
inline SequenceT& rTrim(SequenceT &Input, const std::locale& Loc=std::locale()) {
|
|
141
|
+
|
|
142
|
+
auto p = find_if(Input.rbegin(), Input.rend(), std::not1(std::function<bool(char)>(isspace)));
|
|
143
|
+
Input.erase(p.base(), Input.end());
|
|
144
|
+
return Input;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
template<typename SequenceT>
|
|
148
|
+
inline SequenceT& trim(SequenceT &st) {
|
|
149
|
+
lTrim(rTrim(st));
|
|
150
|
+
return st;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
} // namespace algorithm end
|
|
154
|
+
} // namespace jub end
|
|
155
|
+
#endif /* trim_h */
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#ifndef COINPASS_BIO_UTIL_HPP
|
|
3
|
+
#define COINPASS_BIO_UTIL_HPP
|
|
4
|
+
|
|
5
|
+
#include <assert.h>
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
#include <algorithm>
|
|
10
|
+
#include <sstream>
|
|
11
|
+
#include <iostream>
|
|
12
|
+
#include <cstring>
|
|
13
|
+
#include "mSIGNA/stdutils/uchar_vector.h"
|
|
14
|
+
//#include "Data.h"
|
|
15
|
+
|
|
16
|
+
namespace jub {
|
|
17
|
+
|
|
18
|
+
#define JUB_VERIFY_RET(x, r) \
|
|
19
|
+
do { \
|
|
20
|
+
if (!(x)) { \
|
|
21
|
+
return (r); \
|
|
22
|
+
} \
|
|
23
|
+
} while (0)
|
|
24
|
+
|
|
25
|
+
#define JUB_VERIFY_RV(x) \
|
|
26
|
+
do { \
|
|
27
|
+
JUB_RV r = (x); \
|
|
28
|
+
if (JUBR_OK != r) { \
|
|
29
|
+
return r; \
|
|
30
|
+
} \
|
|
31
|
+
} while (0)
|
|
32
|
+
|
|
33
|
+
#define JUB_CHECK_NULL(x) \
|
|
34
|
+
do { \
|
|
35
|
+
if (!x) { \
|
|
36
|
+
assert(false); \
|
|
37
|
+
return JUBR_MEMORY_NULL_PTR; \
|
|
38
|
+
} \
|
|
39
|
+
} while (0)
|
|
40
|
+
|
|
41
|
+
#define JUB_UNREFERENCED_PARAMETER(P) (P)
|
|
42
|
+
|
|
43
|
+
//template <class _Ty, size_t _Size>
|
|
44
|
+
//constexpr size_t array_size(const _Ty (&)[_Size]) noexcept {
|
|
45
|
+
// return (_Size);
|
|
46
|
+
//}
|
|
47
|
+
//
|
|
48
|
+
/*
|
|
49
|
+
* String splitting function
|
|
50
|
+
*/
|
|
51
|
+
//std::vector<std::string> Split(std::string str, std::string pattern);
|
|
52
|
+
/*
|
|
53
|
+
* Merge string function
|
|
54
|
+
*//*
|
|
55
|
+
std::string Join(std::vector<std::string> v, std::string pattern);
|
|
56
|
+
*/
|
|
57
|
+
/*
|
|
58
|
+
* Decimal string conversion -> Hexadecimal string
|
|
59
|
+
*/
|
|
60
|
+
//std::string DecStringToHexString(std::string str);
|
|
61
|
+
//
|
|
62
|
+
//std::string numberToHexString(unsigned int val);
|
|
63
|
+
//
|
|
64
|
+
/*
|
|
65
|
+
* char array<uint8_t, 32> -> Hexadecimal string conversion
|
|
66
|
+
*//*
|
|
67
|
+
std::string CharArray2HexStr(std::array<uint8_t, 32> v);
|
|
68
|
+
*/
|
|
69
|
+
/*
|
|
70
|
+
* Hexadecimal string conversion -> char array<uint8_t, 32>
|
|
71
|
+
*//*
|
|
72
|
+
std::array<uint8_t, 32> HexStr2CharArray(std::string str);
|
|
73
|
+
*/
|
|
74
|
+
/*
|
|
75
|
+
* std::vector<unsigned char> -> Hexadecimal string conversion
|
|
76
|
+
*/
|
|
77
|
+
//std::string CharPtr2HexStr(std::vector<unsigned char> v);
|
|
78
|
+
//
|
|
79
|
+
/*
|
|
80
|
+
* Hexadecimal string conversion -> std::vector<unsigned char>
|
|
81
|
+
*/
|
|
82
|
+
//std::vector<unsigned char> HexStr2CharPtr(std::string str);
|
|
83
|
+
/*
|
|
84
|
+
// Put an array of strings into a vector
|
|
85
|
+
std::vector<std::string> CharPtrArr2StrVector(const char* Arr[]);
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
//#define ETH_PRDFIX "0x"
|
|
89
|
+
/*
|
|
90
|
+
* std::vector<unsigned char> -> Hexadecimal string conversion
|
|
91
|
+
*//*
|
|
92
|
+
std::string ETHCharPtr2HexStr(std::vector<unsigned char> v);
|
|
93
|
+
*/
|
|
94
|
+
/*
|
|
95
|
+
* Hexadecimal string conversion -> std::vector<unsigned char>
|
|
96
|
+
*/
|
|
97
|
+
//std::vector<unsigned char> ETHHexStr2CharPtr(std::string str);
|
|
98
|
+
//
|
|
99
|
+
//TW::Data ToTlv(uint8_t tag, const TW::Data &data);
|
|
100
|
+
//std::vector<TW::Data> ParseTlv(const TW::Data &data);
|
|
101
|
+
//TW::Data Tollv(const std::string& strData);
|
|
102
|
+
} // namespace jub
|
|
103
|
+
|
|
104
|
+
#endif
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <map>
|
|
3
|
+
|
|
4
|
+
template<typename pI, typename T, typename F>
|
|
5
|
+
class xFactory {
|
|
6
|
+
|
|
7
|
+
protected:
|
|
8
|
+
typedef std::map<T, F> FactoryMap;
|
|
9
|
+
FactoryMap m_FactoryMap;
|
|
10
|
+
|
|
11
|
+
public:
|
|
12
|
+
~xFactory() { m_FactoryMap.clear(); }
|
|
13
|
+
|
|
14
|
+
void Register(const T & name, F pfnCreate) {
|
|
15
|
+
m_FactoryMap[name] = pfnCreate;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
template<typename... Args>
|
|
19
|
+
pI Create(const T &name, Args&&... args) {
|
|
20
|
+
auto it = m_FactoryMap.find(name);
|
|
21
|
+
if (it != m_FactoryMap.end()) {
|
|
22
|
+
return it->second(std::forward<Args>(args)...);
|
|
23
|
+
}
|
|
24
|
+
return nullptr;
|
|
25
|
+
}
|
|
26
|
+
}; // class xFactory end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#ifndef __xManager__
|
|
3
|
+
#define __xManager__
|
|
4
|
+
|
|
5
|
+
#include "JUB_SDK.h"
|
|
6
|
+
|
|
7
|
+
#include <map>
|
|
8
|
+
|
|
9
|
+
template <class T>
|
|
10
|
+
class xManager {
|
|
11
|
+
public:
|
|
12
|
+
xManager() {
|
|
13
|
+
_ID = 0;
|
|
14
|
+
_last = nullptr;
|
|
15
|
+
};
|
|
16
|
+
~xManager() {
|
|
17
|
+
ClearAll();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
JUB_UINT16 AddOne(T* x) {
|
|
21
|
+
//srand((unsigned int)(time(NULL)));
|
|
22
|
+
//JUB_UINT16 ID = rand();
|
|
23
|
+
if (65535 == _ID) {
|
|
24
|
+
_ID = 0;
|
|
25
|
+
}
|
|
26
|
+
//JUB_UINT16 ID = ++_ID;
|
|
27
|
+
|
|
28
|
+
//std::cout << "Add ID:" << ID << std::endl;
|
|
29
|
+
_mapList.insert(std::make_pair(++_ID, x));
|
|
30
|
+
return _ID;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
JUB_UINT16 AddOne(JUB_UINT16 ID, T* x) {
|
|
34
|
+
_mapList.insert(std::make_pair(ID, x));
|
|
35
|
+
|
|
36
|
+
return ID;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
T* GetLast() {
|
|
40
|
+
return _last;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
void ClearLast() { _last = nullptr; };
|
|
44
|
+
|
|
45
|
+
void ClearOne(JUB_UINT16 ID) {
|
|
46
|
+
//std::cout << "Clear ID:" << ID << std::endl;
|
|
47
|
+
auto it = _mapList.find(ID);
|
|
48
|
+
if (it != _mapList.end()) {
|
|
49
|
+
delete it->second;
|
|
50
|
+
_mapList.erase(it);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void ClearAll() {
|
|
55
|
+
for (auto it : _mapList) {
|
|
56
|
+
delete it.second;
|
|
57
|
+
}
|
|
58
|
+
_mapList.clear();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
T* GetOne(JUB_UINT16 ID) {
|
|
62
|
+
auto it = _mapList.find(ID);
|
|
63
|
+
if (it != _mapList.end()) {
|
|
64
|
+
_last = it->second;
|
|
65
|
+
return it->second;
|
|
66
|
+
}
|
|
67
|
+
return nullptr;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
std::vector<JUB_UINT16> GetHandleList() {
|
|
71
|
+
std::vector<JUB_UINT16> vHandleList;
|
|
72
|
+
for (auto it : _mapList) {
|
|
73
|
+
vHandleList.push_back(it.first);
|
|
74
|
+
}
|
|
75
|
+
return vHandleList;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected:
|
|
79
|
+
std::map<JUB_UINT16, T*> _mapList;
|
|
80
|
+
T* _last;
|
|
81
|
+
JUB_UINT16 _ID;
|
|
82
|
+
}; // class xManager end
|
|
83
|
+
|
|
84
|
+
#endif
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|