Class: DimCommand 
Library: DIM
Author: Ph. Charpentier  
Version: v1.0 Update :Thu Feb 11 15:52:46 1999

Description :

    To be used by DIM Servers - Implements Command creation.
    DimCommand constructors add a DIM Command to the list of known services.
    The DimCommand will only be registered (published) and served after "Starting" the DimServer.
    DimCommands can be treated either by a command handler (asynchronously) or be queued and
    retrieved to the user when requested, please refer to Usage for examples.

Constructors :

Destructors : Public Functions :

    Generic

     Without a commandHandler     With a Handler     Access to the Command Data     To find out which command it is (if same handler for multiple commands) Usage :

    DimCommands can be created in three different ways
    Examples:

        - Without a handler:

            DimCommand runCmnd("DELPHI/RUNCMND","C");
            DimServer::start("DelphiServer");
            ...
            while(1)
            {
                sleep(5);
                while(runCmnd.getNext()) {
                    //treat the command
                    char *cmnd = runCmnd.getString();
                    ...
            }

        - Using a commandHandler

            class RunCmnd : public DimCommand // In order to inherit "commandHandler"
            {
                // Overloaded method commandHandler called whenever commands arrive,
                void commandHandler()
                { //treat the command
                    cout << "command " << getString() << " received" << endl;
                }
            public:
                // The constructor initializes the DimCommand
                RunCmnd() : DimCommand("/DELPHI/RUNCMND", "C") {};
            };

         - Using a CommandHandler for multiple Commands

            class RunCmnds : public DimCommandHandler // In order to inherit "commandHandler"
            {
                DimCommand *runNumber;
                DimCommand *runType;
                // Overloaded method commandHandler called whenever commands arrive,
                void comandHandler( )
                {
                    DimCommand *currCmnd = getCommand();
                    if(currCmnd == runNumber)
                    {
                        int run = currCmnd->getInt( );
                        // treat runNumber command
                    }
                    else
                    {
                        char *type = currCmnd->getString( );
                        // treat runType command
                    }
                }
            public:
                // The constructor creates the Commands
                RunCmnds( )
                {
                    runNumber = new DimCommand("/DELPHI/RUN_NUMBER/CMD", "I", this);
                    runType = new DimCommand("/DELPHI/RUN_TYPE/CMD", "C", this);
                }
            };
 



Last update : 02/19/99 12:49:03 by MkHelp 1.1.0