Source: OmVariableNode.h


Annotated List
Files
Globals
Hierarchy
Index
#ifndef OM_VARIABLE_NODE_H
#define OM_VARIABLE_NODE_H

/**
 * The variable final node structure.
 *
 * This class provides a specialization of OmFinalNode to implement the Variable node construction.
 * This corresponds to a basically named element.
 * This is encoded as <OMV name="representation"/>
 * The list of children must always be empty.
 */
class OmVariableNode : public OmFinalNode
{
public:
  /**
   * Constructor (can be used as default).
   * @li Precondition: ~ NullPointer(name_in)
   */
  explicit OmVariableNode(const char * name_in="") {
    OmException::checkNullPointer(name_in);
    name_ = name_in; }

  /**
   * Get the name.
   */
  virtual const char * getName() const {
    return name_.c_str(); }

  /**
   * Set the name.
   * @li Precondition: ~ NullPointer(name_in)
   */
  virtual void setName(const char * name_in) {
    OmException::checkNullPointer(name_in);
    name_ = name_in; }

protected:
  /**
   * Copy constructor.
   */
  OmVariableNode(const OmVariableNode & other_in)
    : OmFinalNode(other_in),
      name_(other_in.name_) {}

  /**
   * Destructor.
   */
  virtual ~OmVariableNode() {}

  /**
   * Implement access to the concrete type.
   */
  virtual OmType typeImp() const {
    return OmVariableType; }

  /**
   * Implement the deep cloning.
   */
  virtual OmNode * cloneImp() const {
    return new OmVariableNode(*this); }

  /**
   * Implement the writing to an output device.
   */
  virtual void writeImp(OmOutputDevice & output_in) const {
    OmException::checkMalformedNode(name_.empty(), "OmVariableNode cannot have empty name");
    output_in.writeVariable(name_.c_str()); }

  virtual void readImp(OmInputDevice & input_in) {
    unsigned int length;
    input_in.readLength(length);
    name_.resize(length);
    input_in.readVariable(&name_[0], length); }
  
private:
  string name_;
};

#endif // OM_VARIABLE_NODE_H

Generated by: root@localhost.localdomain on Tue Oct 12 21:02:30 199.