0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / AIS / AIS_Selection.hxx
1 // Created on: 1995-03-21
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1995-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 _AIS_Selection_HeaderFile
18 #define _AIS_Selection_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TCollection_AsciiString.hxx>
24 #include <AIS_NListTransient.hxx>
25 #include <AIS_NListIteratorOfListTransient.hxx>
26 #include <AIS_NDataMapOfTransientIteratorOfListTransient.hxx>
27 #include <Standard_Integer.hxx>
28 #include <MMgt_TShared.hxx>
29 #include <Standard_CString.hxx>
30 #include <Standard_Boolean.hxx>
31 #include <AIS_SelectStatus.hxx>
32 class Standard_NoSuchObject;
33 class Standard_MultiplyDefined;
34 class Standard_TypeMismatch;
35 class Standard_Transient;
36
37
38 class AIS_Selection;
39 DEFINE_STANDARD_HANDLE(AIS_Selection, MMgt_TShared)
40
41
42 class AIS_Selection : public MMgt_TShared
43 {
44
45 public:
46
47   
48   //! creates a new selection and make it current in the session.
49   //! the selection will be accessible later through its name
50   //! to make it again current.
51   //!
52   //! Note that if a session has been created, a session with
53   //! the name  "default" is created.
54   //!
55   //! In this case, the is always a current selection which
56   //! is the last one created  until SetCurrentSelection is used.
57   //!
58   //! The class methods deals with the current selection.
59   //!
60   //! Warning : Better Call AIS_Selection::CreateSelection.
61   Standard_EXPORT AIS_Selection(const Standard_CString aName);
62   
63   Standard_EXPORT static void Remove (const Standard_CString aName);
64   
65   //! returns True if a selection having this name exsits.
66   Standard_EXPORT static Standard_Boolean Find (const Standard_CString aName);
67   
68   //! calls the private constructor and puts the new Selection
69   //! in the list of existing selections.
70   //! returns False if the selection exists.
71   Standard_EXPORT static Standard_Boolean CreateSelection (const Standard_CString aName);
72   
73   Standard_EXPORT static Handle(AIS_Selection) Selection (const Standard_CString aName);
74   
75   //! returns False if There is no selection of name <aName>
76   Standard_EXPORT static Standard_Boolean SetCurrentSelection (const Standard_CString aName);
77   
78   Standard_EXPORT static Handle(AIS_Selection) CurrentSelection();
79   
80   //! Clears selection.
81   Standard_EXPORT static void ClearCurrentSelection();
82   
83   //! removes all the object of the currentselection.
84   Standard_EXPORT static void Select();
85   
86   //! if the object is not yet in the current selection, it will be added.
87   //! if the object is already in the current selection, it will be removed.
88   Standard_EXPORT static AIS_SelectStatus Select (const Handle(Standard_Transient)& anObject);
89   
90   //! the object is always add int the selection.
91   //! faster when the number of objects selected is great.
92   Standard_EXPORT static AIS_SelectStatus AddSelect (const Handle(Standard_Transient)& anObject);
93   
94   //! clears the selection and adds the object in the selection.
95   Standard_EXPORT static void ClearAndSelect (const Handle(Standard_Transient)& anObject);
96   
97   Standard_EXPORT static Standard_Boolean IsSelected (const Handle(Standard_Transient)& anObject);
98   
99   //! returns the number of objects selected.
100   Standard_EXPORT static Standard_Integer Extent();
101   
102   //! returns the single object selected.
103   //! Warning: raises TypeMismatch from Standard if Extent is not equal to 1.
104   Standard_EXPORT static Handle(Standard_Transient) Single();
105   
106     void Init();
107   
108     Standard_Boolean More() const;
109   
110     void Next();
111   
112     const Handle(Standard_Transient)& Value() const;
113   
114     Standard_Integer NbStored() const;
115   
116     const AIS_NListTransient& Objects() const;
117   
118   Standard_EXPORT static Standard_Integer Index (const Standard_CString aName);
119
120
121
122
123   DEFINE_STANDARD_RTTIEXT(AIS_Selection,MMgt_TShared)
124
125 protected:
126
127
128
129
130 private:
131
132
133   TCollection_AsciiString myName;
134   AIS_NListTransient myresult;
135   AIS_NListIteratorOfListTransient myIterator;
136   AIS_NDataMapOfTransientIteratorOfListTransient myResultMap;
137   Standard_Integer myNb;
138
139
140 };
141
142
143 #include <AIS_Selection.lxx>
144
145
146
147
148
149 #endif // _AIS_Selection_HeaderFile