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);
72 template <
class Object_t>
73 static typename Object_t::Ptr_t
make(
const std::string& _name,
const boost::property_tree::ptree& _pt)
75 typename Object_t::Ptr_t newObject = std::make_shared<Object_t>(_name);
76 newObject->initFromPropertyTree(_pt);
87 const std::string& _schemaFilepath =
"",
88 std::string* _topologyName =
nullptr);
101 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
void initFromXML(const std::string &_filepath, const std::string &_schemaFilepath="", std::string *_topologyName=nullptr)
Initializes object with data from XML file.
Definition: TopoBase.cpp:68
virtual std::string toString() const
Returns string representation of an object.
Definition: TopoBase.cpp:77
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
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:73
void setParent(CTopoBase *_parent)
Definition: TopoBase.cpp:36
std::string getPath() const
Return full path to topo element or property.
Definition: TopoBase.cpp:56
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 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.