client-cpp  0.7.0
EndpointObjectHash.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 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 <botan/sha160.h>
25 
26 #include <cstdint>
27 #include <boost/shared_array.hpp>
28 
29 namespace kaa {
30 
31 typedef std::pair<boost::shared_array<std::uint8_t>, std::uint32_t> SharedDataBuffer;
32 typedef std::vector<std::uint8_t> HashDigest;
33 
38 {
39 public:
41 
42  /*
43  * Specific constructors
44  * Throws \ref KaaException when invalid data was passed (zero-sized or null buffer)
45  */
46  EndpointObjectHash(const std::string& str);
47  EndpointObjectHash(const std::uint8_t* data, const std::uint32_t& dataSize);
48  EndpointObjectHash(const SharedDataBuffer& endpointHash);
49  EndpointObjectHash(const EndpointObjectHash& endpointHash);
50  EndpointObjectHash(EndpointObjectHash&& endpointHash);
51 
52  /*
53  * Copy operator
54  * Throws \ref KaaException when invalid data was passed (zero-sized or null buffer)
55  */
56  EndpointObjectHash& operator=(const EndpointObjectHash& endpointHash);
57 
58  /*
59  * Move operator
60  * Throws \ref KaaException when invalid data was passed (zero-sized or null buffer)
61  */
63 
69 
74  bool operator==(const EndpointObjectHash& endpointHash) { return hashDigest_ == endpointHash.hashDigest_; }
75 
80  bool operator!=(const EndpointObjectHash& endpointHash) { return hashDigest_ != endpointHash.hashDigest_; }
81 
82  operator std::vector<std::uint8_t>();
83 
84 private:
85  void calculateHash(const std::uint8_t* data, std::uint32_t dataSize);
86 
87 private:
88  std::vector<std::uint8_t> hashDigest_;
89 };
90 
91 } /* namespace kaa */
92 
93 #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