summaryrefslogtreecommitdiffstats
path: root/include/astra
diff options
context:
space:
mode:
Diffstat (limited to 'include/astra')
-rw-r--r--include/astra/AstraObjectFactory.h2
-rw-r--r--include/astra/Config.h7
-rw-r--r--include/astra/XMLDocument.h2
-rw-r--r--include/astra/XMLNode.h92
4 files changed, 63 insertions, 40 deletions
diff --git a/include/astra/AstraObjectFactory.h b/include/astra/AstraObjectFactory.h
index ba4ec11..1ed4955 100644
--- a/include/astra/AstraObjectFactory.h
+++ b/include/astra/AstraObjectFactory.h
@@ -110,7 +110,7 @@ template <typename T, typename TypeList>
T* CAstraObjectFactory<T, TypeList>::create(const Config& _cfg)
{
functor_find<T> finder = functor_find<T>();
- finder.tofind = _cfg.self->getAttribute("type");
+ finder.tofind = _cfg.self.getAttribute("type");
CreateObject<TypeList>::find(finder);
if (finder.res == NULL) return NULL;
if (finder.res->initialize(_cfg))
diff --git a/include/astra/Config.h b/include/astra/Config.h
index 9893c90..c10a16e 100644
--- a/include/astra/Config.h
+++ b/include/astra/Config.h
@@ -44,13 +44,14 @@ namespace astra {
struct _AstraExport Config {
Config();
- Config(XMLNode* _self);
+ Config(XMLNode _self);
~Config();
void initialize(std::string rootname);
- XMLNode* self;
- XMLNode* global;
+ XMLNode self;
+
+ XMLDocument *_doc;
};
struct ConfigCheckData {
diff --git a/include/astra/XMLDocument.h b/include/astra/XMLDocument.h
index 869e1a3..eddd908 100644
--- a/include/astra/XMLDocument.h
+++ b/include/astra/XMLDocument.h
@@ -78,7 +78,7 @@ public:
*
* @return first XML node of the document
*/
- XMLNode* getRootNode();
+ XMLNode getRootNode();
/** Save an XML DOM tree to an XML file
*
diff --git a/include/astra/XMLNode.h b/include/astra/XMLNode.h
index eceffe1..4d29d5c 100644
--- a/include/astra/XMLNode.h
+++ b/include/astra/XMLNode.h
@@ -64,71 +64,68 @@ public:
/** Deconstructor
*/
~XMLNode();
-
+
+ /** Check validity
+ */
+ operator bool() const { return fDOMElement != 0; }
/** Get a single child XML node. If there are more, the first one is returned
*
* @param _sName tagname of the requested child node
* @return first child node with the correct tagname, null pointer if it doesn't exist
*/
- XMLNode* getSingleNode(string _sName);
+ XMLNode getSingleNode(string _sName) const;
/** Get all child XML nodes that have the tagname name
*
* @param _sName tagname of the requested child nodes
* @return list with all child nodes with the correct tagname
*/
- std::list<XMLNode*> getNodes(string _sName);
+ std::list<XMLNode> getNodes(string _sName) const;
/** Get all child XML nodes
*
* @return list with all child nodes
*/
- std::list<XMLNode*> getNodes();
+ std::list<XMLNode> getNodes() const;
/** Get the name of this node
*
* @return name of node
*/
- std::string getName();
+ std::string getName() const;
/** Get the content of the XML node as a single string.
*
* @return node content
*/
- string getContent();
+ string getContent() const;
/** Get the content of the XML node as a numerical.
*
* @return node content
*/
- float32 getContentNumerical();
+ float32 getContentNumerical() const;
/** Get the content of the XML node as a boolean.
*
* @return node content
*/
- bool getContentBool();
+ bool getContentBool() const;
/** Get the content of the XML node as a vector of strings.
*
* @return node content
*/
- vector<string> getContentArray();
-
- /** Get the content of the XML node as a c-array of float32 data.
- *
- * @param _pfData data array, shouldn't be initialized already.
- * @param _iSize number of elements stored in _pfData
- */
- void getContentNumericalArray(float32*& _pfData, int& _iSize);
+ vector<string> getContentArray() const;
/** Get the content of the XML node as a stl container of float32 data.
+ * NB: A 2D matrix is returned as a linear list
*
* @return node content
*/
- vector<float32> getContentNumericalArray();
- vector<double> getContentNumericalArrayDouble();
+ vector<float32> getContentNumericalArray() const;
+ vector<double> getContentNumericalArrayDouble() const;
@@ -137,7 +134,7 @@ public:
* @param _sName of the attribute.
* @return attribute value, empty string if it doesn't exist.
*/
- bool hasAttribute(string _sName);
+ bool hasAttribute(string _sName) const;
/** Get the value of an attribute.
*
@@ -145,7 +142,7 @@ public:
* @param _sDefaultValue value to return if the attribute isn't found
* @return attribute value, _sDefaultValue if it doesn't exist.
*/
- string getAttribute(string _sName, string _sDefaultValue = "");
+ string getAttribute(string _sName, string _sDefaultValue = "") const;
/** Get the value of a numerical attribute.
*
@@ -153,8 +150,8 @@ public:
* @param _fDefaultValue value to return if the attribute isn't found
* @return attribute value, _fDefaultValue if it doesn't exist.
*/
- float32 getAttributeNumerical(string _sName, float32 _fDefaultValue = 0);
- double getAttributeNumericalDouble(string _sName, double _fDefaultValue = 0);
+ float32 getAttributeNumerical(string _sName, float32 _fDefaultValue = 0) const;
+ double getAttributeNumericalDouble(string _sName, double _fDefaultValue = 0) const;
/** Get the value of a boolean attribute.
*
@@ -162,7 +159,7 @@ public:
* @param _bDefaultValue value to return if the attribute isn't found
* @return attribute value, _bDefaultValue if it doesn't exist.
*/
- bool getAttributeBool(string _sName, bool _bDefaultValue = false);
+ bool getAttributeBool(string _sName, bool _bDefaultValue = false) const;
@@ -172,7 +169,7 @@ public:
* @param _sKey option key
* @return true if option does exist
*/
- bool hasOption(string _sKey);
+ bool hasOption(string _sKey) const;
/** Get the value of an option within this XML Node
*
@@ -180,7 +177,7 @@ public:
* @param _sDefaultValue value to return if key isn't found
* @return option value, _sDefaultValue if the option doesn't exist
*/
- string getOption(string _sKey, string _sDefaultValue = "");
+ string getOption(string _sKey, string _sDefaultValue = "") const;
/** Get the value of an option within this XML Node
*
@@ -188,7 +185,7 @@ public:
* @param _fDefaultValue value to return if key isn't found
* @return option value, _fDefaultValue if the option doesn't exist
*/
- float32 getOptionNumerical(string _sKey, float32 _fDefaultValue = 0);
+ float32 getOptionNumerical(string _sKey, float32 _fDefaultValue = 0) const;
/** Get the value of an option within this XML Node
*
@@ -196,14 +193,14 @@ public:
* @param _bDefaultValue value to return if key isn't found
* @return option value, _bDefaultValue if the option doesn't exist
*/
- bool getOptionBool(string _sKey, bool _bDefaultValue = false);
+ bool getOptionBool(string _sKey, bool _bDefaultValue = false) const;
/** Get the value of an option within this XML Node
*
* @param _sKey option key
* @return numerical array
*/
- vector<float32> getOptionNumericalArray(string _sKey);
+ vector<float32> getOptionNumericalArray(string _sKey) const;
@@ -214,7 +211,7 @@ public:
* @param _sNodeName the name of the new childnode
* @return new child node
*/
- XMLNode* addChildNode(string _sNodeName);
+ XMLNode addChildNode(string _sNodeName);
/** Create a new XML node as a child to this one, also add some content:
* &lt;...&gt;&lt;_sNodeName&gt;_sValue&lt;/_sNodeName>&lt;/...&gt;
@@ -223,7 +220,7 @@ public:
* @param _sValue some node content
* @return new child node
*/
- XMLNode* addChildNode(string _sNodeName, string _sValue);
+ XMLNode addChildNode(string _sNodeName, string _sValue);
/** Create a new XML node as a child to this one, also add some numerical content:
* &lt;...&gt;&lt;_sNodeName&gt;_sValue&lt;/_sNodeName>&lt;/...&gt;
@@ -232,7 +229,7 @@ public:
* @param _fValue some node content
* @return new child node
*/
- XMLNode* addChildNode(string _sNodeName, float32 _fValue);
+ XMLNode addChildNode(string _sNodeName, float32 _fValue);
/** Create a new XML node as a child to this one, also add a list of numerical content:
* &lt;...&gt;&lt;_sNodeName&gt;_sValue&lt;/_sNodeName>&lt;/...&gt;
@@ -242,7 +239,7 @@ public:
* @param _iSize number of elements in _pfList
* @return new child node
*/
- XMLNode* addChildNode(string _sNodeName, float32* _pfList, int _iSize);
+ XMLNode addChildNode(string _sNodeName, float32* _pfList, int _iSize);
/** Add some text to the node: &lt;...&gt;_sText&lt;/...&gt;
*
@@ -256,13 +253,38 @@ public:
*/
void setContent(float32 _fValue);
- /** Add a list of numerical data to the node: &lt;...&gt;_sText&lt;/...&gt;
+ /** Add a list of numerical data to the node
*
* @param _pfList data
* @param _iSize number of elements in the list
*/
void setContent(float32* _pfList, int _iSize);
+ /** Add a list of numerical data to the node
+ *
+ * @param _pfList data
+ * @param _iSize number of elements in the list
+ */
+ void setContent(double* _pfList, int _iSize);
+
+ /** Add a (2D) matrix of numerical data to the node
+ *
+ * @param _pfMatrix data
+ * @param _iWidth width of the matrix
+ * @param _iHeight height of the matrix
+ * @param transposed true is C order, false is Fortran order
+ */
+ void setContent(float32* _pfMatrix, int _iWidth, int _iHeight, bool transposed);
+
+ /** Add a (2D) matrix of numerical data to the node
+ *
+ * @param _pfMatrix data
+ * @param _iWidth width of the matrix
+ * @param _iHeight height of the matrix
+ * @param transposed true is C order, false is Fortran order
+ */
+ void setContent(double* _pfMatrix, int _iWidth, int _iHeight, bool transposed);
+
/** Add an attribute to this node: &lt;... _sName="_sValue"&gt;
*
* @param _sName name of the attribute
@@ -294,11 +316,11 @@ public:
/** Print to String
*/
- std::string toString();
+ std::string toString() const;
/** Print the node
*/
- void print();
+ void print() const;
protected: