6 #ifndef __DDS__TopoBase__ 7 #define __DDS__TopoBase__ 14 #include <boost/property_tree/ptree.hpp> 18 namespace topology_api
36 using Ptr_t = std::shared_ptr<CTopoBase>;
40 void setName(
const std::string& _name);
44 const std::string&
getName()
const;
57 template <
class Object_t>
58 static typename Object_t::Ptr_t
make(
const std::string& _objectName,
59 const std::string& _filepath,
60 const std::string& _schemaFilepath =
"",
61 std::string* _topologyName =
nullptr)
63 typename Object_t::Ptr_t newObject{ std::make_shared<Object_t>(_objectName) };
64 newObject->initFromXML(_filepath, _schemaFilepath, _topologyName);
74 template <
class Object_t>
75 static typename Object_t::Ptr_t
make(
const std::string& _objectName,
76 std::istream& _stream,
77 const std::string& _schemaFilepath =
"",
78 std::string* _topologyName =
nullptr)
80 typename Object_t::Ptr_t newObject{ std::make_shared<Object_t>(_objectName) };
81 newObject->initFromXML(_stream, _schemaFilepath, _topologyName);
89 template <
class Object_t>
90 static typename Object_t::Ptr_t
make(
const std::string& _name,
const boost::property_tree::ptree& _pt)
92 typename Object_t::Ptr_t newObject{ std::make_shared<Object_t>(_name) };
93 newObject->initFromPropertyTree(_pt);
103 const std::string& _schemaFilepath =
"",
104 std::string* _topologyName =
nullptr);
112 const std::string& _schemaFilepath =
"",
113 std::string* _topologyName =
nullptr);
126 virtual std::string
toString()
const;
Definition: TopoBase.h:20
virtual void saveToPropertyTree(boost::property_tree::ptree &_pt)=0
Save object to a property tree.
static Object_t::Ptr_t make(const std::string &_objectName, const std::string &_filepath, const std::string &_schemaFilepath="", std::string *_topologyName=nullptr)
Convenience API to create topology object from XML file.
Definition: TopoBase.h:58
virtual std::string toString() const
Returns string representation of an object.
Definition: TopoBase.cpp:84
std::shared_ptr< CTopoBase > Ptr_t
Definition: TopoBase.h:36
CTopoBase::EType getType() const
Definition: TopoBase.cpp:46
virtual void initFromPropertyTree(const boost::property_tree::ptree &_pt)=0
Initialize object with data from property tree.
virtual ~CTopoBase()
Destructor.
Definition: TopoBase.cpp:22
EType
Definition: TopoBase.h:23
Miscellaneous functions and helpers are located here.
Definition: AgentConnectionManager.h:13
void setType(CTopoBase::EType _type)
Definition: TopoBase.cpp:26
std::vector< CTopoBase::Ptr_t > PtrVector_t
Definition: TopoBase.h:37
static Object_t::Ptr_t make(const std::string &_name, const boost::property_tree::ptree &_pt)
Convenience API to create topology object with data from property tree.
Definition: TopoBase.h:90
void setParent(CTopoBase *_parent)
Definition: TopoBase.cpp:36
std::string getPath() const
Return full path to topo element or property.
Definition: TopoBase.cpp:56
static Object_t::Ptr_t make(const std::string &_objectName, std::istream &_stream, const std::string &_schemaFilepath="", std::string *_topologyName=nullptr)
Convenience API to create topology object from XML file.
Definition: TopoBase.h:75
const std::string & getName() const
Accessors.
Definition: TopoBase.cpp:41
friend std::ostream & operator<<(std::ostream &_strm, const CTopoBase &_element)
Operator << for convenient output to ostream.
void initFromXML(const std::string &_filepath, const std::string &_schemaFilepath="", std::string *_topologyName=nullptr)
Initializes object with data from XML file.
void setName(const std::string &_name)
Modifiers.
Definition: TopoBase.cpp:31
CTopoBase * getParent() const
Definition: TopoBase.cpp:51
CTopoBase(const std::string &_name)
Constructor.
Definition: TopoBase.cpp:17
virtual std::string hashString() const =0
Returns string which is used to calculate CRC checksum of the object.