Source: OmBindingNode.h


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

/**
 * The binding node structure.
 *
 * This class provides a specialization of OmNode to implement the binding node construction.
 * This corresponds to a binder B on a sequence of bound variables V[0..n] and a bound object X.
 * This is encoded as <OMBIND> B <OMBVAR> V0 ... Vn </OMBVAR> X </OMBIND>
 * The list of children must represent the enclosed sequence of <B, V0, ..., Vn, X>.
 */
class OmBindingNode : public OmNode
{
public:
  /** 
   * Default constructor.
   */
  OmBindingNode() {}

protected:
  /**
   * Copy constructor.
   */
  OmBindingNode(const OmBindingNode & other_in)
    : OmNode(other_in) {}

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

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

  /**
   * Implement the deep cloning.
   */
  virtual OmNode * cloneImp() const {
    return new OmBindingNode(*this); }
      
  /**
   * Implement the writing to an output device.
   */
  virtual void writeImp(OmOutputDevice & output_in) const {
    OmException::checkMalformedNode(count()<2, "OmBindingNode must have at least 2 arguments (the binder and the bound)");
    output_in.writeBinding();
    ConstIterator it = iterate();
    hibernate(output_in, it.getNext());
    output_in.writeBindingVariable();
    for (unsigned int index=1; index<=count()-2; ++index) {
      hibernate(output_in, it.getNext()); }
    output_in.writeEndBindingVariable();
    hibernate(output_in, it.getNext());
    output_in.writeEndBinding(); }
      
  /**
   * Implement the reading from an input device.
   */
  virtual void readImp(OmInputDevice & input_in) {
    OmCommentCollector cc;
    input_in.readBinding();
    cc.collect(input_in);
    append(cc.uncollect(OmNode::resurrect(input_in)));
    cc.collect(input_in);
    input_in.readBindingVariable();
    cc.collect(input_in);
    OmType type;
    input_in.readType(type);
    while (type!=OmEndBindingVariableType) {
      append(cc.uncollect(OmNode::resurrect(input_in)));
      cc.collect(input_in);
      input_in.readType(type); }
    cc.collect(input_in);
    input_in.readEndBindingVariable();
    cc.collect(input_in);
    append(cc.uncollect(OmNode::resurrect(input_in)));
    cc.collect(input_in);
    input_in.readEndBinding(); }
};

#endif // OM_BINDING_NODE_H

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