41 #include "simgear/structure/SGSharedPtr.hxx"
42 #include "math/FGColumnVector3.h"
137 typedef SGSharedPtr<Element> Element_ptr;
143 class JSBSIM_API
Element :
public SGReferenced {
148 Element(
const std::string& nm);
155 bool HasAttribute(
const std::string& key) {
return attributes.find(key) != attributes.end();}
161 std::string GetAttributeValue(
const std::string& key);
169 bool SetAttributeValue(
const std::string& key,
const std::string& value);
175 double GetAttributeValueAsNumber(
const std::string& key);
179 const std::string&
GetName(
void)
const {
return name;}
180 void ChangeName(
const std::string& _name) { name = _name; }
186 std::string GetDataLine(
unsigned int i=0);
195 unsigned int GetNumElements(
const std::string& element_name);
202 double GetDataAsNumber(
void);
211 Element* GetElement(
unsigned int el=0);
243 Element* FindElement(
const std::string& el=
"");
254 Element* FindNextElement(
const std::string& el=
"");
264 std::string FindElementValue(
const std::string& el=
"");
274 double FindElementValueAsNumber(
const std::string& el=
"");
284 bool FindElementValueAsBoolean(
const std::string& el=
"");
301 double FindElementValueAsNumberConvertTo(
const std::string& el,
const std::string& target_units);
320 double FindElementValueAsNumberConvertFromTo(
const std::string& el,
321 const std::string& supplied_units,
322 const std::string& target_units);
333 FGColumnVector3 FindElementTripletConvertTo(
const std::string& target_units);
335 double DisperseValue(
Element *e,
double val,
const std::string& supplied_units=
"",
336 const std::string& target_units=
"");
350 void AddAttribute(
const std::string& name,
const std::string& value);
354 void AddData(std::string d);
359 void Print(
unsigned int level=0);
376 std::string ReadFrom(
void)
const;
385 void MergeAttributes(
Element* el);
389 std::map <std::string, std::string> attributes;
390 std::vector <std::string> data_lines;
391 std::vector <Element_ptr> children;
393 unsigned int element_index;
394 std::string file_name;
396 typedef std::map <std::string, std::map <std::string, double> > tMapConvert;
397 static tMapConvert convert;
398 static bool converterIsInitialized;
int GetLineNumber(void) const
Returns the line number at which the element has been defined.
void SetFileName(const std::string &name)
Set the name of the file in which the element has been read.
unsigned int GetNumDataLines(void)
Returns the number of lines of data stored.
const std::string & GetFileName(void) const
Returns the name of the file in which the element has been read.
unsigned int GetNumElements(void)
Returns the number of child elements for this element.
Element * GetParent(void)
Returns a pointer to the parent of an element.
void SetLineNumber(int line)
Set the line number at which the element has been read.
bool HasAttribute(const std::string &key)
Determines if an element has the supplied attribute.
void AddChildElement(Element *el)
Adds a child element to the list of children stored for this element.
void SetParent(Element *p)
This function sets the value of the parent class attribute to the supplied Element pointer.
const std::string & GetName(void) const
Retrieves the element name.
This class implements a 3 element column vector.