Commit c673ff13 authored by Holcomb, Andrew's avatar Holcomb, Andrew
Browse files

Add generated classes

parent c6b9aa9a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
SET(LIB_REQUIRED_DEP_PACKAGES ScaleExternalPugixml)
SET(LIB_OPTIONAL_DEP_PACKAGES)
SET(TEST_REQUIRED_DEP_PACKAGES)
SET(TEST_OPTIONAL_DEP_PACKAGES)
SET(LIB_REQUIRED_DEP_TPLS)
SET(LIB_OPTIONAL_DEP_TPLS)
SET(TEST_REQUIRED_DEP_TPLS)
SET(TEST_OPTIONAL_DEP_TPLS)
+196 −0
Original line number Diff line number Diff line
#include "abstract_functional_Node.h"
#include <sstream>

namespace endfgnd
{
namespace abstract
{
functionalNode::functionalNode()
    : GNDElement("functional")
{
    Float64 _default_value = getDefaultValue<Float64>();
    _value                 = _default_value;
}

functionalNode::functionalNode(const functionalNode& orig)
    : GNDElement(orig)
{
    _value = orig._value;

    _axes = NULL;
    if (orig._axes != NULL)
    {
        _axes = std::make_shared<gpdc::axes>(*orig._axes);
    }
    for (auto& e : orig._values)
    {
        if (e == NULL)
            continue;
        _values.push_back(std::make_shared<ValuesContainerHolder>(*e));
    }
    for (auto& e : orig._values_elements)
    {
        _values_elements.push_back(e);
    }
    for (auto& e : orig._functional)
    {
        if (e == NULL)
            continue;
        _functional.push_back(std::make_shared<functionalNode>(*e));
    }
    for (auto& e : orig._functional_elements)
    {
        _functional_elements.push_back(e);
    }
    _uncertainty = NULL;
    if (orig._uncertainty != NULL)
    {
        _uncertainty = std::make_shared<gpdc::uncertainty>(*orig._uncertainty);
    }
}

void functionalNode::readFromElement(std::shared_ptr<const Element>& val,
                                     ContainerRepository*            repo)
{
    GNDElement::readFromElement(val, repo);
    Float64 _default_value = getDefaultValue<Float64>();
    _value                 = _default_value;

    std::shared_ptr<const Attribute> attr
        = getDataElement()->getAttribute("value");
    if (attr != NULL)
    {
        std::string attr_val = attr->getValue();
        parseValue<Float64>(attr_val, _value);
    }
    _values_elements     = getDataElement()->getElement("values");
    _functional_elements = getDataElement()->getElement("functional");
}
void functionalNode::saveToElement(std::shared_ptr<Element>& val) const
{
    GNDElement::saveToElement(val);
    std::string                value;
    std::shared_ptr<Attribute> attr;
    value.clear();
    saveValue<Float64>(_value, value);
    if (!value.empty())
    {
        attr = val->addAttribute("value");
        attr->setValue(value);
    }

    if (_axes != NULL)
    {
        std::shared_ptr<Element> ele = val->addElement("axes");
        _axes->saveToElement(ele);
    }

    if (_values.size() > 0)
    {
        for (auto& e : _values)
        {
            std::shared_ptr<Element> ele = val->addElement("values");
            e->saveToElement(ele);
        }
    }

    if (_functional.size() > 0)
    {
        for (auto& e : _functional)
        {
            std::shared_ptr<Element> ele = val->addElement("functional");
            e->saveToElement(ele);
        }
    }

    if (_uncertainty != NULL)
    {
        std::shared_ptr<Element> ele = val->addElement("uncertainty");
        _uncertainty->saveToElement(ele);
    }
}
bool functionalNode::includeInPassThrough(std::shared_ptr<const Element>& val) const
{
    GNDElement::includeInPassThrough(val);
    if (_axes != NULL && val->getName().compare("axes") == 0)
    {
        return false;
    }
    if (_values.size() > 0 && val->getName().compare("values") == 0)
    {
        return false;
    }
    if (_functional.size() > 0 && val->getName().compare("functional") == 0)
    {
        return false;
    }
    if (_uncertainty != NULL && val->getName().compare("uncertainty") == 0)
    {
        return false;
    }
    return true;
}
std::shared_ptr<const gpdc::axes> functionalNode::get_axes() const
{
    // first user supplied
    if (_axes != NULL)
        return _axes;
    // then from data element
    if (getDataElement() == NULL)
        return _axes;
    std::shared_ptr<const gpdc::axes> int_axes
        = getSingleObject<gpdc::axes>("axes");
    return int_axes;
}
std::shared_ptr<const ValuesContainerHolder>
functionalNode::get_values_byIndex(int index) const
{
    if (index < 0 || index >= getNum_values())
        throw gnd_error(" index out for range for values");
    if (_values.size() > 0)
        return _values[index];
    return getDataFromElement<ValuesContainerHolder>(_values_elements[index]);
}
void functionalNode::get_values(
    std::vector<std::shared_ptr<const ValuesContainerHolder>>& data) const
{
    data.clear();
    int num = getNum_values();
    for (int i = 0; i < num; i++)
    {
        data.push_back(get_values_byIndex(i));
    }
}
std::shared_ptr<const functionalNode>
functionalNode::get_functional_byIndex(int index) const
{
    if (index < 0 || index >= getNum_functional())
        throw gnd_error(" index out for range for functional");
    if (_functional.size() > 0)
        return _functional[index];
    return getDataFromElement<functionalNode>(_functional_elements[index]);
}
void functionalNode::get_functional(
    std::vector<std::shared_ptr<const functionalNode>>& data) const
{
    data.clear();
    int num = getNum_functional();
    for (int i = 0; i < num; i++)
    {
        data.push_back(get_functional_byIndex(i));
    }
}
std::shared_ptr<const gpdc::uncertainty> functionalNode::get_uncertainty() const
{
    // first user supplied
    if (_uncertainty != NULL)
        return _uncertainty;
    // then from data element
    if (getDataElement() == NULL)
        return _uncertainty;
    std::shared_ptr<const gpdc::uncertainty> int_uncertainty
        = getSingleObject<gpdc::uncertainty>("uncertainty");
    return int_uncertainty;
}
} // namespace abstract
} // namespace endfgnd
+213 −0
Original line number Diff line number Diff line
#ifndef abstract_functional_Node_h
#define abstract_functional_Node_h

