Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

SimpleModule Class Reference

A simplified version of the Module class. More...

#include <simple_module.h>

Inheritance diagram for SimpleModule:

Module ExecPass LinkSuifPass MarkLibPass List of all members.

Public Methods

 SimpleModule (SuifEnv* suif_env, LString name)
 Constructor. More...

virtual void execute (suif_vector<LString>* args) = 0
 This method should implement the function for this module. More...

virtual String get_help_string (void) const
 Get a human readable help string. More...

virtual String get_description (void) const
 Get a human readable help string.

virtual ~SimpleModule ()
 Destructor.

virtual Moduleclone () const
virtual void execute ()
virtual bool delete_me () const
virtual bool parse_command_line ( TokenStream* command_line_stream )
virtual FileSetBlock* get_file_set_block (void)
 Get the FileSetBlock in current SuifEnv.

void check_file_set_block (void)
 Check that the current SuifEnv has a FileSetBlock. More...

void check_arg_count (suif_vector<LString>* args, unsigned cnt)
 Check number of arguments. More...


Detailed Description

A simplified version of the Module class.

Example on how to use SimpleModule:

  class MyPass : public SimpleModule {
    public:
      MyPass(SuifEnv* senv) : SimpleModule("my_pass", senv) {};
      virtual void execute(suif_vector<LString>*);
      virtual String get_description(void) const;
 }

 extern "C" void EXPORT init_my_pass(SuifEnv* suif_env) {
   ModuleSubSystem* module_subsystem = suif_env->get_module_subsystem();
   module_subsystem->test_and_register_module(new MyPass(suif_env));
 }

The SimpleModule is designed so that it is reused in every invocation. I.e. it will not be cloned or deleted by the suifdriver.

The execute() method of Module is replace by SimpleModule::execute(), which takes a vector of strings as command line arguments. The subclass of SimpleModule is expected to define this method. This method is responsible for checking and interpreting the command line arguments.

If the command line argument consists of only "-h", or "-help", or "-?", then a string from get_description() will be printed on cerr. And the execute() method will not be called.


Constructor & Destructor Documentation

SimpleModule::SimpleModule ( SuifEnv * suif_env,
LString name)

Constructor.

Parameters:
suif_env   a SuifEnv.
name   the command name.

SimpleModule::~SimpleModule ( void) [inline, virtual]

Destructor.


Member Function Documentation

void SimpleModule::check_arg_count ( suif_vector<LString>* args,
unsigned cnt)

Check number of arguments.

Parameters:
args   the vector of arguments.
cnt   the right number of arguments.
Exceptions:
SuifException   if the number of arguments in args is not exactly cnt.

This method is designed to be called inside execute().

void SimpleModule::check_file_set_block ( void)

Check that the current SuifEnv has a FileSetBlock.

Exceptions:
SuifException   if a FileSetBlock is not loaded in SuifEnv.

This method is designed to be called inside execute().

Module * SimpleModule::clone ( void) const [inline, virtual]

For internal use only.

Reimplemented from Module.

bool SimpleModule::delete_me ( void) const [inline, virtual]

For internal use only.

Reimplemented from Module.

void SimpleModule::execute ( void) [inline, virtual]

For internal use only.

Reimplemented from Module.

void SimpleModule::execute ( suif_vector<LString>* args) [inline, pure virtual]

This method should implement the function for this module.

Parameters:
args   command line arguments.

See also:
check_file_set_block() , check_arg_count() , get_file_set_block()

Reimplemented in ExecPass, LinkSuifPass, and MarkLibPass.

String SimpleModule::get_description ( void) const [inline, virtual]

Get a human readable help string.

Reimplemented from Module.

Reimplemented in MarkLibPass.

FileSetBlock * SimpleModule::get_file_set_block ( void) [inline, virtual]

Get the FileSetBlock in current SuifEnv.

String SimpleModule::get_help_string ( void) const [inline, virtual]

Get a human readable help string.

Returns:
a help string.

deprecated: replaced by get_description().

Reimplemented in ExecPass, and LinkSuifPass.

bool SimpleModule::parse_command_line ( TokenStream * command_line_stream) [inline, virtual]

For internal use only.

Reimplemented from Module.


The documentation for this class was generated from the following files:
Generated at Mon Jul 31 13:44:32 2000 for NCI SUIF by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000