Open CASCADE Technology  6.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions
IFSelect_SessionPilot Class Reference

A SessionPilot is intended to make easier the use of a
WorkSession. It receives commands, under alphanumeric form,
then calls a library of Activators to interprete and run them.

Then, WorkSession just records data required to work :
Rules for Selection, Dispatch ... ; File Data (InterfaceModel
and results of Evaluations and Transfer as required).
SessionPilot records and works with alphanumeric commands and
their results (under a very simple form). It calls a list of
Activators to perform the actions.

A Command can have several forms :
More...

#include <IFSelect_SessionPilot.hxx>

Inheritance diagram for IFSelect_SessionPilot:
Inheritance graph
[legend]

Public Member Functions

 IFSelect_SessionPilot (const Standard_CString prompt="")
 Creates an empty SessionPilot, with a prompt which will be
displayed on querying commands. If not precised (""), this
prompt is set to "Test-XSTEP>"
More...
 
Handle_IFSelect_WorkSession Session () const
 Returns the WorkSession which is worked on
More...
 
Handle_IFSelect_WorkLibrary Library () const
 Returns the WorKlibrary (Null if not set). WorkLibrary is used
to Read and Write Files, according to the Norm
More...
 
Standard_Boolean RecordMode () const
 Returns the Record Mode for Commands. Default is False.
More...
 
void SetSession (const Handle< IFSelect_WorkSession > &WS)
 Sets a WorkSession to be worked on
More...
 
void SetLibrary (const Handle< IFSelect_WorkLibrary > &WL)
 Sets a WorkLibrary
More...
 
void SetRecordMode (const Standard_Boolean mode)
 Changes the RecordMode.
More...
 
void SetCommandLine (const TCollection_AsciiString &command)
 Sets the value of the Command Line to be interpreted
Also prepares the interpretation (splitting by blanks)
More...
 
const TCollection_AsciiStringCommandLine () const
 Returns the Command Line to be interpreted
More...
 
Standard_CString CommandPart (const Standard_Integer numarg=0) const
 Returns the part of the command line which begins at argument
<numarg> between 0 and NbWords-1 (by default, all the line)
Empty string if out of range
More...
 
Standard_Integer NbWords () const
 
Returns the count of words of the Command Line, separated by <br>
     blanks : 0 if empty, one if a command without args, else it <br>
     gives the count of args minus one. <br>

Warning : limited to 10 (command title + 9 args)
More...

 
const TCollection_AsciiStringWord (const Standard_Integer num) const
 Returns a word given its rank in the Command Line. Begins at 0
which is the Command Title, 1 is the 1st arg., etc...
More...
 
Standard_CString Arg (const Standard_Integer num) const
 Returns a word given its rank, as a CString.
As for Word, begins at 0 (the command name), etc...
More...
 
Standard_Boolean RemoveWord (const Standard_Integer num)
 Removes a word given its rank. Returns True if Done, False if
<num> is out of range
More...
 
Standard_Integer NbCommands () const
 Returns the count of recorded Commands
More...
 
const TCollection_AsciiStringCommand (const Standard_Integer num) const
 Returns a recorded Command, given its rank (from 1)
More...
 
IFSelect_ReturnStatus RecordItem (const Handle< Standard_Transient > &item)
 Allows to associate a Transient Value with the last execution
as a partial result
Returns RetDone if item is not Null, RetFail if item is Null
Remark : it is nullified for each Perform
More...
 
Handle_Standard_Transient RecordedItem () const
 Returns the Transient Object which was recorded with the
current Line Command. If none was, returns a Null Handle
More...
 
void Clear ()
 Clears the recorded informations (commands, objects)
More...
 
IFSelect_ReturnStatus ReadScript (const Standard_CString file="")
 Reads commands from a Script File, named <file>. By default
(file = ""), reads from standard input with a prompt
Else (reading from a file), the read commands are displayed
onto standard output. Allows nested reads. Reading is stopped
either by command x or exit, or by reaching end of file
Return Value follows the rules of Do : RetEnd for normal end,
RetFail if script could not be opened
More...
 