#include <algorithm>
#include <sstream>

#include "../GNDElement.h"
#include "../ExternalFiles.h"
#include "../Definitions.h"
#include "gpdc_axes.h"
#include "../ValuesContainer.h"
#include "abstract_functional_Node.h"
#include "gpdc_uncertainty.h"

/* Forward declarations of enumerations classes to avoid circular *
 * dependencies in the include file */

/* Forward declarations of member classes to avoid circular * dependencies in
 * the include file */
namespace endfgnd
{
namespace gpdc
{
class axes;
} // namespace gpdc
} // namespace endfgnd

namespace endfgnd
{
namespace abstract
{
class functionalNode;
} // namespace abstract
} // namespace endfgnd

namespace endfgnd
{
namespace gpdc
{
class uncertainty;
} // namespace gpdc
} // namespace endfgnd

namespace endfgnd
{
namespace abstract
{
/**
 * This section lists attributes and child nodes common to functional nodes
 *(containers). These are the `value' attribute and the child node
 *\elemlink{axes}.
 **/
class functionalNode : public GNDElement
{
  public:
    functionalNode();
    functionalNode(const functionalNode& orig);
    virtual ~functionalNode() {}

    virtual void        readFromElement(std::shared_ptr<const Element>& val,
                                        ContainerRepository*            repo = NULL);
    virtual void        saveToElement(std::shared_ptr<Element>& val) const;
    virtual std::string getElementName() const { return "functional"; }

    /**
     * For an $n$-dimensional function, this is its associated $x_{n+1}$ value.
     * Required for all functional nodes that are nested inside
     * higher-dimension functional nodes.
     * @return the value of this attribute
     */
    Float64 value() const { return _value; }

    /**
     * For an $n$-dimensional function, this is its associated $x_{n+1}$ value.
     * Required for all functional nodes that are nested inside
     * higher-dimension functional nodes.
     * @param  val the value of this attribute
     */
    void value(const Float64& val) { _value = val; }

    /**
     * An \elemlink{axes} node.
     * @return the member object
     */
    std::shared_ptr<const gpdc::axes> get_axes() const;
    /**
     * An \elemlink{axes} node.
     * @param val the member object
     */
    void set_axes(std::shared_ptr<gpdc::axes>& val) { _axes = std::move(val); }

    /**
     * A list of numeric values. The meaning of the numbers depends on the type
     * of function.
     * @param val the member object to add
     */
    void add_values(std::shared_ptr<ValuesContainerHolder>& val)
    {
        _values.push_back(std::make_shared<ValuesContainerHolder>());
        _values[_values.size() - 1] = std::move(val);
    }
    /**
     * A list of numeric values. The meaning of the numbers depends on the type
     * of function.
     * @return number of elements for this type
     */
    int getNum_values() const
    {
        if ((int)_values.size() > 0)
            return (int)_values.size();
        return (int)_values_elements.size();
    }
    /**
     * A list of numeric values. The meaning of the numbers depends on the type
     * of function.
     * @param index the index for the desired member obkect
     * @return object at the indicated index
     */
    std::shared_ptr<const ValuesContainerHolder>
    get_values_byIndex(int index) const;
    /**
     * A list of numeric values. The meaning of the numbers depends on the type
     * of function.
     * @param data  on output a list of all the members
     */
    void get_values(
        std::vector<std::shared_ptr<const ValuesContainerHolder>>& data) const;

