client-cpp  0.7.4
LogRecord.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 LOGRECORD_HPP_
18 #define LOGRECORD_HPP_
19 
20 #include <memory>
21 #include <cstdint>
22 
23 #include "kaa/KaaThread.hpp"
24 #include "kaa/gen/EndpointGen.hpp"
28 
29 namespace kaa {
30 
31 class LogRecord {
32 public:
33  LogRecord(const KaaUserLogRecord& record)
34  {
35  AvroByteArrayConverter<KaaUserLogRecord> converter; // TODO: make converter thread local when it would be possible
36  converter.toByteArray(record, serializedLog_.data);
37  }
38 
39  LogRecord(const std::uint8_t *data, size_t size)
40  {
41  if (!data || !size) {
42  throw KaaException("Null serialized log data");
43  }
44  serializedLog_.data.assign(data, data + size);
45  }
46 
47  const std::vector<std::uint8_t>& getData() const { return serializedLog_.data; }
48  size_t getSize() const { return serializedLog_.data.size(); }
49 
50  const LogEntry& getLogEntry() { return serializedLog_; }
51 
52 private:
53  LogEntry serializedLog_;
54 };
55 
56 typedef std::shared_ptr<LogRecord> LogRecordPtr;
57 
58 } // namespace kaa
59 
60 #endif /* LOGRECORD_HPP_ */
const std::vector< std::uint8_t > & getData() const
Definition: LogRecord.hpp:47
size_t getSize() const
Definition: LogRecord.hpp:48
const LogEntry & getLogEntry()
Definition: LogRecord.hpp:50
SharedDataBuffer toByteArray(const T &datum)
LogRecord(const std::uint8_t *data, size_t size)
Definition: LogRecord.hpp:39
NOTE: THIS FILE IS AUTO-GENERATED. DO NOT EDIT IT MANUALLY.
std::shared_ptr< LogRecord > LogRecordPtr
Definition: ILogStorage.hpp:36
LogRecord(const KaaUserLogRecord &record)
Definition: LogRecord.hpp:33