client-cpp  0.10.0
EndpointObjectHash.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ENDPOINT_OBJECT_HASH_HPP_
18 #define ENDPOINT_OBJECT_HASH_HPP_
19 
20 #include <utility>
21 #include <cstring>
22 #include <vector>
23 
24 #include <cstdint>
25 #include <boost/shared_array.hpp>
26 
27 namespace kaa {
28 
29 typedef std::pair<boost::shared_array<std::uint8_t>, std::uint32_t> SharedDataBuffer;
30 typedef std::vector<std::uint8_t> HashDigest;
31 
36 {
37 public:
39 
40  /*
41  * Specific constructors
42  * Throws \ref KaaException when invalid data was passed (zero-sized or null buffer)
43  */
44  EndpointObjectHash(const std::string& str);
45  EndpointObjectHash(const std::uint8_t* data, const std::uint32_t& dataSize);
46  EndpointObjectHash(const SharedDataBuffer& endpointHash);
47  EndpointObjectHash(const EndpointObjectHash& endpointHash);
48  EndpointObjectHash(EndpointObjectHash&& endpointHash);
49 
50  /*
51  * Copy operator
52  * Throws \ref KaaException when invalid data was passed (zero-sized or null buffer)
53  */
54  EndpointObjectHash& operator=(const EndpointObjectHash& endpointHash);
55 
56  /*
57  * Move operator
58  * Throws \ref KaaException when invalid data was passed (zero-sized or null buffer)
59  */
61 
67 
72  bool operator==(const EndpointObjectHash& endpointHash) { return hashDigest_ == endpointHash.hashDigest_; }
73 
78  bool operator!=(const EndpointObjectHash& endpointHash) { return hashDigest_ != endpointHash.hashDigest_; }
79 
80  operator std::vector<std::uint8_t>();
81 
82 private:
83  void calculateHash(const std::uint8_t* data, std::uint32_t dataSize);
84 
85 private:
86  std::vector<std::uint8_t> hashDigest_;
87 };
88 
89 } /* namespace kaa */
90 
91 #endif /* ENDPOINT_OBJECT_HASH_HPP_ */
EndpointObjectHash & operator=(const EndpointObjectHash &endpointHash)
bool operator==(const EndpointObjectHash &endpointHash)
HashDigest getHashDigest()
bool operator!=(const EndpointObjectHash &endpointHash)
std::vector< std::uint8_t > HashDigest
std::pair< boost::shared_array< std::uint8_t >, std::uint32_t > SharedDataBuffer