0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / IFSelect / IFSelect_Activator.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-07-27
2// Created by: Christian CAILLET
3// Copyright (c) 1993-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _IFSelect_Activator_HeaderFile
18#define _IFSelect_Activator_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TCollection_AsciiString.hxx>
24#include <MMgt_TShared.hxx>
25#include <Standard_Integer.hxx>
26#include <Standard_CString.hxx>
27#include <Standard_Boolean.hxx>
28#include <TColStd_HSequenceOfAsciiString.hxx>
29#include <IFSelect_ReturnStatus.hxx>
30class Standard_DomainError;
31class TCollection_AsciiString;
32class IFSelect_SessionPilot;
33
34
35class IFSelect_Activator;
36DEFINE_STANDARD_HANDLE(IFSelect_Activator, MMgt_TShared)
37
38//! Defines the general frame for working with a SessionPilot.
39//! Each Activator treats a set of Commands. Commands are given as
40//! alphanumeric strings. They can be of two main forms :
41//! - classic, to list, evaluate, enrich the session (by itself) :
42//! no specific remark, its complete execution must be described
43//! - creation of a new item : instead of creatinf it plus adding
44//! it to the session (which is a classic way), it is possible
45//! to create it and make it recorded by the SessionPilot :
46//! then, the Pilot will add it to the session; this way allows
47//! the Pilot to manage itself named items
48//!
49//! In order to make easier the use of Activator, this class
50//! provides a simple way to Select an Actor for a Command :
51//! each sub-class of SectionActor defines the command titles it
52//! recognizes, plus attaches a Number, unique for this sub-class,
53//! to each distinct command title.
54//!
55//! Each time an action is required, the corresponding Number
56//! can then be given to help the selection of the action to do.
57//!
58//! The result of an Execution must indicate if it is worth to be
59//! recorded or not : see method Do
60class IFSelect_Activator : public MMgt_TShared
61{
62
63public:
64
65
66 //! Records, in a Dictionary available for all the Activators,
67 //! the command title an Activator can process, attached with
68 //! its number, proper for this Activator
69 //! <mode> allows to distinguish various execution modes
70 //! 0: default mode; 1 : for xset
71 Standard_EXPORT static void Adding (const Handle(IFSelect_Activator)& actor, const Standard_Integer number, const Standard_CString command, const Standard_Integer mode);
72
73 //! Allows a self-definition by an Activator of the Commands it
74 //! processes, call the class method Adding (mode 0)
75 Standard_EXPORT void Add (const Standard_Integer number, const Standard_CString command) const;
76
77 //! Same as Add but specifies that this command is candidate for
78 //! xset (creation of items, xset : named items; mode 1)
79 Standard_EXPORT void AddSet (const Standard_Integer number, const Standard_CString command) const;
80
81 //! Removes a Command, if it is recorded (else, does nothing)
82 Standard_EXPORT static void Remove (const Standard_CString command);
83
84 //! Records, for a configuration named <conf>, that the command
85 //! <command> may be aliased by another command <alias>
86 //!
87 //! To be used by call to Alias (no automatic redirection)
88 //! The configuration typically refers to a norm
89 Standard_EXPORT static void SetAlias (const Standard_CString conf, const Standard_CString command, const Standard_CString aliasname);
90
91 //! Sets <conf> as current configuration for aliases
92 Standard_EXPORT static void SetCurrentAlias (const Standard_CString conf);
93
94 //! Returns, in the current configuration, what alias has been
95 //! recorded for <command>
96 //! The returned string is empty if no alias is recorded
97 Standard_EXPORT static TCollection_AsciiString Alias (const Standard_CString command);
98
99 //! Selects, for a Command given by its title, an actor with its
100 //! command number. Returns True if found, False else
101 Standard_EXPORT static Standard_Boolean Select (const Standard_CString command, Standard_Integer& number, Handle(IFSelect_Activator)& actor);
102
103 //! Returns mode recorded for a command. -1 if not found
104 Standard_EXPORT static Standard_Integer Mode (const Standard_CString command);
105
106 //! Returns, for a root of command title, the list of possible
107 //! commands.
108 //! <mode> : -1 (D) for all commands if <commands> is empty
109 //! -1 + command : about a Group , >= 0 see Adding
110 //! By default, it returns the whole list of known commands.
111 Standard_EXPORT static Handle(TColStd_HSequenceOfAsciiString) Commands (const Standard_Integer mode = -1, const Standard_CString command = "");
112
113 //! Tries to execute a Command Line. <number> is the number of the
114 //! command for this Activator. It Must forecast to record the
115 //! result of the execution, for need of Undo-Redo
116 //! Must Returns : 0 for a void command (not to be recorded),
117 //! 1 if execution OK, -1 if command incorrect, -2 if error
118 //! on execution
119 Standard_EXPORT virtual IFSelect_ReturnStatus Do (const Standard_Integer number, const Handle(IFSelect_SessionPilot)& pilot) = 0;
120
121 //! Sends a short help message for a given command identified by
122 //! it number for this Activator (must take one line max)
123 Standard_EXPORT virtual Standard_CString Help (const Standard_Integer number) const = 0;
124
125 Standard_EXPORT Standard_CString Group() const;
126
127 Standard_EXPORT Standard_CString File() const;
128
129 //! Group and SetGroup define a "Group of commands" which
130 //! correspond to an Activator. Default is "XSTEP"
131 //! Also a file may be attached
132 Standard_EXPORT void SetForGroup (const Standard_CString group, const Standard_CString file = "");
133
134
135
136
137 DEFINE_STANDARD_RTTI(IFSelect_Activator,MMgt_TShared)
138
139protected:
140
141
142 //! Sets the default values
143 Standard_EXPORT IFSelect_Activator();
144
145
146
147private:
148
149
150 TCollection_AsciiString thegroup;
151 TCollection_AsciiString thefile;
152
153
154};
155
156
157
158
159
160
161
162#endif // _IFSelect_Activator_HeaderFile