HcsmC++ System - Executing HCSM


When you instantiate hcsm, you will need to store them, or at least, maintain pointers to those instantiations. We have provided a very simple mechanism for doing this. It is called the HcsmSystem. It maintains pointers to hcsm and then when invoked will execute the behavior of each hcsm. In order to execute the hcsm in the HcsmSystem, you need only make one call. This is the call to the HcsmSystem class member, engine(). However, it's important to set up the HcsmSystem first.

Conversely, if you do not want to use the HcsmSystem class, you can maintain your own lists of hcsm that have been instantiated. When it comes time to execute the hcsm, you will call the Hcsm Class member void Hcsm::execute( void ). This differs from the HcsmSystem method in that you call the execute member of each hcsm directly. This is also the means we will use in the hcsm-system.C code that can be found in the testhcsm directory of the source.

Hcsm* myhcsm = new MyNewHcsmClass();
myhcsm->execute();

To show the first process, I will outline a very simple main.C that illustrates how to use the HcsmSystem class.

   #include <HcsmSystem.H>
   #include <myHcsmClass.H>

   int main()
   {
      // instantiate the Hcsm System Class - allow the 
      // max number of hcsm in system to be 10
      HcsmSystem* hcsmsys = new HcsmSystem(10); 

      // instantiate and register hcsms with system 
      // - only want 2 hcsm for this example
      hcsmsys->addhcsm( new myHcsm() );
      hcsmsys->addhcsm( new myHcsm() );

      // run the engine 5 times - likewise, execute each hcsm five times
      for (int i=0; i<5; i++)
         hcsmsys->engine();

      delete hcsmsys;
      return 1;
   }


Return to the Main HcsmC++ Page
Last Modified:
Please send comments or questions to willemsn@cs.uiowa.edu
Copyright © 1996 - The University of Iowa : Department of Computer Science