00001 #ifndef SUIFKERNEL__MODULE_SUBSYSTEM_H 00002 #define SUIFKERNEL__MODULE_SUBSYSTEM_H 00003 00004 #include "suifkernel_forwarders.h" 00005 00006 class ModuleInterface; 00007 00008 class ModuleSubSystem { 00009 public: 00010 ModuleSubSystem( SuifEnv* _suif_env ); 00011 virtual ~ModuleSubSystem(); 00012 00013 virtual Module* initialize_module( const LString& moduleName ); 00014 00015 virtual bool is_initialized( const LString& moduleName ) const; 00016 virtual bool is_available( const LString& moduleName ) const; 00017 virtual void register_module( Module* module ); 00018 virtual bool test_and_register_module( Module* module, bool delete_if_fail ); 00019 virtual Module* retrieve_module( const LString& moduleName ) const; 00020 00021 virtual bool execute( const LString& moduleName, 00022 TokenStream* command_line ); 00023 00027 virtual void get_module_list(const LString &interface_filter, 00028 list<LString> &mlist) const; 00029 00030 // print out a list of the modules that implement the interface 00031 // If the interface_filter is the emptyLString then print them all out 00032 virtual void print_modules(ostream &output, 00033 const String &separator, 00034 const LString &interface_filter) const; 00035 00036 // Make a clone of the prototype module found by name 00037 // Then apply the command line to the clone and return it 00038 virtual Module* parse_command_line_and_clone( 00039 const LString& module_name, 00040 TokenStream* command_line ) const; 00041 00042 // Iterface for the SUIF interface support mechanism 00043 // Each module interested in knowing about the other modules that 00044 // support a particular interface should use these 00045 virtual void register_interface_listener( Module *listening_module, 00046 const LString &interface_name); 00047 // any module that supports an interface should register its interface 00048 // here: 00049 // These will issue callbacks to listeners. In the call back 00050 // code, you should NOT try to add a new listener. 00051 virtual void register_interface_producer_name(const LString &module_name, 00052 const LString &interface_name); 00053 00054 virtual void register_interface_producer(Module *module, 00055 const LString &interface_name); 00056 virtual void register_interface_producer_destruction(Module *module, 00057 const LString &interface_name); 00058 00059 virtual ModuleInterface *get_interface(const LString &interface_name) const; 00060 // Will build it if it does not exist. 00061 virtual ModuleInterface *retrieve_interface(const LString &interface_name); 00062 00063 virtual void set_interface_description(const LString &interface_name, 00064 const String &description); 00065 virtual String get_interface_description(const LString &interface_name) const; 00069 virtual void get_interface_list(list<LString> &ilist) const; 00070 00071 private: 00072 SuifEnv* _suif_env; 00073 suif_map<LString,Module*> *listOfRegisteredModules; 00074 suif_map<LString,ModuleInterface*> *moduleInterfaces; 00075 00076 ModuleSubSystem(const ModuleSubSystem &); 00077 ModuleSubSystem& operator=(const ModuleSubSystem &); 00078 }; 00079 00080 00081 00082 #endif 00083