// Class Name: operation // // Purpose: // // An operation object manages a ZENO specification for a ZENO operation. #ifndef OPERATION_CLASS #define OPERATION_CLASS #include "amorph.h" #include "consequence.h" #include "operand.h" //#include "pack_amorph.h" class operation // : public chunk, private packable_amorph { public: operation(); ~operation(); // name: returns the name of the operation. string name() const; void name(const string &name); // operands: returns the number of operands for this operation, so far. int operands() const; // add_operand: associates an operand with this operation. the index number // of the new operand is returned. the indices range from 1 through the // number of operands. int add_operand(operand *new_operand); // get_operand: returns the specified operand. it is an error to get an // undefined operand. the string version matches the name specified and // returns the operand if it exists, or NIL if it is not found. operand *get_operand(int index); operand *get_operand(string operand_name); // consequences: returns the number of consequences for this operation. int consequences() const; // add_consequence: associates a consequence with this operation. the index // number of the new consequence is returned, same range as add_operand. int add_consequence(consequence *new_consequence); // get_consequence: returns the specified consequence. it is an error to // get an undefined consequence. consequence *get_consequence(int index); consequence *get_consequence(string consequence_name); // well_formed: returns TRUE if the operation is well-specified. this is // interpreted as meaning: // 1. there is at least one consequence from the operation. // 2. all consequences are well formed. // 3. all operands are well-formed, although none are necessary. // 4. the operation has a name. // 5. int well_formed() const; // pack: returns a packed form of this operation that can be stored to disk. // virtual byte *pack(int &size) const; // this constructor retrieves an operation from its packed form. // friend operation *operation_unpack(byte *packed_operation); // print: prints out the info for this operation. void print() const; private: amorph my_consequences; amorph my_operands; string my_name; }; #endif