0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / LibCtl / LibCtl_Library.cdl
1 -- Created on: 1993-01-29
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 generic class Library  from LibCtl
18         (TheObject   as any;
19          TheModule   as Transient;
20          TheProtocol as Transient)    -- must comply with Protocol template
21
22     ---Purpose : Manages a list of Execution Modules attached to Protocols
23     --           to perform a specific set of functionnalities.
24     --           
25     --           Each instantiated class of Library has a global set a Modules.
26     --           These Modules are put in this set before working, for instance
27     --           by static construction (using method SetGlobal). One Module
28     --           is bound which each Protocol (considered as a class).
29     --           
30     --           To work, a Library is created by taking the Modules which
31     --           comply with a Protocol (bound with its class and the classes
32     --           of its Resources), given as parameter of its creation.
33     --           
34     --           Thus, any tool can use it to get the suitable Modules
35     ---Warning : The order of the Modules in the Library has assumed to be
36     --           useless, and is not managed.
37
38 raises NoSuchObject
39
40         -- --    Nested class : Node of Module    -- --
41
42     private class GlobalNode  inherits Transient
43     ---Purpose : Manages a (possibly static) Global List of Modules bound to
44     --           Protocols.
45     --           Remark that it requires independance from Memory Management
46     --           (because a Global List of Modules can be build through static
47     --           declarations, i.e. before any sequential execution)
48     --           Remark there will not be many many GlobalNodes created
49
50     is
51     
52         Create returns GlobalNode;
53         ---Purpose : Creates an empty GlobalNode, with no Next
54
55         Add (me : mutable; amodule : TheModule; aprotocol : TheProtocol)
56             is static;
57         ---Purpose : Adds a Module bound with a Protocol to the list : does
58         --           nothing if already in the list, THAT IS, Same Type (exact
59         --           match) and Same State (that is, IsEqual is not required)
60         --           Once added, stores its attached Protocol in correspondance
61
62         Module (me) returns any TheModule  is static;
63         ---Purpose : Returns the Module stored in a given GlobalNode
64         ---C++ : return const &
65
66         Protocol (me) returns any TheProtocol  is static;
67         ---Purpose : Returns the attached Protocol stored in a given GlobalNode
68         ---C++ : return const &
69
70         Next (me) returns any GlobalNode  is static;
71         ---Purpose : Returns the Next GlobalNode. If none is defined, returned
72         --           value is a Null Handle
73         ---C++ : return const &
74
75     fields
76
77         themod  : TheModule;
78         theprot : TheProtocol;
79         thenext : GlobalNode;
80
81     end GlobalNode;
82
83
84     private class Node  inherits TShared
85
86     ---Purpose : Manages a list of Modules for a Library (as an instance) :
87     --           Designates a GlobalNode (couple Module-Protocol)
88
89     is
90
91         Create returns Node;
92         ---Purpose : Creates an empty Node, with no Next
93
94         AddNode (me : mutable; anode : any GlobalNode)  is static;
95         ---Purpose : Adds a couple (Module,Protocol), that is, stores it into
96         --           itself if not yet done, else creates a Next Node to do it
97
98         Module (me) returns any TheModule  is static;
99         ---Purpose : Returns the Module designated by a precise Node
100         ---C++ : return const &
101
102         Protocol (me) returns any TheProtocol  is static;
103         ---Purpose : Returns the Protocol designated by a precise Node
104         ---C++ : return const &
105
106         Next (me) returns Node  is static;
107         ---Purpose : Returns the Next Node. If none was defined, returned value
108         --           is a Null Handle
109         ---C++ : return const &
110
111     fields
112
113         thenode : GlobalNode;
114         thenext : Node;
115
116     end Node;
117
118
119 is
120
121     SetGlobal (myclass; amodule : TheModule; aprotocol : TheProtocol);
122     ---Purpose : Adds a couple (Module-Protocol) into the global definition set
123     --           for this class of Library.
124
125     Create (aprotocol : TheProtocol) returns Library;
126     ---Purpose : Creates a Library which complies with a Protocol, that is :
127     --           Same class (criterium IsInstance)
128     --           This creation gets the Modules from the global set, those
129     --           which are bound to the given Protocol and its Resources
130
131     Create returns Library;
132     ---Purpose : Creates an empty Library : it will later by filled by method
133     --           AddProtocol
134
135     AddProtocol (me : in out; aprotocol : Transient)  is static;
136     ---Purpose : Adds a couple (Module-Protocol) to the Library, given the
137     --           class of a Protocol. Takes Resources into account.
138     --           (if <aprotocol> is not of type TheProtocol, it is not added)
139
140     Clear (me : in out)  is static;
141     ---Purpose : Clears the list of Modules of a library (can be used to
142     --           redefine the order of Modules before action : Clear then
143     --           refill the Library by calls to AddProtocol)
144
145     SetComplete (me : in out);
146     ---Purpose : Sets a library to be defined with the complete Global list
147     --           (all the couples Protocol/Modules recorded in it)
148
149
150     Select (me; obj : any TheObject; module : out any TheModule; CN : out Integer)
151         returns Boolean;
152     ---Purpose : Selects a Module from the Library, given an Object.
153     --           Returns True if Select has succeeded, False else.
154     --           Also Returns (as arguments) the selected Module and the Case
155     --           Number determined by the associated Protocol.
156     --           If Select has failed, <module> is Null Handle and CN is zero.
157     --           (Select can work on any criterium, such as Object DynamicType)
158
159
160     Start (me : in out)  is static;
161     ---Purpose : Starts Iteration on the Modules (sets it on the first one)
162
163     More (me) returns Boolean  is static;
164     ---Purpose : Returns True if there are more Modules to iterate on
165
166     Next (me : in out)  is static;
167     ---Purpose : Iterates by getting the next Module in the list
168     --           If there is none, the exception will be raised by Value
169
170     Module (me) returns any TheModule
171     ---Purpose : Returns the current Module in the Iteration
172         raises NoSuchObject  is static;
173     --           Error if there is no current Module to iterate on
174     ---C++ : return const &
175
176     Protocol (me) returns any TheProtocol
177     ---Purpose : Returns the current Protocol in the Iteration
178         raises NoSuchObject  is static;
179     --           Error if there is no current Protocol to iterate on
180     ---C++ : return const &
181
182 fields
183
184     thelist  : Node;
185     thecurr  : Node;         -- for iteration
186     -- there are also "class variables" which describe global set
187
188 end Library;