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
6 -- This file is part of Open CASCADE Technology software library.
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.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 generic class Library from LibCtl
19 TheModule as Transient;
20 TheProtocol as Transient) -- must comply with Protocol template
22 ---Purpose : Manages a list of Execution Modules attached to Protocols
23 -- to perform a specific set of functionnalities.
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).
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.
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.
40 -- -- Nested class : Node of Module -- --
42 private class GlobalNode inherits Transient
43 ---Purpose : Manages a (possibly static) Global List of Modules bound to
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
52 Create returns GlobalNode;
53 ---Purpose : Creates an empty GlobalNode, with no Next
55 Add (me : mutable; amodule : TheModule; aprotocol : TheProtocol)
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
62 Module (me) returns any TheModule is static;
63 ---Purpose : Returns the Module stored in a given GlobalNode
64 ---C++ : return const &
66 Protocol (me) returns any TheProtocol is static;
67 ---Purpose : Returns the attached Protocol stored in a given GlobalNode
68 ---C++ : return const &
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 &
78 theprot : TheProtocol;
84 private class Node inherits TShared
86 ---Purpose : Manages a list of Modules for a Library (as an instance) :
87 -- Designates a GlobalNode (couple Module-Protocol)
92 ---Purpose : Creates an empty Node, with no Next
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
98 Module (me) returns any TheModule is static;
99 ---Purpose : Returns the Module designated by a precise Node
100 ---C++ : return const &
102 Protocol (me) returns any TheProtocol is static;
103 ---Purpose : Returns the Protocol designated by a precise Node
104 ---C++ : return const &
106 Next (me) returns Node is static;
107 ---Purpose : Returns the Next Node. If none was defined, returned value
109 ---C++ : return const &
113 thenode : GlobalNode;
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.
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
131 Create returns Library;
132 ---Purpose : Creates an empty Library : it will later by filled by method
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)
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)
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)
150 Select (me; obj : any TheObject; module : out any TheModule; CN : out Integer)
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)
160 Start (me : in out) is static;
161 ---Purpose : Starts Iteration on the Modules (sets it on the first one)
163 More (me) returns Boolean is static;
164 ---Purpose : Returns True if there are more Modules to iterate on
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
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 &
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 &
185 thecurr : Node; -- for iteration
186 -- there are also "class variables" which describe global set