0026781: Coding rules - eliminate GCC warning -Wunused-result
[occt.git] / src / IFSelect / IFSelect_Editor.hxx
1 // Created on: 1998-02-23
2 // Created by: Christian CAILLET
3 // Copyright (c) 1998-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_Editor_HeaderFile
18 #define _IFSelect_Editor_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Integer.hxx>
24 #include <TColStd_Array1OfTransient.hxx>
25 #include <TColStd_Array1OfAsciiString.hxx>
26 #include <TColStd_Array1OfInteger.hxx>
27 #include <MMgt_TShared.hxx>
28 #include <Standard_CString.hxx>
29 #include <IFSelect_EditValue.hxx>
30 #include <Standard_Boolean.hxx>
31 #include <TColStd_HSequenceOfHAsciiString.hxx>
32 class Dico_DictionaryOfInteger;
33 class Standard_OutOfRange;
34 class Interface_TypedValue;
35 class Message_Messenger;
36 class TCollection_AsciiString;
37 class IFSelect_EditForm;
38 class TCollection_HAsciiString;
39 class IFSelect_ListEditor;
40 class Standard_Transient;
41 class Interface_InterfaceModel;
42
43
44 class IFSelect_Editor;
45 DEFINE_STANDARD_HANDLE(IFSelect_Editor, MMgt_TShared)
46
47 //! An Editor defines a set of values and a way to edit them, on
48 //! an entity or on the model (e.g. on its header)
49 //!
50 //! Each Value is controlled by a TypedValue, with a number (it is
51 //! an Integer) and a name under two forms (complete and short)
52 //! and an edit mode
53 class IFSelect_Editor : public MMgt_TShared
54 {
55
56 public:
57
58   
59   //! Sets a Typed Value for a given ident and short name, with an
60   //! Edit Mode
61   Standard_EXPORT void SetValue (const Standard_Integer num, const Handle(Interface_TypedValue)& typval, const Standard_CString shortname = "", const IFSelect_EditValue accessmode = IFSelect_Editable);
62   
63   //! Sets a parameter to be a List
64   //! max < 0 : not for a list (set when starting)
65   //! max = 0 : list with no length limit (default for SetList)
66   //! max > 0 : list limited to <max> items
67   Standard_EXPORT void SetList (const Standard_Integer num, const Standard_Integer max = 0);
68   
69   //! Returns the count of Typed Values
70   Standard_EXPORT Standard_Integer NbValues() const;
71   
72   //! Returns a Typed Value from its ident
73   Standard_EXPORT Handle(Interface_TypedValue) TypedValue (const Standard_Integer num) const;
74   
75   //! Tells if a parameter is a list
76   Standard_EXPORT Standard_Boolean IsList (const Standard_Integer num) const;
77   
78   //! Returns max length allowed for a list
79   //! = 0 means : list with no limit
80   //! < 0 means : not a list
81   Standard_EXPORT Standard_Integer MaxList (const Standard_Integer num) const;
82   
83   //! Returns the name of a Value (complete or short) from its ident
84   //! Short Name can be empty
85   Standard_EXPORT Standard_CString Name (const Standard_Integer num, const Standard_Boolean isshort = Standard_False) const;
86   
87   //! Returns the edit mode of a Value
88   Standard_EXPORT IFSelect_EditValue EditMode (const Standard_Integer num) const;
89   
90   //! Returns the number (ident) of a Value, from its name, short or
91   //! complete. If not found, returns 0
92   Standard_EXPORT Standard_Integer NameNumber (const Standard_CString name) const;
93   
94   Standard_EXPORT void PrintNames (const Handle(Message_Messenger)& S) const;
95   
96   Standard_EXPORT void PrintDefs (const Handle(Message_Messenger)& S, const Standard_Boolean labels = Standard_False) const;
97   
98   //! Returns the MaxLength of, according to what :
99   //! <what> = -1 : length of short names
100   //! <what> =  0 : length of complete names
101   //! <what> =  1 : length of values labels
102   Standard_EXPORT Standard_Integer MaxNameLength (const Standard_Integer what) const;
103   
104   //! Returns the specific label
105   Standard_EXPORT virtual TCollection_AsciiString Label() const = 0;
106   
107   //! Builds and Returns an EditForm, empty (no data yet)
108   //! Can be redefined to return a specific type of EditForm
109   Standard_EXPORT virtual Handle(IFSelect_EditForm) Form (const Standard_Boolean readonly, const Standard_Boolean undoable = Standard_True) const;
110   
111   //! Tells if this Editor can work on this EditForm and its content
112   //! (model, entity ?)
113   Standard_EXPORT virtual Standard_Boolean Recognize (const Handle(IFSelect_EditForm)& form) const = 0;
114   
115   //! Returns the value of an EditForm, for a given item
116   //! (if not a list. for a list, a Null String may be returned)
117   Standard_EXPORT virtual Handle(TCollection_HAsciiString) StringValue (const Handle(IFSelect_EditForm)& form, const Standard_Integer num) const = 0;
118   
119   //! Returns a ListEditor for a parameter which is a List
120   //! Default returns a basic ListEditor for a List, a Null Handle
121   //! if <num> is not for a List. Can be redefined
122   Standard_EXPORT virtual Handle(IFSelect_ListEditor) ListEditor (const Standard_Integer num) const;
123   
124   //! Returns the value of an EditForm as a List, for a given item
125   //! If not a list, a Null Handle should be returned
126   //! Default returns a Null Handle, because many Editors have
127   //! no list to edit. To be redefined as required
128   Standard_EXPORT virtual Handle(TColStd_HSequenceOfHAsciiString) ListValue (const Handle(IFSelect_EditForm)& form, const Standard_Integer num) const;
129   
130   //! Loads original values from some data, to an EditForm
131   //! Remark: <ent> may be Null, this means all <model> is concerned
132   //! Also <model> may be Null, if no context applies for <ent>
133   //! And both <ent> and <model> may be Null, for a full static
134   //! editor
135   Standard_EXPORT virtual Standard_Boolean Load (const Handle(IFSelect_EditForm)& form, const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model) const = 0;
136   
137   //! Updates the EditForm when a parameter is modified
138   //! I.E.  default does nothing, can be redefined, as follows :
139   //! Returns True when done (even if does nothing), False in case
140   //! of refuse (for instance, if the new value is not suitable)
141   //! <num> is the rank of the parameter for the EDITOR itself
142   //! <enforce> True means that protected parameters can be touched
143   //!
144   //! If a parameter commands the value of other ones, when it is
145   //! modified, it is necessary to touch them by Touch from EditForm
146   Standard_EXPORT virtual Standard_Boolean Update (const Handle(IFSelect_EditForm)& form, const Standard_Integer num, const Handle(TCollection_HAsciiString)& newval, const Standard_Boolean enforce) const;
147   
148   //! Acts as Update, but when the value is a list
149   Standard_EXPORT virtual Standard_Boolean UpdateList (const Handle(IFSelect_EditForm)& form, const Standard_Integer num, const Handle(TColStd_HSequenceOfHAsciiString)& newlist, const Standard_Boolean enforce) const;
150   
151   //! Applies modified values of the EditForm with some data
152   //! Remark: <ent> may be Null, this means all <model> is concerned
153   //! Also <model> may be Null, if no context applies for <ent>
154   //! And both <ent> and <model> may be Null, for a full static
155   //! editor
156   Standard_EXPORT virtual Standard_Boolean Apply (const Handle(IFSelect_EditForm)& form, const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model) const = 0;
157
158
159
160
161   DEFINE_STANDARD_RTTI(IFSelect_Editor,MMgt_TShared)
162
163 protected:
164
165   
166   //! Prepares the list of Typed Values (gives its count)
167   //! This count can be tuned later, to a LOWER value, this allows
168   //! to initialize with a "maximum reservation" then cut the extra
169   Standard_EXPORT IFSelect_Editor(const Standard_Integer nbval);
170   
171   //! Adjusts the true count of values. It can be LOWER or equal to
172   //! the initial size (which then acts as a reservation), but never
173   //! greater
174   Standard_EXPORT void SetNbValues (const Standard_Integer nbval);
175
176
177
178 private:
179
180
181   Standard_Integer thenbval;
182   Standard_Integer themaxsh;
183   Standard_Integer themaxco;
184   Standard_Integer themaxla;
185   Handle(Dico_DictionaryOfInteger) thenames;
186   TColStd_Array1OfTransient thevalues;
187   TColStd_Array1OfAsciiString theshorts;
188   TColStd_Array1OfInteger themodes;
189   TColStd_Array1OfInteger thelists;
190
191
192 };
193
194
195
196
197
198
199
200 #endif // _IFSelect_Editor_HeaderFile