IFSelect_ReturnStatus Perform ()
 Executes the Command, itself (for built-in commands, which
have priority) or by using the list of Activators.
The value returned is : RetVoid if nothing done (void command)
RetDone if execution OK, RetEnd if END OF SESSION, RetError if
command unknown or incorrect, RetFail if error on execution
If execution is OK and RecordMode is set, this Command Line is
recorded to the list (see below).
More...
 
IFSelect_ReturnStatus ExecuteAlias (const TCollection_AsciiString &aliasname)
 
 Executes the Commands, except that the command name (word 0) <br>
      is aliased. The rest of the command line is unchanged <br>
      If <alias> is empty, Executes with no change <br>


Error status is returned if the alias is unknown as command
More...

 
IFSelect_ReturnStatus Execute (const TCollection_AsciiString &command)
 Sets the Command then tries to execute it. Return value :
same as for Perform
More...
 
IFSelect_ReturnStatus ExecuteCounter (const Handle< IFSelect_SignCounter > &counter, const Standard_Integer numword, const IFSelect_PrintCount mode=IFSelect_CountByItem)
 Executes a Counter in a general way
If <numword> is greater than count of command words, it counts
all the model. Else it considers the word <numword> as the
identifier of a Selection
<mode> gives the mode of printing results, default is
CountByItem
More...
 
Standard_Integer Number (const Standard_CString val) const
 Interprets a string value as an entity number :
if it gives an integer, returns its value
else, considers it as ENtityLabel (preferably case sensitive)
in case of failure, returns 0
More...
 
IFSelect_ReturnStatus Do (const Standard_Integer number, const Handle< IFSelect_SessionPilot > &session)
 Processes specific commands, which are :
x or exit for end of session
? or help for help messages
xcommand to control command lines (Record Mode, List, Clear,
File Output ...)
xsource to execute a command file (no nesting allowed),
in case of error, source is stopped and keyword recovers
xstep is a simple prefix (useful in a wider environment, to
avoid conflicts on command names)
xset control commands which create items with names
More...
 
Standard_CString Help (const Standard_Integer number) const
 Help for specific commands (apart from general command help)
More...
 
- Public Member Functions inherited from IFSelect_Activator
void Add (const Standard_Integer number, const Standard_CString command) const
 Allows a self-definition by an Activator of the Commands it
processes, call the class method Adding (mode 0)
More...
 
void AddSet (const Standard_Integer number, const Standard_CString command) const
 Same as Add but specifies that this command is candidate for
xset (creation of items, xset : named items; mode 1)
More...
 
Standard_CString Group () const
 
Standard_CString File () const
 
void SetForGroup (const Standard_CString group, const Standard_CString file="")
 Group and SetGroup define a "Group of commands" which
correspond to an Activator. Default is "XSTEP"
Also a file may be attached
More...
 
- Public Member Functions inherited from MMgt_TShared
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void ShallowDump (Standard_OStream &) const
 
virtual const
Handle_Standard_Type & 
DynamicType () const
 Returns a type information object about this object. More...
 
