|
|
|||
File indexing completed on 2026-10-04 09:14:47
0001 // Created on: 1993-07-27 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1993-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _IFSelect_SessionPilot_HeaderFile 0018 #define _IFSelect_SessionPilot_HeaderFile 0019 0020 #include <Standard.hxx> 0021 0022 #include <Standard_Integer.hxx> 0023 #include <TCollection_AsciiString.hxx> 0024 #include <NCollection_Array1.hxx> 0025 #include <IFSelect_Activator.hxx> 0026 #include <IFSelect_ReturnStatus.hxx> 0027 #include <IFSelect_PrintCount.hxx> 0028 class IFSelect_WorkSession; 0029 class IFSelect_WorkLibrary; 0030 class IFSelect_SignCounter; 0031 0032 //! A SessionPilot is intended to make easier the use of a WorkSession. 0033 //! It receives commands, under alphanumeric form, 0034 //! then calls a library of Activators to interpret and run them. 0035 //! 0036 //! Then, WorkSession just records data required to work : 0037 //! Rules for Selection, Dispatch ... ; File Data (InterfaceModel 0038 //! and results of Evaluations and Transfer as required). 0039 //! SessionPilot records and works with alphanumeric commands and 0040 //! their results (under a very simple form). It calls a list of 0041 //! Activators to perform the actions. 0042 //! 0043 //! A Command can have several forms : 0044 //! - classic execution, to list, evaluate, or enrich the session 0045 //! - command which creates a new item (a Selection for instance) 0046 //! such a command should not add it to the session, but make it 0047 //! recorded by the Pilot (method RecordItem). The Pilot will 0048 //! add the item in the session, with no name 0049 //! -> such a command may be called : 0050 //! - directly, it will add an item with no name 0051 //! - by command xset, in the following form : 0052 //! xset name command ... calls the command and adds the item 0053 //! to the session under the specified name (if not yet known) 0054 //! 0055 //! Thus, to a specific Norm or way of working, only Activators 0056 //! change. A specific Initialisation can be done by starting 0057 //! with a specific set of commands. 0058 //! 0059 //! In addition, SessionPilot is a sub-type of Activator, to 0060 //! recognize some built-in commands : exit/x, help/?, control of 0061 //! command line, and commands xstep xset ... See method Do 0062 //! 0063 //! At least, empty lines and comment lines (beginning by '#') 0064 //! are skipped (comment lines are display if read from file) 0065 class IFSelect_SessionPilot : public IFSelect_Activator 0066 { 0067 0068 public: 0069 //! Creates an empty SessionPilot, with a prompt which will be 0070 //! displayed on querying commands. If not precised (""), this 0071 //! prompt is set to "Test-XSTEP>" 0072 Standard_EXPORT IFSelect_SessionPilot(const char* const prompt = ""); 0073 0074 //! Returns the WorkSession which is worked on 0075 Standard_EXPORT occ::handle<IFSelect_WorkSession> Session() const; 0076 0077 //! Returns the WorKlibrary (Null if not set). WorkLibrary is used 0078 //! to Read and Write Files, according to the Norm 0079 Standard_EXPORT occ::handle<IFSelect_WorkLibrary> Library() const; 0080 0081 //! Returns the Record Mode for Commands. Default is False. 0082 Standard_EXPORT bool RecordMode() const; 0083 0084 //! Sets a WorkSession to be worked on 0085 Standard_EXPORT void SetSession(const occ::handle<IFSelect_WorkSession>& WS); 0086 0087 //! Sets a WorkLibrary 0088 Standard_EXPORT void SetLibrary(const occ::handle<IFSelect_WorkLibrary>& WL); 0089 0090 //! Changes the RecordMode. 0091 Standard_EXPORT void SetRecordMode(const bool mode); 0092 0093 //! Sets the value of the Command Line to be interpreted 0094 //! Also prepares the interpretation (splitting by blanks) 0095 Standard_EXPORT void SetCommandLine(const TCollection_AsciiString& command); 0096 0097 //! Returns the Command Line to be interpreted 0098 Standard_EXPORT const TCollection_AsciiString& CommandLine() const; 0099 0100 //! Returns the part of the command line which begins at argument 0101 //! <numarg> between 0 and NbWords-1 (by default, all the line) 0102 //! Empty string if out of range 0103 Standard_EXPORT const char* CommandPart(const int numarg = 0) const; 0104 0105 //! Returns the count of words of the Command Line, separated by 0106 //! blanks : 0 if empty, one if a command without args, else it 0107 //! gives the count of args minus one. 0108 //! Warning : limited to 10 (command title + 9 args) 0109 Standard_EXPORT int NbWords() const; 0110 0111 //! Returns a word given its rank in the Command Line. Begins at 0 0112 //! which is the Command Title, 1 is the 1st arg., etc... 0113 Standard_EXPORT const TCollection_AsciiString& Word(const int num) const; 0114 0115 //! Returns a word given its rank, as a CString. 0116 //! As for Word, begins at 0 (the command name), etc... 0117 Standard_EXPORT const char* Arg(const int num) const; 0118 0119 //! Removes a word given its rank. Returns True if Done, False if 0120 //! <num> is out of range 0121 Standard_EXPORT bool RemoveWord(const int num); 0122 0123 //! Returns the count of recorded Commands 0124 Standard_EXPORT int NbCommands() const; 0125 0126 //! Returns a recorded Command, given its rank (from 1) 0127 Standard_EXPORT const TCollection_AsciiString& Command(const int num) const; 0128 0129 //! Allows to associate a Transient Value with the last execution 0130 //! as a partial result 0131 //! Returns RetDone if item is not Null, RetFail if item is Null 0132 //! Remark : it is nullified for each Perform 0133 Standard_EXPORT IFSelect_ReturnStatus RecordItem(const occ::handle<Standard_Transient>& item); 0134 0135 //! Returns the Transient Object which was recorded with the 0136 //! current Line Command. If none was, returns a Null Handle 0137 Standard_EXPORT occ::handle<Standard_Transient> RecordedItem() const; 0138 0139 //! Clears the recorded information (commands, objects) 0140 Standard_EXPORT void Clear(); 0141 0142 //! Reads commands from a Script File, named <file>. By default 0143 //! (file = ""), reads from standard input with a prompt 0144 //! Else (reading from a file), the read commands are displayed 0145 //! onto standard output. Allows nested reads. Reading is stopped 0146 //! either by command x or exit, or by reaching end of file 0147 //! Return Value follows the rules of Do : RetEnd for normal end, 0148 //! RetFail if script could not be opened 0149 Standard_EXPORT IFSelect_ReturnStatus ReadScript(const char* const file = ""); 0150 0151 //! Executes the Command, itself (for built-in commands, which 0152 //! have priority) or by using the list of Activators. 0153 //! The value returned is : RetVoid if nothing done (void command) 0154 //! RetDone if execution OK, RetEnd if END OF SESSION, RetError if 0155 //! command unknown or incorrect, RetFail if error on execution 0156 //! If execution is OK and RecordMode is set, this Command Line is 0157 //! recorded to the list (see below). 0158 Standard_EXPORT IFSelect_ReturnStatus Perform(); 0159 0160 //! Executes the Commands, except that the command name (word 0) 0161 //! is aliased. The rest of the command line is unchanged 0162 //! If <alias> is empty, Executes with no change 0163 //! 0164 //! Error status is returned if the alias is unknown as command 0165 Standard_EXPORT IFSelect_ReturnStatus ExecuteAlias(const TCollection_AsciiString& aliasname); 0166 0167 //! Sets the Command then tries to execute it. Return value : 0168 //! same as for Perform 0169 Standard_EXPORT IFSelect_ReturnStatus Execute(const TCollection_AsciiString& command); 0170 0171 //! Executes a Counter in a general way 0172 //! If <numword> is greater than count of command words, it counts 0173 //! all the model. Else it considers the word <numword> as the 0174 //! identifier of a Selection 0175 //! <mode> gives the mode of printing results, default is 0176 //! CountByItem 0177 Standard_EXPORT IFSelect_ReturnStatus 0178 ExecuteCounter(const occ::handle<IFSelect_SignCounter>& counter, 0179 const int numword, 0180 const IFSelect_PrintCount mode = IFSelect_CountByItem); 0181 0182 //! Interprets a string value as an entity number : 0183 //! if it gives an integer, returns its value 0184 //! else, considers it as ENtityLabel (preferably case sensitive) 0185 //! in case of failure, returns 0 0186 Standard_EXPORT int Number(const char* const val) const; 0187 0188 //! Processes specific commands, which are : 0189 //! x or exit for end of session 0190 //! ? or help for help messages 0191 //! xcommand to control command lines (Record Mode, List, Clear, 0192 //! File Output ...) 0193 //! xsource to execute a command file (no nesting allowed), 0194 //! in case of error, source is stopped and keyword recovers 0195 //! xstep is a simple prefix (useful in a wider environment, to 0196 //! avoid conflicts on command names) 0197 //! xset control commands which create items with names 0198 Standard_EXPORT IFSelect_ReturnStatus 0199 Do(const int number, const occ::handle<IFSelect_SessionPilot>& session) override; 0200 0201 //! Help for specific commands (apart from general command help) 0202 Standard_EXPORT const char* Help(const int number) const override; 0203 0204 DEFINE_STANDARD_RTTIEXT(IFSelect_SessionPilot, IFSelect_Activator) 0205 0206 private: 0207 occ::handle<IFSelect_WorkSession> thesession; 0208 TCollection_AsciiString theprompt; 0209 TCollection_AsciiString thecommand; 0210 int thenbwords; 0211 NCollection_Array1<TCollection_AsciiString> thewords; 0212 NCollection_Array1<int> thewordeb; 0213 bool therecord; 0214 int thenumrec; 0215 occ::handle<Standard_Transient> theobjrec; 0216 NCollection_Sequence<TCollection_AsciiString> thecomlist; 0217 }; 0218 0219 #endif // _IFSelect_SessionPilot_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|