// file: $isip/class/asr/Machine/Machine.h // version: $Id: Machine.h 8577 2002-08-14 00:04:41Z alphonso $ // // make sure definitions are only made once // #ifndef ISIP_MACHINE #define ISIP_MACHINE #ifndef ISIP_VECTOR_DOUBLE #include #endif #ifndef ISIP_STRING #include #endif #ifndef ISIP_DOUBLE #include #endif #ifndef ISIP_LONG #include #endif #ifndef ISIP_NAME_MAP #include #endif // Machine: a class used to represent a machine and its attributes // class Machine { //-------------------------------------------------------------------------- // // public constants // //-------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the algorithm choices // enum PROTOCOL { REMOTE_SHELL = 0, SECURE_SHELL, DEF_PROTOCOL = REMOTE_SHELL }; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_PROTOCOL; static const String PARAM_NODE_NAME; static const String PARAM_ARCHITECTURE; static const String PARAM_NUM_PROCESSORS; static const String PARAM_PROCESSOR_SPEED; static const String PARAM_MAIN_MEMORY; static const String PARAM_SWAP_MEMORY; static const String PARAM_OS_NAME; static const String PARAM_OS_VERSION; //---------------------------------------- // // default values and arguments // //---------------------------------------- // default values // static const int32 DEF_NUM_PROCESSORS = 1; static const float64 DEF_PROCESSOR_SPEED = 3.0e8; static const float64 DEF_MAIN_MEMORY = 0.0; static const float64 DEF_SWAP_MEMORY = 0.0; // define the static NameMap objects // static const NameMap PROTOCOL_MAP; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // declare the preferred connection protocol for the machine (rsh/ssh) // PROTOCOL protocol_d; // declare the nodename of the machine (isip100.isip.msstate.edu) // String node_name_d; // declare the machine architecture (pentium/sparc) // String architecture_d; // declare the number of processors on the machine (single/dual) // Long num_processors_d; // declare the speed of the processor on the machine (8.0e08/1.0e09) // VectorDouble speed_d; // declare the amount of main memory on the machine (1.0e09/2.0e09) // Double main_memory_d; // declare the amount of swap space on the machine (1.0e06/2.0e06) // Double swap_memory_d; // declare the operating system on the machine (solaris/linux) // String os_d; // declare the operating system version on the machine (v_7.0/v_8.0) // String os_version_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 // ~Machine() { clear(); } // method: default constructor // Machine(); // method: copy constructor // Machine(const Machine& arg) { assign(arg); } // method: assign // bool8 assign(const Machine& arg); // method: sofSize // int32 sofSize() const { return (PROTOCOL_MAP.elementSofSize() + node_name_d.sofSize() + architecture_d.sofSize() + num_processors_d.sofSize() + speed_d.sofSize() + main_memory_d.sofSize() + swap_memory_d.sofSize() + os_d.sofSize() + os_version_d.sofSize()); } // method: read // bool8 read(Sof& sof, int32 tag) { return read(sof, tag, name()); } bool8 read(Sof& sof, int32 tag, const String& name); // method: write // bool8 write(Sof& sof, int32 tag) const { return write(sof, tag, name()); } bool8 write(Sof& sof, int32 tag, const String& name) const; bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: eq // bool8 eq(const Machine& 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: getProtocol // PROTOCOL getProtocol() { return protocol_d; } // method: setProtocol // bool8 setProtocol(PROTOCOL arg) { protocol_d = arg; return true; } // method: getNodeName // String& getNodeName() { return node_name_d; } // method: setNodeName // bool8 setNodeName(String& arg) { return node_name_d.assign(arg); } // method: getArchitecture // String& getArchitecture() { return architecture_d; } // method: setArchitecture // bool8 setArchitecture(String& arg) { return architecture_d.assign(arg); } // method: getNumProcessors // int32 getNumProcessors() { return (int32)num_processors_d; } // method: setNumProcessors // bool8 setNumProcessors(int32 arg) { return (num_processors_d = arg); } // method: getProcessorSpeed // VectorDouble& getProcessorSpeed() { return speed_d; } // method: setProcessorSpeed // bool8 setProcessorSpeed(VectorDouble& arg) { return speed_d.assign(arg); } // method: getMainMemory // float64 getMainMemory() { return (float64)main_memory_d; } // method: setMainMemory // bool8 setMainMemory(float64 arg) { return (main_memory_d = arg); } // method: getSwapMemory // float64 getSwapMemory() { return (float64)swap_memory_d; } // method: setSwapMemory // bool8 setSwapMemory(float64 arg) { return (swap_memory_d = arg); } // method: getOS // String& getOS() { return os_d; } // method: setOS // bool8 setOS(String& arg) { return os_d.assign(arg); } // method: getOSVersion // String& getOSVersion() { return os_version_d; } // method: setOSVersion // bool8 setOSVersion(String& arg) { return os_version_d.assign(arg); } //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; //end of include file // #endif