// file: $isip/class/asr/MachineDatabase/MachineDatabase.h // version: $Id: MachineDatabase.h 8575 2002-08-13 23:27:48Z alphonso $ // // make sure definitions are only made once // #ifndef ISIP_MACHINE_DATABASE #define ISIP_MACHINE_DATABASE #ifndef ISIP_STRING #include #endif #ifndef ISIP_VECTOR #include #endif #ifndef ISIP_MACHINE #include #endif // forward class definitions // class Machine; // MachineDatabase: a class used to represent a database of machines // class MachineDatabase { //-------------------------------------------------------------------------- // // public constants // //-------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_NAME; static const String PARAM_MACHINES; //---------------------------------------- // // default values and arguments // //---------------------------------------- // default values // //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // define the database name // String name_d; // define the container object // Vector database_d; // declare a static debug level for all class instantiations // static Integral::DEBUG debug_level_d; // a static memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } static bool8 diagnose(Integral::DEBUG debug_level); // debug methods // bool8 debug(const unichar* msg) const; // method: setDebug // static bool8 setDebug(Integral::DEBUG arg) { debug_level_d = arg; return true; } // method: destructor // ~MachineDatabase() { clear(); } // method: default constructor // MachineDatabase(); // method: copy constructor // MachineDatabase(const MachineDatabase& arg) { assign(arg); } // method: assign // bool8 assign(const MachineDatabase& arg); // method: sofSize // int32 sofSize() const { return (name_d.sofSize() + database_d.sofSize()); } // method: read // bool8 read(Sof& sof, int32 tag) { return read(sof, tag, name()); } // other read methods // bool8 read(Sof& sof, int32 tag, const String& name); bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); // method: write // bool8 write(Sof& sof, int32 tag) const { return write(sof, tag, name()); } // other write methods // bool8 write(Sof& sof, int32 tag, const String& name) const; bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: eq // bool8 eq(const MachineDatabase& arg) const; // method: new // static void* operator new(size_t arg) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t arg) { return mgr_d.getBlock(arg); } // method: delete // static void operator delete(void* arg) { mgr_d.release(arg); } // method: delete[] // static void operator delete[](void* arg) { mgr_d.releaseBlock(arg); } // method: setGrowSize // static bool8 setGrowSize(int32 arg) { return mgr_d.setGrow(arg); } // method: clear // bool8 clear(Integral::CMODE cmode = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // method: isEmpty // bool8 isEmpty() { return ((int32)database_d.length() == 0); } // method: getDataBaseName // String& getDataBaseName() { return name_d; } // method: setDataBaseName // bool8 setDataBaseName(String& arg) { return name_d.assign(arg); } // method: getDataBase // Vector& getDataBase() { return database_d; } // method: setDataBase // bool8 setDataBase(Vector& arg) { return database_d.assign(arg); } // method: get // bool8 get(String& node, Machine& machine) { for (int32 i=0; i < database_d.length(); i++) { if (database_d(i).getNodeName().eq(node)) { machine.assign(database_d(i)); return true; } } return false; } //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; //end of include file // #endif