client-cpp  0.0.1-SNAPSHOT
CommonRecord.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 COMMON_RECORD_HPP_
18 #define COMMON_RECORD_HPP_
19 
21 
22 #include <avro/Schema.hh>
23 #include <boost/ref.hpp>
24 #include <map>
25 
26 namespace kaa {
27 
28 class CommonRecord : public ICommonRecord {
29 public:
30  CommonRecord(uuid_t uuid, const avro::NodePtr & schema);
31 
32  const boost::any getValue() const { return boost::cref(*this).get(); }
33  const avro::NodePtr & getSchema() const;
34 
35  avro::GenericDatum toAvro() const;
36  std::string toString() const;
37 
38  void setUuid(uuid_t uuid);
39  uuid_t getUuid();
40 
41  bool hasField (const keys_type &field_name) const;
42  fields_type getField (const keys_type &field_name) const;
43  void setField (const keys_type &field_name, fields_type value);
44  void removeField (const keys_type &field_name);
45  const container_type & getFields () const { return fields_; }
46 private:
47  uuid_t uuid_;
48  container_type fields_;
49  avro::NodePtr schema_;
50 };
51 
52 } // namespace kaa
53 
54 #endif /* COMMON_RECORD_HPP_ */
fields_type getField(const keys_type &field_name) const
const avro::NodePtr & getSchema() const
avro::GenericDatum toAvro() const
std::string toString() const
bool hasField(const keys_type &field_name) const
Container::mapped_type fields_type
void removeField(const keys_type &field_name)
boost::uuids::uuid uuid_t
void setUuid(uuid_t uuid)
Container::key_type keys_type
CommonRecord(uuid_t uuid, const avro::NodePtr &schema)
void setField(const keys_type &field_name, fields_type value)
const boost::any getValue() const
const container_type & getFields() const