Source: OmSymbolNode.h


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

/**
 * The symbol final node structure.
 *
 * This class provides a specialization of OmFinalNode to implement the Symbol node construction.
 * This corresponds to a couple of two attributes, the name of the content dictionary the symbol is
 * coming from, and the name of the symbol.
 * This is encoded as <OMS cd="representation" name="representation"/>
 * The list of children must always be empty.
 */
class OmSymbolNode : public OmFinalNode
{
public:
  /**
   * Constructor (can be used as default).
   * @li Precondition: ~ NullPointer(cd_in) and ~ NullPointer(name_in)
   */
  explicit OmSymbolNode(const char * cd_in="", const char * name_in="") {
    OmException::checkNullPointer(cd_in);
    OmException::checkNullPointer(name_in);
    cd_ = cd_in;
    name_ = name_in; }

  /**
   * Get the cd.
   */
  virtual const char * getCD() const {
    return cd_.c_str(); }

  /**
   * Set the cd.
   * @li Precondition: ~ NullPointer(cd_in)
   */
  virtual void setCD(const char * cd_in) {
    OmException::checkNullPointer(cd_in);
    cd_ = cd_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.
   */
  OmSymbolNode(const OmSymbolNode & other_in)
    : OmFinalNode(other_in),
      cd_(other_in.cd_), name_(other_in.name_) {}

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

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

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

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

  /**
   * Implement the reading from an input device.
   */
  virtual void readImp(OmInputDevice & input_in) {
    unsigned int cdLength, nameLength;
    input_in.readSymbolLength(cdLength, nameLength);
    cd_.resize(cdLength);
    name_.resize(nameLength);
    input_in.readSymbol(&cd_[0], cdLength, &name_[0], nameLength); }

private:
  string cd_;
  string name_;
};

#endif // OM_SYMBOL_NODE_H

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