    /**
     * A list of lower-dimensional functions contained inside this function.
     * @param val the member object to add
     */
    void add_functional(std::shared_ptr<functionalNode>& val)
    {
        _functional.push_back(std::make_shared<functionalNode>());
        _functional[_functional.size() - 1] = std::move(val);
    }
    /**
     * A list of lower-dimensional functions contained inside this function.
     * @return number of elements for this type
     */
    int getNum_functional() const
    {
        if ((int)_functional.size() > 0)
            return (int)_functional.size();
        return (int)_functional_elements.size();
    }
    /**
     * A list of lower-dimensional functions contained inside this function.
     * @param index the index for the desired member obkect
     * @return object at the indicated index
     */
    std::shared_ptr<const functionalNode>
    get_functional_byIndex(int index) const;
    /**
     * A list of lower-dimensional functions contained inside this function.
     * @param data  on output a list of all the members
     */
    void get_functional(
        std::vector<std::shared_ptr<const functionalNode>>& data) const;

    /**
     * The \elemlink{uncertainty} node.
     * @return the member object
     */
    std::shared_ptr<const gpdc::uncertainty> get_uncertainty() const;
    /**
     * The \elemlink{uncertainty} node.
     * @param val the member object
     */
    void set_uncertainty(std::shared_ptr<gpdc::uncertainty>& val)
    {
        _uncertainty = std::move(val);
    }

  protected:
    virtual bool
    includeInPassThrough(std::shared_ptr<const Element>& val) const;

  private:
    /**
     * For an $n$-dimensional function, this is its associated $x_{n+1}$ value.
     *Required for all functional nodes that are nested inside higher-dimension
     *functional nodes.
     **/
    Float64 _value;

    /**
     * An \elemlink{axes} node.
     **/
    std::shared_ptr<gpdc::axes> _axes;

    /**
     * A list of numeric values. The meaning of the numbers depends on the type
     *of function.
     **/
    std::vector<std::shared_ptr<ValuesContainerHolder>> _values;
    std::vector<std::shared_ptr<const Element>>         _values_elements;

    /**
     * A list of lower-dimensional functions contained inside this function.
     **/
    std::vector<std::shared_ptr<functionalNode>> _functional;
    std::vector<std::shared_ptr<const Element>>  _functional_elements;

    /**
     * The \elemlink{uncertainty} node.
     **/
    std::shared_ptr<gpdc::uncertainty> _uncertainty;
};
} // namespace abstract
} // namespace endfgnd
#endif /*abstract_functional_Node_h*/
+35 −0
Original line number Diff line number Diff line
#include "abstract_label_Node.h"
#include <sstream>

namespace endfgnd
{
namespace abstract
{
labelNode::labelNode()
    : GNDElement("label")
{
}

labelNode::labelNode(const labelNode& orig)
    : GNDElement(orig)
{
}

void labelNode::readFromElement(std::shared_ptr<const Element>& val,
                                ContainerRepository*            repo)
{
    GNDElement::readFromElement(val, repo);
}
void labelNode::saveToElement(std::shared_ptr<Element>& val) const
{
    GNDElement::saveToElement(val);
    std::string                value;
    std::shared_ptr<Attribute> attr;
}
bool labelNode::includeInPassThrough(std::shared_ptr<const Element>& val) const
{
    GNDElement::includeInPassThrough(val);
    return true;
}
} // namespace abstract
} // namespace endfgnd
+44 −0
Original line number Diff line number Diff line
#ifndef abstract_label_Node_h
#define abstract_label_Node_h

#include <algorithm>
#include <sstream>

#include "../GNDElement.h"
#include "../ExternalFiles.h"
#include "../Definitions.h"

/* Forward declarations of enumerations classes to avoid circular *
 * dependencies in the include file */
namespace endfgnd
{
namespace abstract
{
/**
 * Many nodes (containers) can reside in other nodes. When more than one node
 *of the same type is embedded in another node, a unique way is needed to
 *address a specific node. The label attribute provides this capability.  An
 *xlink can address a child node with a unique label even when embedded in a
 *parent node containing more than one child nodes of the same type.
 **/
class labelNode : public GNDElement
{
  public:
    labelNode();
    labelNode(const labelNode& orig);
    virtual ~labelNode() {}

    virtual void        readFromElement(std::shared_ptr<const Element>& val,
                                        ContainerRepository*            repo = NULL);
    virtual void        saveToElement(std::shared_ptr<Element>& val) const;
    virtual std::string getElementName() const { return "label"; }

  protected:
    virtual bool
    includeInPassThrough(std::shared_ptr<const Element>& val) const;

  private:
};
} // namespace abstract
} // namespace endfgnd
#endif /*abstract_label_Node_h*/
Loading