-- File: WorkSession.cdl -- Created: Tue Dec 15 15:37:42 1992 -- Author: Christian CAILLET -- ---Copyright: Matra Datavision 1992 class WorkSession from IFSelect inherits TShared ---Purpose : This class can be used to simply manage a process such as -- splitting a file, extracting a set of Entities ... -- It allows to manage different types of Variables : Integer or -- Text Parameters, Selections, Dispatches, in addition to a -- ShareOut. To each of these variables, a unique Integer -- Identifier is attached. A Name can be attached too as desired. uses CString, AsciiString from TCollection, HAsciiString from TCollection, Messenger from Message, SequenceOfHAsciiString from TColStd, HSequenceOfHAsciiString from TColStd, DictionaryOfInteger from Dico, Type, SequenceOfTransient from TColStd, SequenceOfInteger from TColStd, HSequenceOfInteger from TColStd, HArray1OfInteger from TColStd, DictionaryOfTransient from Dico, IndexedDataMapOfTransientTransient, Transient, HSequenceOfTransient from TColStd, InterfaceModel from Interface, EntityIterator from Interface, Protocol from Interface, HGraph from Interface, Graph from Interface, CheckIterator from Interface, GTool from Interface, ShareOut, IntParam, Signature, Selection, Dispatch, WorkLibrary, ModelCopier, GeneralModifier, Modifier, Transformer, SelectionIterator, PacketList, SignatureList, SignCounter, ReturnStatus, RemainMode, PrintCount raises DomainError is -- -- General Management -- -- Create returns mutable WorkSession; ---Purpose : Creates a Work Session -- It provides default, empty ShareOut and ModelCopier, which can -- be replaced (if required, should be done just after creation). SetErrorHandle (me : mutable; hand : Boolean); ---Purpose : Changes the Error Handler status (by default, it is not set) ErrorHandle (me) returns Boolean; ---Purpose : Returns the Error Handler status ShareOut (me) returns mutable ShareOut; ---Purpose : Returns the ShareOut defined at creation time ---C++ : return const & SetShareOut (me : mutable; shareout : mutable ShareOut); ---Purpose : Sets a new ShareOut. Fills Items which its content -- Warning : data from the former ShareOut are lost SetModeStat(me : mutable; theMode : Boolean); ---Purpose : Set value of mode responsible for precence of selections after loading -- If mode set to true that different selections will be accessible after loading -- else selections will be not accessible after loading( for economy memory in applicatios) GetModeStat(me) returns Boolean from Standard; ---Purpose : Return value of mode defining of filling selection during loading SetLibrary (me : mutable; lib : WorkLibrary); ---Purpose : Sets a WorkLibrary, which will be used to Read and Write Files WorkLibrary (me) returns WorkLibrary; ---Purpose : Returns the WorkLibrary. Null Handle if not yet set -- should be C++ : return const & SetProtocol (me : mutable; protocol : Protocol from Interface); ---Purpose : Sets a Protocol, which will be used to determine Graphs, to -- Read and to Write Files Protocol (me) returns Protocol; ---Purpose : Returns the Protocol. Null Handle if not yet set -- should be C++ : return const & SetSignType (me : mutable; signtype : Signature); ---Purpose : Sets a specific Signature to be the SignType, i.e. the -- Signature which will determine TypeName from the Model -- (basic function). It is recorded in the GTool -- This Signature is also set as "xst-sign-type" (reserved name) -- SignType (me) returns Signature; ---Purpose : Returns the current SignType HasModel (me) returns Boolean; ---Purpose : Returns True is a Model has been set SetModel (me : mutable; model : InterfaceModel; clearpointed : Boolean = Standard_True); ---Purpose : Sets a Model as input : this will be the Model from which the -- ShareOut will work -- if is True (default) all SelectPointed items -- are cleared, else they must be managed by the caller -- Remark : SetModel clears the Graph, recomputes it if a -- Protocol is set and if the Model is not empty, of course Model (me) returns InterfaceModel; ---Purpose : Returns the Model of the Work Session (Null Handle if none) -- should be C++ : return const & SetLoadedFile (me : mutable; filename : CString); ---Purpose : Stores the filename used for read for setting the model -- It is cleared by SetModel and ClearData(1) LoadedFile (me) returns CString; ---Purpose : Returns the filename used to load current model -- empty if unknown ReadFile (me : mutable; filename : CString) returns ReturnStatus; ---Purpose : Reads a file with the WorkLibrary (sets Model and LoadedFile) -- Returns a integer status which can be : -- RetDone if OK, RetVoid if no Protocol not defined, -- RetError for file not found, RetFail if fail during read NbStartingEntities (me) returns Integer; ---Purpose : Returns the count of Entities stored in the Model, or 0 StartingEntity (me; num : Integer) returns Transient; ---Purpose : Returns an Entity stored in the Model of the WorkSession -- (Null Handle is no Model or num out of range) StartingNumber (me; ent : Transient) returns Integer; ---Purpose : Returns the Number of an Entity in the Model -- (0 if no Model set or not in the Model) NumberFromLabel (me; val : CString; afternum : Integer= 0) returns Integer; ---Purpose : From a given label in Model, returns the corresponding number -- Starts from first entity by Default, may start after a given -- number : this number may be given negative, its absolute value -- is then considered. Hence a loop on NumberFromLabel may be -- programmed (stop test is : returned value positive or null) -- -- Returns 0 if not found, < 0 if more than one found (first -- found in negative). -- If just gives an integer value, returns it EntityLabel (me; ent : Transient) returns HAsciiString from TCollection; ---Purpose : Returns the label for , as the Model does -- If is not in the Model or if no Model is loaded, a Null -- Handle is returned EntityName (me; ent : Transient) returns HAsciiString from TCollection; ---Purpose : Returns the Name of an Entity -- This Name is computed by the general service Name -- Returns a Null Handle if fails CategoryNumber (me; ent : Transient) returns Integer; ---Purpose : Returns the Category Number determined for an entity -- it is computed by the class Category -- An unknown entity (number 0) gives a value -1 CategoryName (me; ent : Transient) returns CString; ---Purpose : Returns the Category Name determined for an entity -- it is computed by the class Category -- Remark : an unknown entity gives an empty string ValidityName (me; ent : Transient) returns CString; ---Purpose : Returns the Validity Name determined for an entity -- it is computed by the class SignValidity -- Remark : an unknown entity gives an empty string ClearData (me : mutable; mode : Integer) is virtual; ---Purpose : Clears recorded data (not the items) according mode : -- 1 : all Data : Model, Graph, CheckList, + ClearData 4 -- 2 : Graph and CheckList (they will then be recomputed later) -- 3 : CheckList (it will be recomputed by ComputeCheck) -- 4 : just content of SelectPointed and Counters -- Plus 0 : does nothing but called by SetModel -- ClearData is virtual, hence it can be redefined to clear -- other data of a specialised Work Session ComputeGraph (me : mutable; enforce : Boolean = Standard_False) returns Boolean; ---Purpose : Computes the Graph used for Selections, Displays ... -- If a HGraph is already set, with same model as given by method -- Model, does nothing. Else, computes a new Graph. -- If is given True, computes a new Graph anyway. -- Remark that a call to ClearGraph will cause ComputeGraph to -- really compute a new Graph -- Returns True if Graph is OK, False else (i.e. if no Protocol -- is set, or if Model is absent or empty). HGraph (me : mutable) returns HGraph; ---Purpose : Returns the Computed Graph as HGraph (Null Handle if not set) Graph (me : mutable) returns Graph ---Purpose : Returns the Computed Graph, for Read only raises DomainError; -- Error if the Graph is not available ---C++ : return const & Shareds (me : mutable; ent : Transient) returns HSequenceOfTransient; ---Purpose : Returns the list of entities shared by (can be empty) -- Returns a null Handle if is unknown Sharings (me : mutable; ent : Transient) returns HSequenceOfTransient; ---Purpose : Returns the list of entities sharing (can be empty) -- Returns a null Handle if is unknown IsLoaded (me) returns Boolean; ---Purpose : Returns True if a Model is defined and really loaded (not -- empty), a Protocol is set and a Graph has been computed. -- In this case, the WorkSession can start to work ComputeCheck (me : mutable; enforce : Boolean = Standard_False) returns Boolean; ---Purpose : Computes the CheckList for the Model currently loaded -- It can then be used for displays, querries ... -- Returns True if OK, False else (i.e. no Protocol set, or Model -- absent). If is False, works only if not already done -- or if a new Model has been loaded from last call. -- Remark : computation is enforced by every call to -- SetModel or RunTransformer ModelCheckList (me : mutable; complete : Boolean = Standard_True) returns CheckIterator; ---Purpose : Returns the Check List for the Model currently loaded : -- = True : complete (syntactic & semantic messages), -- computed if not yet done -- = False : only syntactic (check file form) CheckOne (me : mutable; ent : Transient; complete : Boolean = Standard_True) returns CheckIterator; ---Purpose : Returns a Check for a single entity, under the form of a -- CheckIterator (this gives only one form for the user) -- if is Null or equates the current Model, it gives the -- Global Check, else the Check for the given entity -- as for ModelCheckList LastRunCheckList (me) returns CheckIterator; ---Purpose : Returns the Check List produced by the last execution of -- either : EvaluateFile(for Split), SendSplit, SendAll, -- SendSelected, RunTransformer-RunModifier -- Cleared by SetModel or ClearData(1) -- The field is protected, hence a specialized WorkSession may -- fill it -- -- General Management on Items (and Names) -- -- MaxIdent (me) returns Integer; ---Purpose : Returns the Maximum Value for an Item Identifier. It can be -- greater to the count of known Items, because some can have -- been removed Item (me; id : Integer) returns mutable Transient; ---Purpose : Returns an Item, given its Ident. Returns a Null Handle if -- no Item corresponds to this Ident. ItemIdent (me; item : Transient) returns Integer; ---Purpose : Returns the Ident attached to an Item in the WorkSession, or -- Zero if it is unknown NamedItem (me; name : CString) returns mutable Transient; ---Purpose : Returns the Item which corresponds to a Variable, given its -- Name (whatever the type of this Item). -- Returns a Null Handle if this Name is not recorded NamedItem (me; name : HAsciiString from TCollection) returns mutable Transient; ---Purpose : Same as above, but is given through a Handle -- Especially Usefull with methods SelectionNames, etc... NameIdent (me; name : CString) returns Integer; ---Purpose : Returns the Ident attached to a Name, 0 if name not recorded HasName (me; item : Transient) returns Boolean; ---Purpose : Returns True if an Item of the WorkSession has an attached Name Name (me; item : Transient) returns HAsciiString from TCollection; ---Purpose : Returns the Name attached to an Item as a Variable of this -- WorkSession. If is Null or not recorded, returns an -- empty string. AddItem (me : mutable; item : mutable Transient; active : Boolean = Standard_True) returns Integer; ---Purpose : Adds an Item and returns its attached Ident. Does nothing -- if is already recorded (and returns its attached Ident) -- if True commands call to SetActive (see below) -- Remark : the determined Ident is used if is a Dispatch, -- to fill the ShareOut AddNamedItem (me : mutable; name : CString; item : mutable Transient; active : Boolean = Standard_True) returns Integer; ---Purpose : Adds an Item with an attached Name. If the Name is already -- known in the WorkSession, the older item losts it -- Returns Ident if Done, 0 else, i.e. if is null -- If is empty, works as AddItem (i.e. with no name) -- If is already known but with no attached Name, this -- method tries to attached a Name to it -- if True commands call to SetActive (see below) SetActive (me : mutable; item : mutable Transient; mode : Boolean) returns Boolean; ---Purpose : Following the type of : -- - Dispatch : Adds or Removes it in the ShareOut & FileNaming -- - GeneralModifier : Adds or Removes it for final sending -- (i.e. in the ModelCopier) -- Returns True if it did something, False else (state unchanged) RemoveNamedItem (me : mutable; name : CString) returns Boolean; ---Purpose : Removes an Item from the Session, given its Name -- Returns True if Done, False else (Name not recorded) -- (Applies only on Item which are Named) RemoveName (me : mutable; name : CString) returns Boolean; ---Purpose : Removes a Name without removing the Item -- Returns True if Done, False else (Name not recorded) RemoveItem (me : mutable; item : Transient) returns Boolean; ---Purpose : Removes an Item given its Ident. Returns False if is -- attached to no Item in the WorkSession. For a Named Item, -- also removes its Name. ClearItems (me : mutable); ---Purpose : Clears all the recorded Items : Selections, Dispatches, -- Modifiers, and Strings & IntParams, with their Idents & Names. -- Remark that if a Model has been loaded, it is not cleared. ItemLabel (me; id : Integer) returns HAsciiString from TCollection; ---Purpose : Returns a Label which illustrates the content of an Item, -- given its Ident. This Label is : -- - for a Text Parameter, "Text:" -- - for an Integer Parameter, "Integer:" -- - for a Selection, a Dispatch or a Modifier, its Label -- (see these classes) -- - for any other kind of Variable, its cdl type ItemIdents (me; type : Type) returns HSequenceOfInteger from TColStd; ---Purpose : Fills a Sequence with the List of Idents attached to the Items -- of which Type complies with (IsKind) (alphabetic order) -- Remark : = TYPE(Standard_Transient) gives all the -- Idents which are suitable in the WorkSession ItemNames (me; type : Type) returns HSequenceOfHAsciiString from TColStd; ---Purpose : Fills a Sequence with the list of the Names attached to Items -- of which Type complies with (IsKind) (alphabetic order) -- Remark : = TYPE(Standard_Transient) gives all the Names ItemNamesForLabel (me; label : CString) returns HSequenceOfHAsciiString; ---Purpose : Fills a Sequence with the NAMES of the control items, of which -- the label matches