/** * \file RMF/internal/SharedData.h * \brief Handle read/write of Model data from/to files. * * Copyright 2007-2013 IMP Inventors. All rights reserved. * */ #ifndef RMF_INTERNAL_AVRO_SHARED_DATA_IMPL_H #define RMF_INTERNAL_AVRO_SHARED_DATA_IMPL_H #include "AvroSharedData.h" #include #include #include #include #include #include RMF_ENABLE_WARNINGS namespace RMF { namespace avro_backend { template AvroSharedData::AvroSharedData(std::string g, bool create, bool read_only): Base(g, create, read_only) { if (create) { P::access_node(0).name = "root"; P::access_node(0).type = boost::lexical_cast(ROOT); P::add_node_key(); } } template AvroSharedData::AvroSharedData(std::string &g, bool create): Base(g, create) { if (create) { P::access_node(0).name = "root"; P::access_node(0).type = boost::lexical_cast(ROOT); P::add_node_key(); } } template AvroSharedData::AvroSharedData(const std::string &g): Base(g) { } template std::string AvroSharedData::get_name(unsigned int node) const { return P::get_node(node).name; } template unsigned int AvroSharedData::get_type(unsigned int node) const { std::string string_type = P::get_node(node).type; unsigned int ret_type = boost::lexical_cast(string_type); return ret_type; } template int AvroSharedData::add_child(int node, std::string name, int t) { int index = P::get_nodes_data().size(); P::access_node(index).name = name; P::access_node(index).type = boost::lexical_cast(NodeType(t)); add_child(node, index); P::add_node_key(); RMF_INTERNAL_CHECK(get_type(index) == static_cast(t), internal::get_error_message("Types don't match for node ", name, ": ", NodeType(t), " (", t, ") vs ", NodeType(get_type(index)), " (", get_type(index), ")")); return index; } template void AvroSharedData::add_child(int node, int child_node) { P::access_node(node).children.push_back(child_node); } template Ints AvroSharedData::get_children(int node) const { return Ints(P::get_node(node).children.begin(), P::get_node(node).children.end()); } template std::string AvroSharedData::get_description() const { return P::get_file().description; } template void AvroSharedData::set_description(std::string str) { P::access_file().description = str; } template std::string AvroSharedData::get_producer() const { return P::get_file().producer; } template void AvroSharedData::set_producer(std::string str) { P::access_file().producer = str; } } // namespace avro_backend } /* namespace RMF */ RMF_DISABLE_WARNINGS #endif /* RMF_INTERNAL_AVRO_SHARED_DATA_IMPL_H */