Standard_Boolean IsInstance (const Handle_Standard_Type &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const Handle_Standard_Type &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
virtual Handle_Standard_Transient This () const
 Returns a Handle which references this object. Must never be called to objects created in stack. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from IFSelect_Activator
static void Adding (const Handle< IFSelect_Activator > &actor, const Standard_Integer number, const Standard_CString command, const Standard_Integer mode)
 Records, in a Dictionary available for all the Activators,
the command title an Activator can process, attached with
its number, proper for this Activator
<mode> allows to distinguish various execution modes
0: default mode; 1 : for xset
More...
 
static void Remove (const Standard_CString command)
 Removes a Command, if it is recorded (else, does nothing)
More...
 
static void SetAlias (const Standard_CString conf, const Standard_CString command, const Standard_CString aliasname)
 
 Records, for a configuration named <conf>, that the command <br>
      <command> may be aliased by another command <alias> <br>


To be used by call to Alias (no automatic redirection)
The configuration typically refers to a norm
More...

 
static void SetCurrentAlias (const Standard_CString conf)
 Sets <conf> as current configuration for aliases
More...
 
static TCollection_AsciiString Alias (const Standard_CString command)
 Returns, in the current configuration, what alias has been
recorded for <command>
The returned string is empty if no alias is recorded
More...
 
static Standard_Boolean Select (const Standard_CString command, Standard_Integer &number, Handle< IFSelect_Activator > &actor)
 Selects, for a Command given by its title, an actor with its
command number. Returns True if found, False else
More...
 
static Standard_Integer Mode (const Standard_CString command)
 Returns mode recorded for a command. -1 if not found
More...
 
static
Handle_TColStd_HSequenceOfAsciiString 
Commands (const Standard_Integer mode=-1, const Standard_CString command="")
 Returns, for a root of command title, the list of possible
commands.
<mode> : -1 (D) for all commands if <commands> is empty
-1 + command : about a Group , >= 0 see Adding
By default, it returns the whole list of known commands.
More...
 
- Protected Member Functions inherited from IFSelect_Activator
 IFSelect_Activator ()
 Sets the default values
More...
 

Detailed Description

A SessionPilot is intended to make easier the use of a
WorkSession. It receives commands, under alphanumeric form,
then calls a library of Activators to interprete and run them.

Then, WorkSession just records data required to work :
Rules for Selection, Dispatch ... ; File Data (InterfaceModel
and results of Evaluations and Transfer as required).
SessionPilot records and works with alphanumeric commands and
their results (under a very simple form). It calls a list of
Activators to perform the actions.

A Command can have several forms :

      - classic execution, to list, evaluate, or enrich the session <br>
      - command which creates a new item (a Selection for instance) <br>
        such a command should not add it to the session, but make it <br>
        recorded by the Pilot (method RecordItem). The Pilot will <br>
        add the item in the session, with no name <br>
      -> such a command may be called : <br>
        - directly, it will add an item with no name <br>
        - by command xset, in the following form : <br>
        xset name command ...  calls the command and adds the item <br>
          to the session under the specified name (if not yet known) <br>


Thus, to a specific Norm or way of working, only Activators
change. A specific Initialisation can be done by starting
with a specific set of commands.

In addition, SessionPilot is a sub-type of Activator, to
recognize some built-in commands : exit/x, help/?, control of
command line, and commands xstep xset ... See method Do

At least, empty lines and comment lines (beginning by '#')
are skipped (comment lines are display if read from file)

Constructor & Destructor Documentation

IFSelect_SessionPilot::IFSelect_SessionPilot ( const Standard_CString  prompt = "")

Creates an empty SessionPilot, with a prompt which will be
displayed on querying commands. If not precised (""), this
prompt is set to "Test-XSTEP>"

Member Function Documentation

Standard_CString IFSelect_SessionPilot::Arg ( const Standard_Integer  num) const

Returns a word given its rank, as a CString.
As for Word, begins at 0 (the command name), etc...

void IFSelect_SessionPilot::Clear ( )

Clears the recorded informations (commands, objects)

const TCollection_AsciiString& IFSelect_SessionPilot::Command ( const Standard_Integer  num) const

Returns a recorded Command, given its rank (from 1)

const TCollection_AsciiString& IFSelect_SessionPilot::CommandLine ( ) const

Returns the Command Line to be interpreted

Standard_CString IFSelect_SessionPilot::CommandPart ( const Standard_Integer  numarg = 0) const

Returns the part of the command line which begins at argument
<numarg> between 0 and NbWords-1 (by default, all the line)
Empty string if out of range

IFSelect_ReturnStatus IFSelect_SessionPilot::Do ( const Standard_Integer  number,
const Handle< IFSelect_SessionPilot > &  session 
)
virtual

Processes specific commands, which are :
x or exit for end of session
? or help for help messages
xcommand to control command lines (Record Mode, List, Clear,
File Output ...)
xsource to execute a command file (no nesting allowed),
in case of error, source is stopped and keyword recovers
xstep is a simple prefix (useful in a wider environment, to
avoid conflicts on command names)
xset control commands which create items with names

Implements IFSelect_Activator.

IFSelect_ReturnStatus IFSelect_SessionPilot::Execute ( const TCollection_AsciiString command)

Sets the Command then tries to execute it. Return value :
same as for Perform

IFSelect_ReturnStatus IFSelect_SessionPilot::ExecuteAlias ( const TCollection_AsciiString aliasname)

 Executes the Commands, except that the command name (word 0) <br>
      is aliased. The rest of the command line is unchanged <br>
      If <alias> is empty, Executes with no change <br>


Error status is returned if the alias is unknown as command

IFSelect_ReturnStatus IFSelect_SessionPilot::ExecuteCounter ( const Handle< IFSelect_SignCounter > &  counter,
const Standard_Integer  numword,
const IFSelect_PrintCount  mode = IFSelect_CountByItem 
)

Executes a Counter in a general way
If <numword> is greater than count of command words, it counts
all the model. Else it considers the word <numword> as the
identifier of a Selection
<mode> gives the mode of printing results, default is
CountByItem

Standard_CString IFSelect_SessionPilot::Help ( const Standard_Integer  number) const
virtual

Help for specific commands (apart from general command help)

Implements IFSelect_Activator.

Handle_IFSelect_WorkLibrary IFSelect_SessionPilot::Library ( ) const

Returns the WorKlibrary (Null if not set). WorkLibrary is used
to Read and Write Files, according to the Norm

Standard_Integer IFSelect_SessionPilot::NbCommands ( ) const

Returns the count of recorded Commands

Standard_Integer IFSelect_SessionPilot::NbWords ( ) const

Returns the count of words of the Command Line, separated by <br>
     blanks : 0 if empty, one if a command without args, else it <br>
     gives the count of args minus one. <br>

Warning : limited to 10 (command title + 9 args)

Standard_Integer IFSelect_SessionPilot::Number ( const Standard_CString  val) const

Interprets a string value as an entity number :
if it gives an integer, returns its value
else, considers it as ENtityLabel (preferably case sensitive)
in case of failure, returns 0

IFSelect_ReturnStatus IFSelect_SessionPilot::Perform ( )

Executes the Command, itself (for built-in commands, which
have priority) or by using the list of Activators.
The value returned is : RetVoid if nothing done (void command)
RetDone if execution OK, RetEnd if END OF SESSION, RetError if
command unknown or incorrect, RetFail if error on execution
If execution is OK and RecordMode is set, this Command Line is
recorded to the list (see below).

IFSelect_ReturnStatus IFSelect_SessionPilot::ReadScript ( const Standard_CString  file = "")

Reads commands from a Script File, named <file>. By default
(file = ""), reads from standard input with a prompt
Else (reading from a file), the read commands are displayed
onto standard output. Allows nested reads. Reading is stopped
either by command x or exit, or by reaching end of file
Return Value follows the rules of Do : RetEnd for normal end,
RetFail if script could not be opened

Handle_Standard_Transient IFSelect_SessionPilot::RecordedItem ( ) const

Returns the Transient Object which was recorded with the
current Line Command. If none was, returns a Null Handle

IFSelect_ReturnStatus IFSelect_SessionPilot::RecordItem ( const Handle< Standard_Transient > &  item)

Allows to associate a Transient Value with the last execution
as a partial result
Returns RetDone if item is not Null, RetFail if item is Null
Remark : it is nullified for each Perform

Standard_Boolean IFSelect_SessionPilot::RecordMode ( ) const

Returns the Record Mode for Commands. Default is False.

Standard_Boolean IFSelect_SessionPilot::RemoveWord ( const Standard_Integer  num)

Removes a word given its rank. Returns True if Done, False if
<num> is out of range

Handle_IFSelect_WorkSession IFSelect_SessionPilot::Session ( ) const

Returns the WorkSession which is worked on

void IFSelect_SessionPilot::SetCommandLine ( const TCollection_AsciiString command)

Sets the value of the Command Line to be interpreted
Also prepares the interpretation (splitting by blanks)

void IFSelect_SessionPilot::SetLibrary ( const Handle< IFSelect_WorkLibrary > &  WL)

Sets a WorkLibrary

void IFSelect_SessionPilot::SetRecordMode ( const Standard_Boolean  mode)

Changes the RecordMode.

void IFSelect_SessionPilot::SetSession ( const Handle< IFSelect_WorkSession > &  WS)

Sets a WorkSession to be worked on

const TCollection_AsciiString& IFSelect_SessionPilot::Word ( const Standard_Integer  num) const

Returns a word given its rank in the Command Line. Begins at 0
which is the Command Title, 1 is the 1st arg., etc...


The documentation for this class was generated from the following file: