1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

9
src/Interface/FILES Executable file
View File

@@ -0,0 +1,9 @@
Interface_Macros.hxx
Interface_Statics.hxx
Interface_StaticSatisfies.hxx
Interface_ValueInterpret.hxx
Interface_ValueSatisfies.hxx
Interface_Translates.hxx
Interface_StaticStandards.cxx
Interface_Version.hxx
Interface_VectorOfFileParameter.hxx

150
src/Interface/Interface.cdl Executable file
View File

@@ -0,0 +1,150 @@
-- File: Interface.cdl
-- Created: Mon Feb 3 10:34:50 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
package Interface
---Purpose : defines a general frame for interface data
-- used to manipulate results of normalized Interface outputs
-- (i.e. files), also as a basis to define transfer operations
-- (in other packages : see package Transfer)
uses LibCtl, TCollection, TColStd, MMgt, Standard, Dico, MoniTool, Message
is
deferred class InterfaceModel;
-- -- Data Definitions -- --
class UndefinedContent;
class ReportEntity;
class EntityList; -- for an (ordered) little list of Entities
private class EntityCluster; -- ancillary class for the former
generic class JaggedArray; -- to turn arround limitation on Array(Array)
-- -- Auxiliary Classes (results, working data) -- --
class IntVal;
class EntityIterator;
class Graph;
class GraphContent;
class HGraph;
class IntList;
class BitMap;
class Check;
class CheckIterator;
-- -- General Services -- --
deferred class Protocol; -- manages also Active Protocol
deferred class GeneralModule; -- (Shareds,Check,Copy,Trace)
class GeneralLib instantiates Library from LibCtl
(Transient, GeneralModule, Protocol from Interface);
class GTool;
class ShareTool;
class ShareFlags;
class CheckTool;
class CopyTool;
deferred class CopyControl;
class CopyMap;
class Category;
deferred class SignType;
class SignLabel;
class TypedValue;
class Static;
imported ValueSatisfies;
-- (val : HAsciiString) returns Boolean, see Satisfies from TypedValue
imported ValueInterpret;
-- (typval : TypedValue; hval : HAsciiString; native : Boolean)
-- returns HAsciiString, see Interpret from TypedValue
imported StaticSatisfies;
-- Function to be added to a Static for specific Satisfies
deferred generic class Recognizer; -- aimed to create Interface Entities
-- -- File Access (Read & Write) -- --
deferred class ReaderModule;
class ReaderLib instantiates Library from LibCtl
(Transient, ReaderModule, Protocol from Interface);
imported VectorOfFileParameter;
class FileParameter;
class ParamSet; -- see also ParamList
class ParamList;
deferred class FileReaderData;
deferred class FileReaderTool;
class LineBuffer;
class FloatWriter;
class MSG;
class STAT;
-- -- Enumerations -- --
enumeration ParamType is
ParamMisc, ParamInteger, ParamReal, ParamIdent, ParamVoid, ParamText,
ParamEnum, ParamLogical, ParamSub, ParamHexa, ParamBinary;
enumeration DataState is
StateOK, LoadWarning, LoadFail, DataWarning, DataFail,
StateUnloaded, StateUnknown;
---Purpose : validity state of anentity's content (see InterfaceModel)
enumeration CheckStatus is
CheckOK, CheckWarning, CheckFail, CheckAny, CheckMessage, CheckNoFail;
---Purpose : Classifies checks
-- OK : check is empty Warning : Warning, no Fail Fail : Fail
-- Others to query :
-- Any : any status Message : Warning/Fail NoFail : Warning/OK
-- -- Exceptions -- --
exception InterfaceError inherits Failure;
exception InterfaceMismatch inherits InterfaceError;
exception CheckFailure inherits InterfaceError;
-- -- Instantiations -- --
private class SequenceOfCheck instantiates -- for HSequence
Sequence from TCollection (Check);
private class HSequenceOfCheck instantiates -- Transient
HSequence from TCollection (Check,SequenceOfCheck);
class Array1OfFileParameter instantiates -- for ParamList :
Array1 from TCollection (FileParameter);
-- class HArray1OfFileParameter instantiates -- Array, Transient
-- HArray1 from TCollection (FileParameter,Array1OfFileParameter);
-- Useful Instantiations to define Data
class DataMapOfTransientInteger instantiates DataMap from TCollection
(Transient, Integer,MapTransientHasher from TColStd);
class Array1OfHAsciiString instantiates Array1 from TCollection
(HAsciiString from TCollection);
class HArray1OfHAsciiString instantiates HArray1 from TCollection
(HAsciiString from TCollection,Array1OfHAsciiString);
-- ==============IndexedMapOfAsciiString===================
class MapAsciiStringHasher; -- instantiates MapHasher from TCollection;
class IndexedMapOfAsciiString instantiates IndexedMap from TCollection(AsciiString from TCollection,MapAsciiStringHasher from Interface);
-- ==================================
end Interface;

View File

@@ -0,0 +1,120 @@
-- File: Interface_BitMap.cdl
-- Created: Fri Sep 1 10:01:00 1995
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1995
class BitMap from Interface
---Purpose : A bit map simply allows to associate a boolean flag to each
-- item of a list, such as a list of entities, etc... numbered
-- between 1 and a positive count nbitems
--
-- The BitMap class allows to associate several binary flags,
-- each of one is identified by a number from 0 to a count
-- which can remain at zero or be positive : nbflags
--
-- Flags lists over than numflag=0 are added after creation
-- Each of one can be named, hence the user can identify it
-- either by its flag number or by a name which gives a flag n0
-- (flag n0 0 has no name)
uses CString, HSequenceOfAsciiString from TColStd,
HArray1OfInteger from TColStd
is
Create (nbitems : Integer; resflags : Integer = 0) returns BitMap;
---Purpose : Creates a BitMap for <nbitems> items
-- One flag is defined, n0 0
-- <resflags> prepares allocation for <resflags> more flags
-- Flags values start at false
Create (other : BitMap; copied : Boolean = Standard_False) returns BitMap;
---Purpose : Creates a BitMap from another one
-- if <copied> is True, copies data
-- else, data are not copied, only the header object is
Internals (me; nbitems , nbwords, nbflags : out Integer;
flags : out mutable HArray1OfInteger;
names : out mutable HSequenceOfAsciiString);
---Purpose : Returns internal values, used for copying
-- Flags values start at false
Reservate (me : in out; moreflags : Integer);
---Purpose : Reservates for a count of more flags
SetLength (me : in out; nbitems : Integer);
---Purpose : Sets for a new count of items, which can be either less or
-- greater than the former one
-- For new items, their flags start at false
AddFlag (me : in out; name : CString = "") returns Integer;
---Purpose : Adds a flag, a name can be attached to it
-- Returns its flag number
-- Makes required reservation
AddSomeFlags (me : in out; more : Integer) returns Integer;
---Purpose : Adds several flags (<more>) with no name
-- Returns the number of last added flag
RemoveFlag (me : in out; num : Integer) returns Boolean;
---Purpose : Removes a flag given its number.
-- Returns True if done, false if num is out of range
SetFlagName (me : in out; num : Integer; name : CString) returns Boolean;
---Purpose : Sets a name for a flag, given its number
-- name can be empty (to erase the name of a flag)
-- Returns True if done, false if : num is out of range, or
-- name non-empty already set to another flag
NbFlags (me) returns Integer;
---Purpose : Returns the count of flags (flag 0 not included)
Length (me) returns Integer;
---Purpose : Returns the count of items (i.e. the length of the bitmap)
FlagName (me; num : Integer) returns CString;
---Purpose : Returns the name recorded for a flag, or an empty string
FlagNumber (me; name : CString) returns Integer;
---Purpose : Returns the number or a flag given its name, or zero
-- Access to flag values --
Value (me; item : Integer; flag : Integer = 0) returns Boolean;
---Purpose : Returns the value (true/false) of a flag, from :
-- - the number of the item
-- - the flag number, by default 0
SetValue (me; item : Integer; val : Boolean; flag : Integer = 0);
---Purpose : Sets a new value for a flag
SetTrue (me; item : Integer; flag : Integer = 0);
---Purpose : Sets a flag to True
SetFalse (me; item : Integer; flag : Integer = 0);
---Purpose : Sets a flag to False
CTrue (me; item : Integer; flag : Integer = 0) returns Boolean;
---Purpose : Returns the former value for a flag and sets it to True
-- (before : value returned; after : True)
CFalse (me; item : Integer; flag : Integer = 0) returns Boolean;
---Purpose : Returns the former value for a flag and sets it to False
-- (before : value returned; after : False)
Init (me; val : Boolean; flag : Integer = 0);
---Purpose : Initialises all the values of Flag Number <flag> to a given
-- value <val>
fields
thenbitems : Integer;
thenbwords : Integer;
thenbflags : Integer;
theflags : HArray1OfInteger;
thenames : HSequenceOfAsciiString;
end BitMap;

View File

@@ -0,0 +1,227 @@
#include <Interface_BitMap.ixx>
#include <TCollection_AsciiString.hxx>
#include <Standard_NotImplemented.hxx>
Interface_BitMap::Interface_BitMap
(const Standard_Integer nbitems, const Standard_Integer resflags)
{
thenbitems = nbitems;
thenbwords = nbitems/32 + 1;
thenbflags = 0;
theflags = new TColStd_HArray1OfInteger (0,thenbwords*(resflags+1)); theflags->Init(0);
}
Interface_BitMap::Interface_BitMap
(const Interface_BitMap& other, const Standard_Boolean copied)
{
other.Internals (thenbitems,thenbwords,thenbflags,theflags,thenames);
if (!copied) return;
Standard_Integer nb = theflags->Upper ();
Handle(TColStd_HArray1OfInteger) flags = new TColStd_HArray1OfInteger(0,nb);
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 0; i <= nb; i ++)
flags->SetValue (i,theflags->Value(i));
theflags = flags;
if (thenames.IsNull()) return;
nb = thenames->Length();
Handle(TColStd_HSequenceOfAsciiString) names = new TColStd_HSequenceOfAsciiString();
for (i = 1; i <= nb; i ++)
names->Append ( TCollection_AsciiString(thenames->Value(i)) );
thenames = names;
}
void Interface_BitMap::Internals
(Standard_Integer& nbitems, Standard_Integer& nbwords,
Standard_Integer& nbflags,
Handle(TColStd_HArray1OfInteger)& flags,
Handle(TColStd_HSequenceOfAsciiString)& names) const
{
nbitems = thenbitems; nbwords = thenbwords; nbflags = thenbflags;
flags = theflags; names = thenames;
}
void Interface_BitMap::Reservate (const Standard_Integer moreflags)
{
Standard_Integer nb = theflags->Upper ();
Standard_Integer nbflags = nb / thenbwords - 1; // flag 0 non compte ...
if (nbflags >= thenbflags + moreflags) return;
Standard_Integer nbw = thenbwords * (thenbflags+moreflags+2);
Handle(TColStd_HArray1OfInteger) flags = new TColStd_HArray1OfInteger(0,nbw);
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 0; i <= nb; i ++)
flags->SetValue (i,theflags->Value(i));
for (i = nb+1; i <= nbw; i ++) flags->SetValue (i,0);
theflags = flags;
}
void Interface_BitMap::SetLength (const Standard_Integer nbitems)
{
Standard_Integer nbw = nbitems/32 + 1;
if (nbw == thenbwords) return;
Handle(TColStd_HArray1OfInteger) flags =
new TColStd_HArray1OfInteger(0,nbw*(thenbflags+1));
if (nbw > thenbwords) flags->Init(0);
Standard_Integer nbmots = (nbw > thenbwords ? thenbwords : nbw);
Standard_Integer i0 = 0, i1 = 0;
for (Standard_Integer nf = 0; nf <= thenbflags; nf ++) {
for (Standard_Integer i = 0; i < nbmots; i ++)
flags->SetValue (i1+i,theflags->Value(i0+i));
i0 += thenbwords; i1 += nbw;
}
theflags = flags;
thenbitems = nbitems;
thenbwords = nbw;
}
Standard_Integer Interface_BitMap::AddFlag (const Standard_CString name)
{
Reservate(1);
Standard_Integer deja = 0;
if (thenames.IsNull()) thenames = new TColStd_HSequenceOfAsciiString();
else {
Standard_Integer i, nb = thenames->Length();
for (i = 1; i <= nb; i ++) {
if (thenames->Value(i).IsEqual("."))
{ thenames->ChangeValue(i).AssignCat(name); deja = i; }
}
}
if (!deja) thenames->Append (TCollection_AsciiString(name));
thenbflags ++;
return (deja ? deja : thenbflags);
}
Standard_Integer Interface_BitMap::AddSomeFlags
(const Standard_Integer more)
{
Reservate(more);
if (thenames.IsNull()) thenames = new TColStd_HSequenceOfAsciiString();
for (Standard_Integer i = 1; i <= more; i ++)
thenames->Append (TCollection_AsciiString(""));
thenbflags += more;
return thenbflags;
}
Standard_Boolean Interface_BitMap::RemoveFlag
(const Standard_Integer num)
{
if (num < 1 || num > thenames->Length()) return Standard_False;
if (num == thenames->Length()) thenames->Remove (thenames->Length());
else thenames->ChangeValue(num).AssignCat(".");
thenbflags --;
return Standard_True;
}
Standard_Boolean Interface_BitMap::SetFlagName
(const Standard_Integer num, const Standard_CString name)
{
if (num < 1 || num > thenames->Length()) return Standard_False;
Standard_Integer deja = (name[0] == '\0' ? 0 : FlagNumber (name) );
if (deja != 0 && deja != num) return Standard_False;
thenames->ChangeValue(num).AssignCat(name);
return Standard_True;
}
Standard_Integer Interface_BitMap::NbFlags () const
{ return thenbflags; }
Standard_Integer Interface_BitMap::Length () const
{ return thenbitems; }
Standard_CString Interface_BitMap::FlagName
(const Standard_Integer num) const
{
if (theflags.IsNull()) return "";
if (num < 1 || num > thenames->Length()) return "";
return thenames->Value(num).ToCString();
}
Standard_Integer Interface_BitMap::FlagNumber
(const Standard_CString name) const
{
if (name[0] == '\0') return 0;
if (thenames.IsNull()) return 0;
Standard_Integer i, nb = thenames->Length();
for (i = 1; i <= nb; i ++)
if (thenames->Value(i).IsEqual(name)) return i;
return 0;
}
// Les valeurs ...
Standard_Boolean Interface_BitMap::Value
(const Standard_Integer item, const Standard_Integer flag) const
{
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
const Standard_Integer& val = theflags->Value (numw);
if (val == 0 ) return Standard_False;
if (val == ~(0)) return Standard_True;
Standard_Integer numb = item & 31;
return ( ((1 << numb) & val) != 0);
}
void Interface_BitMap::SetValue
(const Standard_Integer item, const Standard_Boolean val,
const Standard_Integer flag) const
{
if (val) SetTrue (item,flag);
else SetFalse (item,flag);
}
void Interface_BitMap::SetTrue
(const Standard_Integer item, const Standard_Integer flag) const
{
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
Standard_Integer numb = item & 31;
theflags->ChangeValue (numw) |= (1 << numb);
}
void Interface_BitMap::SetFalse
(const Standard_Integer item, const Standard_Integer flag) const
{
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
Standard_Integer& val = theflags->ChangeValue (numw);
if (val == 0) return;
Standard_Integer numb = item & 31;
theflags->ChangeValue (numw) &= ~(1 << numb);
}
Standard_Boolean Interface_BitMap::CTrue
(const Standard_Integer item, const Standard_Integer flag) const
{
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
Standard_Integer numb = item & 31;
Standard_Integer& val = theflags->ChangeValue (numw);
Standard_Integer res, mot = (1 << numb);
if (val == 0) { val = mot; return Standard_False; }
else { res = val & mot; val |= mot; }
return (res != 0);
}
Standard_Boolean Interface_BitMap::CFalse
(const Standard_Integer item, const Standard_Integer flag) const
{
Standard_Integer numw = (thenbwords * flag) + (item >> 5);
Standard_Integer numb = item & 31;
Standard_Integer& val = theflags->ChangeValue (numw);
Standard_Integer res, mot = ~(1 << numb);
if (val == ~(0)) { val = mot; return Standard_False; }
else { res = val | mot; val &= mot; }
return (res != 0);
}
void Interface_BitMap::Init
(const Standard_Boolean val, const Standard_Integer flag) const
{
Standard_Integer i, ii = thenbwords, i1 = thenbwords *flag;
if (flag < 0) { i1 = 0; ii = thenbwords*(thenbflags+1); }
if (val) for (i = 0; i < ii; i ++) theflags->SetValue (i1+i,~(0));
else for (i = 0; i < ii; i ++) theflags->SetValue (i1+i, 0 );
}

View File

@@ -0,0 +1,90 @@
-- File: Interface_Category.cdl
-- Created: Wed Nov 8 19:11:08 1995
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1995
class Category from Interface
---Purpose : This class manages categories
-- A category is defined by a name and a number, and can be
-- seen as a way of rough classification, i.e. less precise than
-- a cdl type.
-- Hence, it is possible to dispatch every entity in about
-- a dozen of categories, twenty is a reasonable maximum.
--
-- Basically, the system provides the following categories :
-- Shape (Geometry, BRep, CSG, Features, etc...)
-- Drawing (Drawing, Views, Annotations, Pictures, Scketches ...)
-- Structure (Component & Part, Groups & Patterns ...)
-- Description (Meta-Data : Relations, Properties, Product ...)
-- Auxiliary (those which do not enter in the above list)
-- and some dedicated categories
-- FEA , Kinematics , Piping , etc...
-- plus Professional for other dedicated non-classed categories
--
-- In addition, this class provides a way to compute then quickly
-- query category numbers for an entire model.
-- Values are just recorded as a list of numbers, control must
-- then be done in a wider context (which must provide a Graph)
uses Integer, CString, Transient, HArray1OfInteger from TColStd,
Protocol, GTool, InterfaceModel, ShareTool
is
Create returns Category;
---Purpose : Creates a Category, with no protocol yet
Create (proto : Protocol) returns Category;
---Purpose : Creates a Category with a given protocol
Create (gtool : GTool) returns Category;
---Purpose : Creates a Category with a given GTool
SetProtocol (me : in out; proto : Protocol);
---Purpose : Sets/Changes Protocol
CatNum (me : in out; ent : Transient; shares : ShareTool) returns Integer;
---Purpose : Determines the Category Number for an entity in its context,
-- by using general service CategoryNumber
ClearNums (me : in out);
---Purpose : Clears the recorded list of category numbers for a Model
Compute (me : in out; model : InterfaceModel; shares : ShareTool);
---Purpose : Computes the Category Number for each entity and records it,
-- in an array (ent.number -> category number)
-- Hence, it can be queried by the method Num.
-- The Model itself is not recorded, this method is intended to
-- be used in a wider context (which detains also a Graph, etc)
Num (me; nument : Integer) returns Integer;
---Purpose : Returns the category number recorded for an entity number
-- Returns 0 if out of range
AddCategory (myclass; name : CString) returns Integer;
---Purpose : Records a new Category defined by its names, produces a number
-- New if not yet recorded
NbCategories (myclass) returns Integer;
---Purpose : Returns the count of recorded categories
Name (myclass; num : Integer) returns CString;
---Purpose : Returns the name of a category, according to its number
Number (myclass; name : CString) returns Integer;
---Purpose : Returns the number of a category, according to its name
Init (myclass);
---Purpose : Default initialisation
-- (protected against several calls : passes only once)
fields
thegtool : GTool;
thenum : HArray1OfInteger;
end Category;

View File

@@ -0,0 +1,116 @@
#include <Interface_Category.ixx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <Interface_GeneralModule.hxx>
static int init = 0;
static Standard_CString unspec = "unspecified";
static TColStd_SequenceOfAsciiString& thecats()
{
static TColStd_SequenceOfAsciiString thecat;
return thecat;
}
Interface_Category::Interface_Category ()
: thegtool (new Interface_GTool) { Init(); }
Interface_Category::Interface_Category
(const Handle(Interface_Protocol)& protocol)
: thegtool (new Interface_GTool(protocol)) { Init(); }
Interface_Category::Interface_Category
(const Handle(Interface_GTool)& gtool)
: thegtool (gtool) { Init(); }
void Interface_Category::SetProtocol
(const Handle(Interface_Protocol)& protocol)
{ thegtool->SetProtocol(protocol); }
Standard_Integer Interface_Category::CatNum
(const Handle(Standard_Transient)& ent, const Interface_ShareTool& shares)
{
if (ent.IsNull()) return 0;
Standard_Integer CN;
Handle(Interface_GeneralModule) module;
if (!thegtool->Select (ent,module,CN)) return 0;
return module->CategoryNumber (CN,ent,shares);
}
void Interface_Category::ClearNums ()
{ thenum.Nullify(); }
void Interface_Category::Compute
(const Handle(Interface_InterfaceModel)& model,
const Interface_ShareTool& shares)
{
ClearNums();
if (model.IsNull()) return;
Standard_Integer CN, i, nb = model->NbEntities();
thegtool->Reservate (nb);
if (nb == 0) return;
thenum = new TColStd_HArray1OfInteger (1,nb); thenum->Init(0);
for (i = 1; i <= nb; i ++) {
Handle(Standard_Transient) ent = model->Value(i);
if (ent.IsNull()) continue;
Handle(Interface_GeneralModule) module;
if (!thegtool->Select (ent,module,CN)) continue;
thenum->SetValue (i,module->CategoryNumber (CN,ent,shares));
}
}
Standard_Integer Interface_Category::Num (const Standard_Integer nument) const
{
if (thenum.IsNull()) return 0;
if (nument < 1 || nument > thenum->Length()) return 0;
return thenum->Value(nument);
}
// ########## LISTE DES CATEGORIES ##########
Standard_Integer Interface_Category::AddCategory (const Standard_CString name)
{
Standard_Integer num = Interface_Category::Number (name);
if (num > 0) return num;
thecats().Append (TCollection_AsciiString(name));
return thecats().Length()+1;
}
Standard_Integer Interface_Category::NbCategories ()
{ return thecats().Length(); }
Standard_CString Interface_Category::Name (const Standard_Integer num)
{
if (num < 0) return "";
if (num < 1 || num > thecats().Length()) return unspec;
return thecats().Value(num).ToCString();
}
Standard_Integer Interface_Category::Number (const Standard_CString name)
{
Standard_Integer i, nb = thecats().Length();
for (i = 1; i <= nb; i ++) {
if (thecats().Value(i).IsEqual(name)) return i;
}
return 0;
}
void Interface_Category::Init ()
{
if (init) return; init = 1;
init = Interface_Category::AddCategory ("Shape");
init = Interface_Category::AddCategory ("Drawing");
init = Interface_Category::AddCategory ("Structure");
init = Interface_Category::AddCategory ("Description");
init = Interface_Category::AddCategory ("Auxiliary");
init = Interface_Category::AddCategory ("Professional");
init = Interface_Category::AddCategory ("FEA");
init = Interface_Category::AddCategory ("Kinematics");
init = Interface_Category::AddCategory ("Piping");
}

256
src/Interface/Interface_Check.cdl Executable file
View File

@@ -0,0 +1,256 @@
-- File: Check.cdl
-- Created: Mon Feb 3 15:20:02 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class Check from Interface inherits TShared
---Purpose : Defines a Check, as a list of Fail or Warning Messages under
-- a literal form, which can be empty. A Check can also bring an
-- Entity, which is the Entity to which the messages apply
-- (this Entity may be any Transient Object).
--
-- Messages can be stored in two forms : the definitive form
-- (the only one by default), and another form, the original
-- form, which can be different if it contains values to be
-- inserted (integers, reals, strings)
-- The original form can be more suitable for some operations
-- such as counting messages
uses Integer, Boolean, Transient from Standard,
CString, HAsciiString from TCollection,
HSequenceOfHAsciiString from TColStd,
Msg from Message,
Messenger from Message,
CheckStatus from Interface
raises OutOfRange
is
Create returns Check;
---Purpose : Allows definition of a Sequence. Used also for Global Check
-- of an InterfaceModel (which stores global messages for file)
Create (anentity : Transient) returns Check;
---Purpose : Defines a Check on an Entity
SendFail (me : mutable; amsg : Msg from Message);
---Purpose : New name for AddFail (Msg)
AddFail (me : mutable; amess : HAsciiString from TCollection) is static;
---Purpose : Records a new Fail message
AddFail (me : mutable; amess,orig : HAsciiString from TCollection) is static;
---Purpose : Records a new Fail message under two forms : final,original
AddFail (me : mutable; amess : CString; orig : CString = "") is static;
---Purpose : Records a new Fail message given as "error text" directly
-- If <orig> is given, a distinct original form is recorded
-- else (D), the original form equates <amess>
AddFail (me : mutable; amsg : Msg from Message);
---Purpose : Records a new Fail from the definition of a Msg (Original+Value)
HasFailed (me) returns Boolean is static;
---Purpose : Returns True if Check brings at least one Fail Message
NbFails (me) returns Integer is static;
---Purpose : Returns count of recorded Fails
Fail (me; num : Integer; final : Boolean = Standard_True)
returns HAsciiString from TCollection
---Purpose : Returns Fail Message as a String
-- Final form by default, Original form if <final> is False
raises OutOfRange is static;
-- Error if <num> is out of range
---C++ : return const &
CFail (me; num : Integer; final : Boolean = Standard_True) returns CString
---Purpose : Same as above, but returns a CString (to be printed ...)
-- Final form by default, Original form if <final> is False
raises OutOfRange is static;
Fails (me; final : Boolean = Standard_True) returns HSequenceOfHAsciiString
is static;
---Purpose : Returns the list of Fails, for a frontal-engine logic
-- Final forms by default, Original forms if <final> is False
-- Can be empty
SendWarning (me : mutable; amsg : Msg from Message);
---Purpose : New name for AddWarning
AddWarning (me : mutable; amess : HAsciiString from TCollection) is static;
---Purpose : Records a new Warning message
AddWarning (me : mutable; amess,orig : HAsciiString from TCollection) is static;
---Purpose : Records a new Warning message under two forms : final,original
AddWarning (me : mutable; amess : CString; orig : CString = "") is static;
---Purpose : Records a Warning message given as "warning message" directly
-- If <orig> is given, a distinct original form is recorded
-- else (D), the original form equates <amess>
AddWarning (me : mutable; amsg : Msg from Message);
---Purpose : Records a new Warning from the definition of a Msg (Original+Value)
HasWarnings (me) returns Boolean is static;
---Purpose : Returns True if Check brings at least one Warning Message
NbWarnings (me) returns Integer is static;
---Purpose : Returns count of recorded Warning messages
Warning (me; num : Integer; final : Boolean = Standard_True)
returns HAsciiString from TCollection
---Purpose : Returns Warning message as a String
-- Final form by default, Original form if <final> is False
raises OutOfRange is static;
-- Error if <num> is out of range
---C++ : return const &
CWarning (me; num : Integer; final : Boolean = Standard_True) returns CString
raises OutOfRange is static;
---Purpose : Same as above, but returns a CString (to be printed ...)
-- Final form by default, Original form if <final> is False
Warnings (me; final : Boolean = Standard_True) returns HSequenceOfHAsciiString
is static;
---Purpose : Returns the list of Warnings, for a frontal-engine logic
-- Final forms by default, Original forms if <final> is False
-- Can be empty
SendMsg (me : mutable; amsg : Msg from Message);
---Purpose : Records an information message
-- This does not change the status of the Check
NbInfoMsgs (me) returns Integer;
---Purpose : Returns the count of recorded information messages
InfoMsg (me; num : Integer; final : Boolean = Standard_True)
returns HAsciiString from TCollection;
---Purpose : Returns information message as a String
---C++: return const &
CInfoMsg (me; num : Integer; final : Boolean = Standard_True) returns CString
raises OutOfRange is static;
---Purpose : Same as above, but returns a CString (to be printed ...)
-- Final form by default, Original form if <final> is False
InfoMsgs(me; final : Boolean = Standard_True) returns HSequenceOfHAsciiString;
---Purpose : Returns the list of Info Msg, for a frontal-engine logic
-- Final forms by default, Original forms if <final> is False
-- Can be empty
Status (me) returns CheckStatus is static;
---Purpose : Returns the Check Status : OK, Warning or Fail
Complies (me; status : CheckStatus) returns Boolean is static;
---Purpose : Tells if Check Status complies with a given one
-- (i.e. also status for query)
Complies (me; mess : HAsciiString; incl : Integer; status : CheckStatus)
returns Boolean is static;
---Purpose : Tells if a message is brought by a Check, as follows :
-- <incl> = 0 : <mess> exactly matches one of the messages
-- <incl> < 0 : <mess> is contained by one of the messages
-- <incl> > 0 : <mess> contains one of the messages
-- For <status> : for CheckWarning and CheckFail, considers only
-- resp. Warning or Check messages. for CheckAny, considers all
-- other values are ignored (answer will be false)
HasEntity (me) returns Boolean is static;
---Purpose : Returns True if a Check is devoted to an entity; else, it is
-- global (for InterfaceModel's storing of global error messages)
Entity (me) returns any Transient is static;
---Purpose : Returns the entity on which the Check has been defined
---C++ : return const &
Clear (me : mutable) is static;
---Purpose : Clears a check, in order to receive informations from transfer
-- (Messages and Entity)
ClearFails (me : mutable) is static;
---Purpose : Clears the Fail Messages (for instance to keep only Warnings)
ClearWarnings (me : mutable) is static;
---Purpose : Clears the Warning Messages (for instance to keep only Fails)
ClearInfoMsgs (me : mutable) is static;
---Purpose : Clears the Info Messages
Remove (me : mutable; mess : HAsciiString;
incl : Integer; status : CheckStatus)
returns Boolean is static;
---Purpose : Removes the messages which comply with <mess>, as follows :
-- <incl> = 0 : <mess> exactly matches one of the messages
-- <incl> < 0 : <mess> is contained by one of the messages
-- <incl> > 0 : <mess> contains one of the messages
-- For <status> : for CheckWarning and CheckFail, considers only
-- resp. Warning or Check messages. for CheckAny, considers all
-- other values are ignored (nothing is done)
-- Returns True if at least one message has been removed, False else
Mend (me : mutable; pref : CString; num : Integer = 0)
returns Boolean is static;
---Purpose : Mends messages, according <pref> and <num>
-- According to <num>, works on the whole list of Fails if = 0(D)
-- or only one Fail message, given its rank
-- If <pref> is empty, converts Fail(s) to Warning(s)
-- Else, does the conversion but prefixes the new Warning(s) but
-- <pref> followed by a semi-column
-- Some reserved values of <pref> are :
-- "FM" : standard prefix "Mended" (can be translated)
-- "CF" : clears Fail(s)
-- "CW" : clears Warning(s) : here, <num> refers to Warning list
-- "CA" : clears all messages : here, <num> is ignored
SetEntity (me : mutable; anentity : any Transient) is static;
---Purpose : Receives an entity result of a Transfer
GetEntity (me : mutable; anentity : any Transient) is static;
---Purpose : same as SetEntity (old form kept for compatibility)
-- Warning : Does nothing if Entity field is not yet clear
GetMessages (me : mutable; other : Check) is static;
---Purpose : Copies messages stored in another Check, cumulating
-- Does not regard other's Entity. Used to cumulate messages
GetAsWarning (me : mutable; other : Check; failsonly : Boolean) is static;
---Purpose : Copies messages converted into Warning messages
-- If failsonly is true, only Fails are taken, and converted
-- else, Warnings are taken too. Does not regard Entity
-- Used to keep Fail messages as Warning, after a recovery
Print (me; S: Messenger from Message; level : Integer; final : Integer = 1);
---Purpose : Prints the messages of the check to an Messenger
-- <level> = 1 : only fails
-- <level> = 2 : fails and warnings
-- <level> = 3 : all (fails, warnings, info msg)
-- <final> : if positive (D) prints final values of messages
-- if negative, prints originals
-- if null, prints both forms
Trace (me; level : Integer = -1; final : Integer = 1);
---Purpose : Prints the messages of the check to the default trace file
-- By default, according to the default standard level
-- Else, according level (see method Print)
fields
thefails : HSequenceOfHAsciiString;
thefailo : HSequenceOfHAsciiString;
thewarns : HSequenceOfHAsciiString;
thewarno : HSequenceOfHAsciiString;
theinfos : HSequenceOfHAsciiString;
theinfoo : HSequenceOfHAsciiString;
theent : Transient; -- the checked entity
end Check;

731
src/Interface/Interface_Check.cxx Executable file
View File

@@ -0,0 +1,731 @@
#include <Interface_Check.ixx>
#include <Standard_OutOfRange.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
// Un Check est cree au depart sans liste de message : celle ci est creee
// seulement si au moins une erreur doit y etre enregitree (Fail-Warning)
//=======================================================================
//function : Interface_Check
//purpose :
//=======================================================================
Interface_Check::Interface_Check()
{
} // construit a vide
//=======================================================================
//function : Interface_Check
//purpose :
//=======================================================================
Interface_Check::Interface_Check(const Handle(Standard_Transient)& anentity)
{
theent = anentity;
}
// .... Ajout de message d Erreur vraie (Fail)
//=======================================================================
//function : SendFail
//purpose :
//=======================================================================
void Interface_Check::SendFail(const Message_Msg& amsg)
{
AddFail (amsg);
}
//=======================================================================
//function : AddFail
//purpose :
//=======================================================================
void Interface_Check::AddFail (const Handle(TCollection_HAsciiString)& mess)
{
if (thefails.IsNull()) thefails = new TColStd_HSequenceOfHAsciiString();
if (thefailo.IsNull()) thefailo = new TColStd_HSequenceOfHAsciiString();
thefails->Append(mess); thefailo->Append(mess);
}
//=======================================================================
//function : AddFail
//purpose :
//=======================================================================
void Interface_Check::AddFail(const Handle(TCollection_HAsciiString)& mess,
const Handle(TCollection_HAsciiString)& orig)
{
if (thefails.IsNull()) thefails = new TColStd_HSequenceOfHAsciiString();
if (thefailo.IsNull()) thefailo = new TColStd_HSequenceOfHAsciiString();
thefails->Append(mess); thefailo->Append(orig);
}
//=======================================================================
//function : AddFail
//purpose :
//=======================================================================
void Interface_Check::AddFail(const Standard_CString amess,
const Standard_CString orig)
{
if (amess[0] == '\0') return;
if (!orig || orig[0] == '\0') AddFail (new TCollection_HAsciiString(amess));
else AddFail (new TCollection_HAsciiString(amess),
new TCollection_HAsciiString(orig) );
}
//=======================================================================
//function : AddFail
//purpose :
//=======================================================================
void Interface_Check::AddFail(const Message_Msg& amsg)
{
if (amsg.IsEdited()) AddFail (new TCollection_HAsciiString(TCollection_AsciiString(amsg.Value())),
new TCollection_HAsciiString(TCollection_AsciiString(amsg.Original())));
else AddFail (new TCollection_HAsciiString(TCollection_AsciiString(amsg.Value())));
}
//=======================================================================
//function : HasFailed
//purpose :
//=======================================================================
Standard_Boolean Interface_Check::HasFailed () const
{
return (!thefails.IsNull());
}
//=======================================================================
//function : NbFails
//purpose :
//=======================================================================
Standard_Integer Interface_Check::NbFails () const
{
return (thefails.IsNull() ? 0 : thefails->Length());
}
//=======================================================================
//function : Fail
//purpose :
//=======================================================================
const Handle(TCollection_HAsciiString)& Interface_Check::Fail
(const Standard_Integer num, const Standard_Boolean final) const
{
if (thefails.IsNull()) Standard_OutOfRange::Raise();
return (final ? thefails->Value(num) : thefailo->Value(num));
}
//=======================================================================
//function : CFail
//purpose :
//=======================================================================
Standard_CString Interface_Check::CFail(const Standard_Integer num,
const Standard_Boolean final) const
{
return Fail(num,final)->ToCString();
}
//=======================================================================
//function : Fails
//purpose :
//=======================================================================
Handle(TColStd_HSequenceOfHAsciiString) Interface_Check::Fails
(const Standard_Boolean final) const
{
if (thefails.IsNull()) return new TColStd_HSequenceOfHAsciiString();
return (final ? thefails : thefailo);
}
// .... Ajout de message de Warning
//=======================================================================
//function : SendWarning
//purpose :
//=======================================================================
void Interface_Check::SendWarning(const Message_Msg& amsg)
{
AddWarning (amsg);
}
//=======================================================================
//function : AddWarning
//purpose :
//=======================================================================
void Interface_Check::AddWarning (const Handle(TCollection_HAsciiString)& mess)
{
if (thewarns.IsNull()) thewarns = new TColStd_HSequenceOfHAsciiString();
if (thewarno.IsNull()) thewarno = new TColStd_HSequenceOfHAsciiString();
thewarns->Append(mess); thewarno->Append(mess);
}
//=======================================================================
//function : AddWarning
//purpose :
//=======================================================================
void Interface_Check::AddWarning(const Handle(TCollection_HAsciiString)& mess,
const Handle(TCollection_HAsciiString)& orig)
{
if (thewarns.IsNull()) thewarns = new TColStd_HSequenceOfHAsciiString();
if (thewarno.IsNull()) thewarno = new TColStd_HSequenceOfHAsciiString();
thewarns->Append(mess); thewarno->Append(orig);
}
//=======================================================================
//function : AddWarning
//purpose :
//=======================================================================
void Interface_Check::AddWarning(const Standard_CString amess,
const Standard_CString orig)
{
if (amess[0] == '\0') return;
if (!orig || orig[0] == '\0') AddWarning (new TCollection_HAsciiString(amess));
else AddWarning (new TCollection_HAsciiString(amess),
new TCollection_HAsciiString(orig) );
}
//=======================================================================
//function : AddWarning
//purpose :
//=======================================================================
void Interface_Check::AddWarning(const Message_Msg& amsg)
{
if (amsg.IsEdited()) AddWarning (new TCollection_HAsciiString(TCollection_AsciiString(amsg.Value())),
new TCollection_HAsciiString(TCollection_AsciiString(amsg.Original())));
else AddWarning (new TCollection_HAsciiString(TCollection_AsciiString(amsg.Value())));
}
//=======================================================================
//function : HasWarnings
//purpose :
//=======================================================================
Standard_Boolean Interface_Check::HasWarnings () const
{
return (!thewarns.IsNull());
}
//=======================================================================
//function : NbWarnings
//purpose :
//=======================================================================
Standard_Integer Interface_Check::NbWarnings () const
{
return (thewarns.IsNull() ? 0 : thewarns->Length());
}
//=======================================================================
//function : Warning
//purpose :
//=======================================================================
const Handle(TCollection_HAsciiString)& Interface_Check::Warning
(const Standard_Integer num, const Standard_Boolean final) const
{
if (thewarns.IsNull()) Standard_OutOfRange::Raise();
return (final ? thewarns->Value(num) : thewarno->Value(num));
}
//=======================================================================
//function : CWarning
//purpose :
//=======================================================================
Standard_CString Interface_Check::CWarning(const Standard_Integer num,
const Standard_Boolean final) const
{
return Warning(num,final)->ToCString();
}
//=======================================================================
//function : Warnings
//purpose :
//=======================================================================
Handle(TColStd_HSequenceOfHAsciiString) Interface_Check::Warnings
(const Standard_Boolean final) const
{
if (thewarns.IsNull()) return new TColStd_HSequenceOfHAsciiString();
return (final ? thewarns : thewarno);
}
// .... Ajout de message d Info simple (not yet completed)
//=======================================================================
//function : SendMsg
//purpose :
//=======================================================================
void Interface_Check::SendMsg (const Message_Msg& amsg)
{
Handle(TCollection_HAsciiString) mess =
new TCollection_HAsciiString (amsg.Value());
Handle(TCollection_HAsciiString) orig = mess;
if (amsg.IsEdited()) orig = new TCollection_HAsciiString (amsg.Original());
if (theinfos.IsNull()) theinfos = new TColStd_HSequenceOfHAsciiString();
if (theinfoo.IsNull()) theinfoo = new TColStd_HSequenceOfHAsciiString();
theinfos->Append(mess); theinfoo->Append(mess);
}
//=======================================================================
//function : NbInfoMsgs
//purpose :
//=======================================================================
Standard_Integer Interface_Check::NbInfoMsgs () const
{
return (theinfos.IsNull() ? 0 : theinfos->Length());
}
//=======================================================================
//function : InfoMsg
//purpose :
//=======================================================================
const Handle(TCollection_HAsciiString)& Interface_Check::InfoMsg
(const Standard_Integer num, const Standard_Boolean final) const
{
if (theinfos.IsNull()) Standard_OutOfRange::Raise();
return (final ? theinfos->Value(num) : theinfoo->Value(num));
}
//=======================================================================
//function : CInfoMsg
//purpose :
//=======================================================================
Standard_CString Interface_Check::CInfoMsg
(const Standard_Integer num, const Standard_Boolean final) const
{
return InfoMsg(num,final)->ToCString();
}
//=======================================================================
//function : InfoMsgs
//purpose :
//=======================================================================
Handle(TColStd_HSequenceOfHAsciiString) Interface_Check::InfoMsgs
(const Standard_Boolean final) const
{
if (theinfos.IsNull()) return new TColStd_HSequenceOfHAsciiString();
return (final ? theinfos : theinfoo);
}
// .... Gestion generale
//=======================================================================
//function : Status
//purpose :
//=======================================================================
Interface_CheckStatus Interface_Check::Status () const
{
if (!thefails.IsNull()) return Interface_CheckFail;
if (!thewarns.IsNull()) return Interface_CheckWarning;
return Interface_CheckOK;
}
//=======================================================================
//function : Complies
//purpose :
//=======================================================================
Standard_Boolean Interface_Check::Complies(const Interface_CheckStatus status) const
{
Standard_Boolean now = thewarns.IsNull();
Standard_Boolean nof = thefails.IsNull();
switch (status) {
case Interface_CheckOK : return ( nof && now);
case Interface_CheckWarning : return ( nof && !now);
case Interface_CheckFail : return !nof;
case Interface_CheckAny : return Standard_True;
case Interface_CheckMessage : return (!nof || !now);
case Interface_CheckNoFail : return nof;
default : break;
}
return Standard_False;
}
//=======================================================================
//function : Complies
//purpose :
//=======================================================================
Standard_Boolean Interface_Check::Complies(const Handle(TCollection_HAsciiString)& mess,
const Standard_Integer incl,
const Interface_CheckStatus status) const
{
if (mess.IsNull()) return Standard_False;
Standard_Integer lng = mess->Length();
if (status == Interface_CheckWarning || status == Interface_CheckAny) {
Standard_Integer i, nb = NbWarnings();
for (i = nb; i > 0; i --) {
Handle(TCollection_HAsciiString) ames = Warning(i);
if (incl == 0) { if (mess->IsSameString (ames)) return Standard_True; }
if (incl < 0) { if (ames->Location(mess,1,ames->Length()) > 0) return Standard_True; }
if (incl < 0) { if (mess->Location(mess,1,lng) > 0) return Standard_True; }
}
}
if (status == Interface_CheckFail || status == Interface_CheckAny) {
Standard_Integer i, nb = NbWarnings();
for (i = nb; i > 0; i --) {
Handle(TCollection_HAsciiString) ames = Warning(i);
if (incl == 0) { if (mess->IsSameString (ames)) return Standard_True; }
if (incl < 0) { if (ames->Location(mess,1,ames->Length()) > 0) return Standard_True; }
if (incl < 0) { if (mess->Location(mess,1,lng) > 0) return Standard_True; }
}
}
return Standard_False;
}
//=======================================================================
//function : HasEntity
//purpose :
//=======================================================================
Standard_Boolean Interface_Check::HasEntity () const
{
return (!theent.IsNull());
}
//=======================================================================
//function : Entity
//purpose :
//=======================================================================
const Handle(Standard_Transient)& Interface_Check::Entity () const
{
return theent;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void Interface_Check::Clear ()
{
thefails.Nullify(); thefailo.Nullify();
thewarns.Nullify(); thewarno.Nullify();
theinfos.Nullify(); theinfoo.Nullify();
theent.Nullify();
}
//=======================================================================
//function : ClearFails
//purpose :
//=======================================================================
void Interface_Check::ClearFails ()
{
thefails.Nullify();
thefailo.Nullify();
}
//=======================================================================
//function : ClearWarnings
//purpose :
//=======================================================================
void Interface_Check::ClearWarnings ()
{
thewarns.Nullify();
thewarno.Nullify();
}
//=======================================================================
//function : ClearInfoMsgs
//purpose :
//=======================================================================
void Interface_Check::ClearInfoMsgs ()
{
theinfos.Nullify();
theinfoo.Nullify();
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
Standard_Boolean Interface_Check::Remove(const Handle(TCollection_HAsciiString)& mess,
const Standard_Integer incl,
const Interface_CheckStatus status)
{
if (mess.IsNull()) return Standard_False;
Standard_Boolean res = Standard_False;
Standard_Integer lng = mess->Length();
if (status == Interface_CheckWarning || status == Interface_CheckAny) {
Standard_Integer i, nb = NbWarnings();
for (i = nb; i > 0; i --) {
Standard_Boolean rem = Standard_False;
Handle(TCollection_HAsciiString) ames = Warning(i);
if (incl == 0) rem = mess->IsSameString (ames);
if (incl < 0) rem = (ames->Location(mess,1,ames->Length()) > 0);
if (incl < 0) rem = (mess->Location(mess,1,lng) > 0);
if (rem) { thewarns->Remove(i); thewarno->Remove(i); res = rem; }
}
}
if (status == Interface_CheckFail || status == Interface_CheckAny) {
Standard_Integer i, nb = NbWarnings();
for (i = nb; i > 0; i --) {
Standard_Boolean rem = Standard_False;
Handle(TCollection_HAsciiString) ames = Warning(i);
if (incl == 0) rem = mess->IsSameString (ames);
if (incl < 0) rem = (ames->Location(mess,1,ames->Length()) > 0);
if (incl < 0) rem = (mess->Location(mess,1,lng) > 0);
if (rem) { thefails->Remove(i); thefailo->Remove(i); res = rem; }
}
}
return res;
}
//=======================================================================
//function : Mend
//purpose :
//=======================================================================
Standard_Boolean Interface_Check::Mend(const Standard_CString pref,
const Standard_Integer num)
{
Standard_Integer i, n1 = num, n2 = num;
if (pref && pref[2] == '\0') {
if (pref[0] == 'F' && pref[1] == 'M') return Mend ("Mended",num);
if (pref[0] == 'C' && pref[1] == 'A') { Clear(); return Standard_True; }
if (pref[0] == 'C' && pref[1] == 'W') {
if (num == 0) { ClearWarnings(); return Standard_True; }
if (num < 0 || num > NbWarnings()) return Standard_False;
thewarns->Remove(num); thewarno->Remove(num);
return Standard_True;
}
if (pref[0] == 'C' && pref[1] == 'F') {
if (num == 0) { ClearFails(); return Standard_True; }
if (num < 0 || num > NbFails()) return Standard_False;
thefails->Remove(num); thefailo->Remove(num);
return Standard_True;
}
}
// Cas courant
if (num == 0) {
n1 = 1; n2 = NbFails();
for (i = n2; i >= n1; i --) Mend (pref,i);
return Standard_True;
}
else if (num < 0 || num > NbFails()) return Standard_False;
// Un message
Handle(TCollection_HAsciiString) strf = thefails->Value(num);
Handle(TCollection_HAsciiString) stro = thefailo->Value(num);
if (pref && pref[0] != '\0') {
strf->Insert (1," : "); strf->Insert (1,pref);
if (stro != strf) { stro->Insert (1," : "); stro->Insert (1,pref); }
}
thefails->Remove(num); thefailo->Remove(num);
if (stro == strf) AddFail (strf);
else AddFail (strf,stro);
return Standard_True;
}
//=======================================================================
//function : SetEntity
//purpose :
//=======================================================================
void Interface_Check::SetEntity(const Handle(Standard_Transient)& anentity)
{
theent = anentity;
}
//=======================================================================
//function : GetEntity
//purpose :
//=======================================================================
void Interface_Check::GetEntity(const Handle(Standard_Transient)& anentity)
{
if (theent.IsNull()) SetEntity(anentity);
}
// .. GetMessages, reprend les messages en les cumulant aux siens propres
// .. GetAsWarning, reprend les messages en les cumulant et en les
// considerant tous comme "Warning" . En outre, selon <failsonly>
// failsonly True : ne pas reprendre les Warnings originaux
// failsonly False : les prendre aussi
//=======================================================================
//function : GetMessages
//purpose :
//=======================================================================
void Interface_Check::GetMessages (const Handle(Interface_Check)& other)
{
Standard_Integer nb,i;
if ( (nb = other->NbFails()) != 0) {
if (thefails.IsNull()) thefails = new TColStd_HSequenceOfHAsciiString();
if (thefailo.IsNull()) thefailo = new TColStd_HSequenceOfHAsciiString();
for (i = 1; i <= nb; i ++) thefails->Append(other->Fail(i,Standard_True));
for (i = 1; i <= nb; i ++) thefailo->Append(other->Fail(i,Standard_False));
}
if ( (nb = other->NbWarnings()) != 0) {
if (thewarns.IsNull()) thewarns = new TColStd_HSequenceOfHAsciiString();
if (thewarno.IsNull()) thewarno = new TColStd_HSequenceOfHAsciiString();
for (i = 1; i <= nb; i ++) thewarns->Append(other->Warning(i,Standard_True));
for (i = 1; i <= nb; i ++) thewarno->Append(other->Warning(i,Standard_False));
}
if ( (nb = other->NbInfoMsgs()) != 0) {
if (theinfos.IsNull()) theinfos = new TColStd_HSequenceOfHAsciiString();
if (theinfoo.IsNull()) theinfoo = new TColStd_HSequenceOfHAsciiString();
for (i = 1; i <= nb; i ++) theinfos->Append(other->InfoMsg(i,Standard_True));
for (i = 1; i <= nb; i ++) theinfoo->Append(other->InfoMsg(i,Standard_False));
}
}
//=======================================================================
//function : GetAsWarning
//purpose :
//=======================================================================
void Interface_Check::GetAsWarning(const Handle(Interface_Check)& other,
const Standard_Boolean failsonly)
{
Standard_Integer nb,i;
if ( (nb = other->NbFails()) != 0) {
if (thewarns.IsNull()) thewarns = new TColStd_HSequenceOfHAsciiString();
if (thewarno.IsNull()) thewarno = new TColStd_HSequenceOfHAsciiString();
for (i = 1; i <= nb; i ++) thewarns->Append(other->Fail(i,Standard_True));
for (i = 1; i <= nb; i ++) thewarno->Append(other->Fail(i,Standard_False));
}
if ( (nb = other->NbWarnings()) != 0 || !failsonly) {
if (thewarns.IsNull()) thewarns = new TColStd_HSequenceOfHAsciiString();
if (thewarno.IsNull()) thewarno = new TColStd_HSequenceOfHAsciiString();
for (i = 1; i <= nb; i ++) thewarns->Append(other->Warning(i,Standard_True));
for (i = 1; i <= nb; i ++) thewarno->Append(other->Warning(i,Standard_False));
}
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void Interface_Check::Print(const Handle(Message_Messenger)& S, const Standard_Integer level,
const Standard_Integer final) const
{
Standard_Integer j, nb = NbFails();
if (level >= 1) {
nb = NbFails();
// if (nb > 0) S<<" --> Fails : "<<nb<<endl;
for (j = 1; j <= nb; j ++) {
if (final >= 0)
S<<CFail(j,Standard_True)<<"\n";
else
S<<CFail(j,Standard_False)<<"\n";
// if (final == 0)
// if (Fail(j,Standard_True) != Fail(j,Standard_False))
// S<<"[original:"<<CFail(j,Standard_False)<<"]\n";
}
}
if (level >= 2) {
nb = NbWarnings();
// if (nb > 0) S<<" --> Warnings : "<<nb<<endl;
for (j = 1; j <= nb; j ++) {
if (final >= 0)
S<<CWarning(j,Standard_True)<<"\n";
else
S<<CWarning(j,Standard_False)<<"\n";
// if (final == 0)
// if (Warning(j,Standard_True) != Warning(j,Standard_False))
// S<<"[original:"<<CWarning(j,Standard_False)<<"]\n";
}
}
// InfoMsg : regle causant (user message)
if (level >= 0) {
nb = NbInfoMsgs();
// if (nb > 0) S<<" --> Infos : "<<nb<<endl;
for (j = 1; j <= nb; j ++) {
if (final >= 0)
S<<CInfoMsg(j,Standard_True)<<"\n";
else
S<<CInfoMsg(j,Standard_False)<<"\n";
// if (final == 0)
// if (InfoMsg(j,Standard_True) != InfoMsg(j,Standard_False))
// S<<"[original:"<<CInfoMsg(j,Standard_False)<<"]\n";
}
}
}
//=======================================================================
//function : Trace
//purpose :
//=======================================================================
void Interface_Check::Trace(const Standard_Integer level,
const Standard_Integer final) const
{
Print (Message::DefaultMessenger(), level, final);
}

View File

@@ -0,0 +1,188 @@
-- File: CheckIterator.cdl
-- Created: Wed Oct 28 14:17:10 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class CheckIterator from Interface
---Purpose : Result of a Check operation (especially from InterfaceModel)
uses Integer, CString, AsciiString from TCollection,
Messenger from Message,
HSequenceOfInteger from TColStd, HSequenceOfTransient from TColStd,
IntVal, Check, HSequenceOfCheck, InterfaceModel, CheckStatus
raises NoSuchObject
is
Create returns CheckIterator;
---Purpose : Creates an empty CheckIterator
Create (name : CString) returns CheckIterator;
---Purpose : Creates a CheckIterator with a name (displayed by Print as a
-- title)
SetName (me : in out; name : CString);
---Purpose : Sets / Changes the name
Name (me) returns CString;
---Purpose : Returns the recorded name (can be empty)
SetModel (me : in out; model : InterfaceModel);
---Purpose : Defines a Model, used to locate entities (not required, if it
-- is absent, entities are simply less documented)
Model (me) returns InterfaceModel;
---Purpose : Returns the stored model (can be a null handle)
Clear (me : in out) is static;
---Purpose : Clears the list of checks
Merge (me : in out; other : in out CheckIterator) is static;
---Purpose : Merges another CheckIterator into <me>, i.e. adds each of its
-- Checks. Content of <other> remains unchanged.
-- Takes also the Model but not the Name
Add (me : in out; ach : Check; num : Integer = 0) is static;
---Purpose : Adds a Check to the list to be iterated
-- This Check is Accompanied by Entity Number in the Model
-- (0 for Global Check or Entity unknown in the Model), if 0 and
-- Model is recorded in <me>, it is computed
Check (me; num : Integer) returns Check is static;
---Purpose : Returns the Check which was attached to an Entity given its
-- Number in the Model. <num>=0 is for the Global Check.
-- If no Check was recorded for this Number, returns an empty
-- Check.
-- Remark : Works apart from the iteration methods (no interference)
---C++ : return const &
Check (me; ent : Transient) returns Check is static;
---Purpose : Returns the Check attached to an Entity
-- If no Check was recorded for this Entity, returns an empty
-- Check.
-- Remark : Works apart from the iteration methods (no interference)
---C++ : return const &
CCheck (me : in out; num : Integer) returns Check is static;
---Purpose : Returns the Check bound to an Entity Number (0 : Global)
-- in order to be consulted or completed on the spot
-- I.e. returns the Check if is already exists, or adds it then
-- returns the new empty Check
---C++ : return &
CCheck (me : in out; ent : Transient) returns Check is static;
---Purpose : Returns the Check bound to an Entity, in order to be consulted
-- or completed on the spot
-- I.e. returns the Check if is already exists, or adds it then
-- returns the new empty Check
---C++ : return &
IsEmpty (me; failsonly : Boolean) returns Boolean is static;
---Purpose : Returns True if : no Fail has been recorded if <failsonly> is
-- True, no Check at all if <failsonly> is False
Status (me) returns CheckStatus;
---Purpose : Returns worst status among : OK, Warning, Fail
Complies (me; status : CheckStatus) returns Boolean;
---Purpose : Tells if this check list complies with a given status :
-- OK (i.e. empty), Warning (at least one Warning, but no Fail),
-- Fail (at least one), Message (not OK), NoFail, Any
Extract (me; status : CheckStatus) returns CheckIterator;
---Purpose : Returns a CheckIterator which contains the checks which comply
-- with a given status
-- Each check is added completely (no split Warning/Fail)
Extract (me; mess : CString; incl : Integer; status : CheckStatus)
returns CheckIterator;
---Purpose : Returns a CheckIterator which contains the check which comply
-- with a message, plus some conditions as follows :
-- <incl> = 0 : <mess> exactly matches one of the messages
-- <incl> < 0 : <mess> is contained by one of the messages
-- <incl> > 0 : <mess> contains one of the messages
-- For <status> : for CheckWarning and CheckFail, considers only
-- resp. Warning or Check messages. for CheckAny, considers all
-- other values are ignored (answer will be false)
-- Each Check which complies is entirely taken
Remove (me : in out; mess : CString; incl : Integer; status : CheckStatus)
returns Boolean;
---Purpose : Removes the messages of all Checks, under these conditions :
-- <incl> = 0 : <mess> exactly matches one of the messages
-- <incl> < 0 : <mess> is contained by one of the messages
-- <incl> > 0 : <mess> contains one of the messages
-- For <status> : for CheckWarning and CheckFail, considers only
-- resp. Warning or Check messages. for CheckAny, considers all
-- other values are ignored (nothing is done)
-- Returns True if at least one message has been removed, False else
Checkeds (me; failsonly : Boolean; global : Boolean) returns
HSequenceOfTransient;
---Purpose : Returns the list of entities concerned by a Check
-- Only fails if <failsonly> is True, else all non-empty checks
-- If <global> is true, adds the model for a global check
-- Else, global check is ignored
---Warning : if the model has not yet been defined, returns a Null Handle
Start (me) is static;
---Purpose : Starts Iteration. Thus, it is possible to restart it
-- Remark : an iteration may be done with a const Iterator
-- While its content is modified (through a pointer), this allows
-- to give it as a const argument to a function
More (me) returns Boolean is static;
---Purpose : Returns True if there are more Checks to get
Next (me) is static;
---Purpose : Sets Iteration to next Item
Value (me) returns Check
---Purpose : Returns Check currently Iterated
-- It brings all other informations (status, messages, ...)
-- The Number of the Entity in the Model is given by Number below
raises NoSuchObject is static;
-- Error if Iteration has ended
---C++ : return const &
Number (me) returns Integer
---Purpose : Returns Number of Entity for the Check currently iterated
-- or 0 for GlobalCheck
raises NoSuchObject is static;
-- Error if Iteration has ended
Print (me; S : Messenger from Message; failsonly : Boolean; final : Integer = 0);
---Purpose : Prints the list of Checks with their attached Numbers
-- If <failsonly> is True, prints only Fail messages
-- If <failsonly> is False, prints all messages
-- If <final> = 0 (D), prints also original messages if different
-- If <final> < 0, prints only original messages
-- If <final> > 0, prints only final messages
-- It uses the recorded Model if it is defined
-- Remark : Works apart from the iteration methods (no interference)
Print (me; S : Messenger from Message; model : InterfaceModel;
failsonly : Boolean; final : Integer = 0);
---Purpose : Works as Print without a model, but for entities which have
-- no attached number (Number not positive), tries to compute
-- this Number from <model> and displays "original" or "computed"
Destroy (me : in out);
---Purpose : Clears data of iteration
---C++ : alias ~
fields
thelist : HSequenceOfCheck;
thenums : HSequenceOfInteger from TColStd;
themod : InterfaceModel;
thename : AsciiString;
thecurr : IntVal;
end CheckIterator;

View File

@@ -0,0 +1,517 @@
#include <Interface_CheckIterator.ixx>
#include <Standard_NoSuchObject.hxx>
#include <TCollection_HAsciiString.hxx>
static const Handle(Interface_Check)& nulcheck ()
{
static Handle(Interface_Check) nulch = new Interface_Check;
return nulch;
}
//=======================================================================
//function : Interface_CheckIterator
//purpose :
//=======================================================================
Interface_CheckIterator::Interface_CheckIterator ()
{
Clear();
}
//=======================================================================
//function : Interface_CheckIterator
//purpose :
//=======================================================================
Interface_CheckIterator::Interface_CheckIterator(const Standard_CString name)
: thename (name)
{
Clear();
}
//=======================================================================
//function : SetName
//purpose :
//=======================================================================
void Interface_CheckIterator::SetName (const Standard_CString name)
{
thename.Clear();
if (name[0] != '\0') thename.AssignCat(name);
}
//=======================================================================
//function : Name
//purpose :
//=======================================================================
Standard_CString Interface_CheckIterator::Name () const
{
return thename.ToCString();
}
//=======================================================================
//function : SetModel
//purpose :
//=======================================================================
void Interface_CheckIterator::SetModel(const Handle(Interface_InterfaceModel)& model)
{
themod = model;
}
//=======================================================================
//function : Model
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) Interface_CheckIterator::Model() const
{
return themod;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void Interface_CheckIterator::Clear ()
{
thelist = new Interface_HSequenceOfCheck();
thenums = new TColStd_HSequenceOfInteger();
thecurr = new Interface_IntVal;
thecurr->CValue() = 1;
}
//=======================================================================
//function : Merge
//purpose :
//=======================================================================
void Interface_CheckIterator::Merge (Interface_CheckIterator& other)
{
themod = other.Model();
for (other.Start(); other.More(); other.Next())
Add (other.Value(),other.Number());
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void Interface_CheckIterator::Add(const Handle(Interface_Check)& ach,
const Standard_Integer num)
{
// Add <meme num que le dernier> -> cumul des Checks
if (ach->NbWarnings() + ach->NbFails() == 0) return;
Standard_Integer nm = num;
if (num <= 0 && ach->HasEntity()) {
if (!themod.IsNull()) {
nm = themod->Number (ach->Entity());
if (nm <= 0) nm = -1;
}
else nm = -1;
}
if (nm >= 0 && nm <= - (thecurr->Value()) ) {
Standard_Integer i , numpos = 0 , nb = thelist->Length();
for (i = nb; i > 0; i --)
if (thenums->Value(i) == nm) { numpos = i; break; }
if (numpos > 0 && nm >= 0) {
Handle(Interface_Check) lch = thelist->ChangeValue(numpos);
lch->GetMessages (ach);
}
// Cas normal : on ajoute en fin de liste
else { thelist->Append(ach); thenums->Append(nm); }
}
// Pas encore vu passe : inutile de chercher
else { thelist->Append(ach); thenums->Append(nm); thecurr->CValue() = -nm; }
}
//=======================================================================
//function : Check
//purpose :
//=======================================================================
const Handle(Interface_Check)& Interface_CheckIterator::Check
(const Standard_Integer num) const
{
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
if (num == thenums->Value(i)) return thelist->Value(i);
}
return nulcheck();
}
//=======================================================================
//function : Check
//purpose :
//=======================================================================
const Handle(Interface_Check)& Interface_CheckIterator::Check
(const Handle(Standard_Transient)& ent) const
{
Standard_Integer num = -1;
if (!themod.IsNull()) num = themod->Number(ent);
if (num > 0) return Check(num);
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
if (ent == thelist->Value(i)->Entity()) return thelist->Value(i);
}
return nulcheck();
}
//=======================================================================
//function : CCheck
//purpose :
//=======================================================================
Handle(Interface_Check)& Interface_CheckIterator::CCheck
(const Standard_Integer num)
{
Standard_Integer i, nb = thenums->Length();
for (i = 1; i <= nb; i ++) {
if (num == thenums->Value(i)) return thelist->ChangeValue(i);
}
Handle(Interface_Check) ach = new Interface_Check;
thelist->Append(ach); thenums->Append(num);
return thelist->ChangeValue (thelist->Length());
}
//=======================================================================
//function : CCheck
//purpose :
//=======================================================================
Handle(Interface_Check)& Interface_CheckIterator::CCheck
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = -1;
if (!themod.IsNull()) num = themod->Number(ent);
if (num > 0) return CCheck(num);
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
if (ent == thelist->Value(i)->Entity()) return thelist->ChangeValue(i);
}
Handle(Interface_Check) ach = new Interface_Check;
thelist->Append(ach); thenums->Append(num);
return thelist->ChangeValue (thelist->Length());
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
Standard_Boolean Interface_CheckIterator::IsEmpty
(const Standard_Boolean failsonly) const
{
if (thelist->IsEmpty()) return Standard_True;
if (!failsonly) return Standard_False;
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
if (thelist->Value(i)->HasFailed()) return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : Status
//purpose :
//=======================================================================
Interface_CheckStatus Interface_CheckIterator::Status () const
{
Interface_CheckStatus stat = Interface_CheckOK;
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
const Handle(Interface_Check) ach = thelist->Value(i);
if (ach->HasFailed()) return Interface_CheckFail;
if (ach->NbWarnings() > 0) stat = Interface_CheckWarning;
}
return stat;
}
//=======================================================================
//function : Complies
//purpose :
//=======================================================================
Standard_Boolean Interface_CheckIterator::Complies
(const Interface_CheckStatus stat) const
{
Standard_Boolean res = Standard_False;
if (stat == Interface_CheckNoFail) res = Standard_True;
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
const Handle(Interface_Check) ach = thelist->Value(i);
Standard_Integer nbf = ach->NbFails(), nbw = ach->NbWarnings();
switch (stat) {
case Interface_CheckOK : if (nbf + nbw > 0) return Standard_False; break;
case Interface_CheckWarning : if (nbf > 0) return Standard_False;
if (nbw > 0) res = Standard_True; break;
case Interface_CheckFail : if (nbf > 0) return Standard_True; break;
case Interface_CheckAny : return Standard_True;
case Interface_CheckMessage : if (nbf + nbw > 0) return Standard_True; break;
case Interface_CheckNoFail : if (nbf > 0) return Standard_False; break;
default : break;
}
}
return res;
}
//=======================================================================
//function : Extract
//purpose :
//=======================================================================
Interface_CheckIterator Interface_CheckIterator::Extract
(const Interface_CheckStatus stat) const
{
Interface_CheckIterator res;
res.SetModel (themod); res.SetName (thename.ToCString());
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
const Handle(Interface_Check) ach = thelist->Value(i);
Standard_Integer nbf = ach->NbFails(), nbw = ach->NbWarnings();
Standard_Boolean prend = Standard_False;
switch (stat) {
case Interface_CheckOK : prend = (nbf + nbw == 0); break;
case Interface_CheckWarning : prend = (nbf == 0 && nbw > 0); break;
case Interface_CheckFail : prend = (nbf > 0); break;
case Interface_CheckAny : prend = Standard_True; break;
case Interface_CheckMessage : prend = (nbf + nbw > 0); break;
case Interface_CheckNoFail : prend = (nbf == 0); break;
default : break;
}
if (prend) res.Add (ach,thenums->Value(i));
}
return res;
}
//=======================================================================
//function : Extract
//purpose :
//=======================================================================
Interface_CheckIterator Interface_CheckIterator::Extract
(const Standard_CString mess,
const Standard_Integer incl, const Interface_CheckStatus stat) const
{
Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString (mess);
Interface_CheckIterator res;
res.SetModel (themod); res.SetName (thename.ToCString());
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
const Handle(Interface_Check) ach = thelist->Value(i);
if (ach->Complies(str,incl,stat)) res.Add (ach,thenums->Value(i));
}
return res;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
Standard_Boolean Interface_CheckIterator::Remove(const Standard_CString mess,
const Standard_Integer incl,
const Interface_CheckStatus stat)
{
Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString (mess);
Standard_Boolean res = Standard_False;
Standard_Integer i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
Handle(Interface_Check) ach = thelist->ChangeValue(i);
if (ach->Remove (str,incl,stat)) res = Standard_True;
}
return res;
}
//=======================================================================
//function : Checkeds
//purpose :
//=======================================================================
Handle(TColStd_HSequenceOfTransient) Interface_CheckIterator::Checkeds
(const Standard_Boolean failsonly, const Standard_Boolean global) const
{
Handle(TColStd_HSequenceOfTransient) list;
if (themod.IsNull()) return list;
list = new TColStd_HSequenceOfTransient();
Standard_Integer num, i, nb = thelist->Length();
for (i = 1; i <= nb; i ++) {
const Handle(Interface_Check) chk = thelist->Value(i);
if (failsonly && !chk->HasFailed()) continue;
if (chk->NbWarnings() == 0) continue;
num = thenums->Value(i);
if (num == 0 && global) list->Append (themod);
else if (num > 0) list->Append (themod->Value(num));
}
return list;
}
//=======================================================================
//function : Start
//purpose :
//=======================================================================
void Interface_CheckIterator::Start () const
{
thecurr->CValue() = 1;
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean Interface_CheckIterator::More () const
{
if (thecurr->Value() < 0) thecurr->CValue() = 1;
return (thecurr->Value() <= thelist->Length());
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void Interface_CheckIterator::Next () const
{
if (thecurr->Value() < 0) thecurr->CValue() = 1;
thecurr->CValue() ++;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const Handle(Interface_Check)& Interface_CheckIterator::Value () const
{
if (thecurr->Value() > thelist->Length()) Standard_NoSuchObject::Raise
("Interface Check Iterator : Value");
return thelist->Value(thecurr->Value());
}
//=======================================================================
//function : Number
//purpose :
//=======================================================================
Standard_Integer Interface_CheckIterator::Number () const
{
if (thecurr->Value() > thenums->Length()) Standard_NoSuchObject::Raise
("Interface Check Iterator : Value");
return thenums->Value(thecurr->Value());
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void Interface_CheckIterator::Print(const Handle(Message_Messenger)& S,
const Standard_Boolean failsonly,
const Standard_Integer final) const
{
Print (S,themod,failsonly,final);
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void Interface_CheckIterator::Print(const Handle(Message_Messenger)& S,
const Handle(Interface_InterfaceModel)& model,
const Standard_Boolean failsonly,
const Standard_Integer /*final*/) const
{
Standard_Boolean titre = Standard_False;
/*Standard_CString mesnum;
Standard_CString mesnum0 = ":";
Standard_CString mesnum1 = " (original):";
Standard_CString mesnum2 = " (computed):"; */
Standard_Integer i, nbch = 0, nb = thelist->Length();//,j; svv #2
Standard_Boolean yamod = !model.IsNull();
for (i = 1; i <= nb; i ++) {
const Handle(Interface_Check) ach = thelist->Value(i);
Standard_Integer nbw = 0, nbf = ach->NbFails();
if (!failsonly) nbw = ach->NbWarnings();
if (nbf + nbw == 0) continue;
Handle(Standard_Transient) ent = ach->Entity();
Standard_Integer nm0 = thenums->Value(i);
Standard_Boolean entnul = ent.IsNull();
Standard_Integer num = nm0;
if (nm0 <= 0 && !entnul && yamod) num = model->Number(ent);
if (nm0 <= 0 && entnul) num = -1; // Global
// mesnum = mesnum0;
// if (yamod) mesnum = (nm0 > 0 ? mesnum1 : mesnum2);
if (!titre) S<<" ** " << Name() << " **"<<endl;
titre = Standard_True;
S<<"Check:"; if(nb > 9 && i < 10) S<<" "; if (nb > 99 && i < 100) S<<" ";
S<<i;
if (num < 0) S<<" -- Global Check"<<endl;
else if (num == 0) S<<" -- Entity n0 ??:";
else {
if (yamod) { S<<" -- Entity (n0:id) "; model->Print (ent,S); }
else S<<" -- Entity n0 "<<num;
// S<<" -- Entity n0 "<<num<<mesnum;
// if (yamod) model->PrintLabel(ent,S);
}
if (num >= 0 && entnul) S<<" (unknown Type)"<<endl;
else if (num >= 0 && !entnul) {
if (yamod) S<<" Type:"<<model->TypeName(ent)<<endl;
else S<<" Type:"<<ent->DynamicType()->Name()<<endl;
}
nbch ++;
ach->Print (S, (failsonly ? 1 : 3));
}
// if (nbch > 0) S<<" ---- Checks : "<<nbch<<" ----"<<endl;
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void Interface_CheckIterator::Destroy ()
{
thecurr.Nullify();
} // redevient standard

View File

@@ -0,0 +1,105 @@
-- File: Interface_CheckTool.cdl
-- Created: Tue Feb 2 16:12:59 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
class CheckTool from Interface
---Purpose : Performs Checks on Entities, using General Service Library and
-- Modules to work. Works on one Entity or on a complete Model
uses Transient, InterfaceModel, Check,
CheckIterator, EntityIterator, HGraph, Graph, ShareTool,
Messenger from Message,
Protocol from Interface, GeneralLib, GTool
raises CheckFailure
is
Create (model : InterfaceModel; protocol : Protocol from Interface)
returns CheckTool;
---Purpose : Creates a CheckTool, by calling the General Service Library
-- and Modules, selected through a Protocol, to work on a Model
-- Moreover, Protocol recognizes Unknown Entities
Create (model : InterfaceModel)
returns CheckTool;
---Purpose : Creates a CheckTool, by calling the General Service Library
-- and Modules, selected through a Protocol, to work on a Model
-- Protocol and so on are taken from the Model (its GTool)
Create (graph : Graph) returns CheckTool;
---Purpose : Creates a CheckTool from a Graph. The Graph contains a Model
-- which designates a Protocol: they are used to create ShareTool
Create (hgraph : HGraph) returns CheckTool;
FillCheck (me : in out; ent : Transient; sh : ShareTool; ach : in out Check);
---Purpose : Fills as required a Check with the Error and Warning messages
-- produced by Checking a given Entity.
-- For an Erroneous or Corrected Entity : Check build at Analyse
-- time; else, Check computed for Entity (Verify integrity), can
-- use a Graph as required to control context
Print (me; ach : Check; S : Messenger from Message);
---Purpose : Utility method which Prints the content of a Check
Print (me; list : CheckIterator; S : Messenger from Message);
---Purpose : Simply Lists all the Checks and the Content (messages) and the
-- Entity, if there is, of each Check
-- (if all Checks are OK, nothing is Printed)
-- -- Checking a Model (the one given for Creation) -- --
Check (me : in out; num : Integer) returns Check;
---Purpose : Returns the Check associated to an Entity identified by
-- its Number in a Model.
CheckSuccess (me : in out; reset : Boolean = Standard_False)
raises CheckFailure;
---Purpose : Checks if any Error has been detected (CheckList not empty)
-- Returns normally if none, raises exception if some exists.
-- It reuses the last computations from other checking methods,
-- unless the argument <resest> is given True
CompleteCheckList (me : in out) returns CheckIterator;
---Purpose : Returns list of all "remarkable" informations, which include :
-- - GlobalCheck, if not empty
-- - Error Checks, for all Errors (Verify + Analyse)
-- - also Corrected Entities
-- - and Unknown Entities : for those, each Unknown Entity is
-- associated to an empty Check (it is neither an Error nor a
-- Correction, but a remarkable information)
CheckList (me : in out) returns CheckIterator;
---Purpose : Returns list of all Errors detected
-- Note that presence of Unknown Entities is not an error
-- Cumulates : GlobalCheck if error +
-- AnalyseCheckList + VerifyCheckList
AnalyseCheckList (me : in out) returns CheckIterator;
---Purpose : Returns list of errors dectected at Analyse time (syntactic)
-- (note that GlobalCheck is not in this list)
VerifyCheckList (me : in out) returns CheckIterator;
---Purpose : Returns list of integrity constraints errors (semantic)
-- (note that GlobalCheck is not in this list)
WarningCheckList (me : in out) returns CheckIterator;
---Purpose : Returns list of Corrections (includes GlobalCheck if corrected)
UnknownEntities (me : in out) returns EntityIterator;
---Purpose : Returns list of Unknown Entities
-- Note that Error and Erroneous Entities are not considered
-- as Unknown
fields
thegtool : GTool;
theshare : ShareTool;
thestat : Integer;
end CheckTool;

View File

@@ -0,0 +1,481 @@
#include <Standard_ErrorHandler.hxx>
#include <Interface_CheckTool.ixx>
#include <Interface_Macros.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Interface_Graph.hxx>
#include <Interface_ReportEntity.hxx>
#include <Interface_GeneralModule.hxx>
#include <Interface_CheckFailure.hxx>
#include <Message_Messenger.hxx>
#include <Standard_Failure.hxx>
#ifdef WNT
#include <OSD_Exception.hxx>
#else
#include <OSD_Signal.hxx>
#endif
#include <stdio.h>
static int errh = 1;
static void raisecheck (Handle(Interface_Check)& ach)
{
Handle(Standard_Failure) afail = Standard_Failure::Caught();
char mess[100];
sprintf (mess,"** Exception Raised during Check : %s **",
afail->DynamicType()->Name());
ach->AddFail(mess);
#ifdef WNT
if (afail->IsKind(STANDARD_TYPE(OSD_Exception)))
#else
if (afail->IsKind(STANDARD_TYPE(OSD_Signal)))
#endif
afail->Reraise("System Signal received, check interrupt");
}
// thestat : evite a CheckSuccess de refaire un calcul prealablement fait :
// bit valeur 1 : Verify fait, valeur 4 : et ilya des erreurs
// bit valeur 2 : Analyse fait, valeur 8 : et ilya des erreurs
//=======================================================================
//function : Interface_CheckTool
//purpose :
//=======================================================================
Interface_CheckTool::Interface_CheckTool(const Handle(Interface_InterfaceModel)& model,
const Handle(Interface_Protocol)& protocol)
: thegtool ( new Interface_GTool(protocol,model->NbEntities()) ) ,
theshare (model,protocol)
{
thestat = 0;
}
//=======================================================================
//function : Interface_CheckTool
//purpose :
//=======================================================================
Interface_CheckTool::Interface_CheckTool(const Handle(Interface_InterfaceModel)& model)
: thegtool(model->GTool()) , theshare (model,model->GTool())
{
thestat = 0;
thegtool->Reservate(model->NbEntities());
}
//=======================================================================
//function : Interface_CheckTool
//purpose :
//=======================================================================
Interface_CheckTool::Interface_CheckTool(const Interface_Graph& graph)
: thegtool(graph.Model()->GTool()) , theshare (graph)
{
}
//=======================================================================
//function : Interface_CheckTool
//purpose :
//=======================================================================
Interface_CheckTool::Interface_CheckTool(const Handle(Interface_HGraph)& hgraph)
: thegtool(hgraph->Graph().Model()->GTool()) , theshare (hgraph)
{
}
//=======================================================================
//function : FillCheck
//purpose :
//=======================================================================
void Interface_CheckTool::FillCheck(const Handle(Standard_Transient)& ent,
const Interface_ShareTool& sh,
Handle(Interface_Check)& ach)
{
Handle(Interface_GeneralModule) module;
Standard_Integer CN;
if (thegtool->Select(ent,module,CN)) {
// Sans try/catch (fait par l appelant, evite try/catch en boucle)
if (!errh) {
module->CheckCase(CN,ent,sh,ach);
return;
}
// Avec try/catch
try {
OCC_CATCH_SIGNALS
module->CheckCase(CN,ent,sh,ach);
}
catch (Standard_Failure) {
raisecheck(ach);
}
}
else {
DeclareAndCast(Interface_ReportEntity,rep,ent);
if (rep.IsNull()) return;
ach = rep->Check();
}
if (theshare.Graph().HasShareErrors(ent))
ach->AddFail("** Shared Items unknown from the containing Model");
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void Interface_CheckTool::Print(const Handle(Interface_Check)& ach,
const Handle(Message_Messenger)& S) const
{
Standard_Integer i, nb;
nb = ach->NbFails();
if (nb > 0) S << " Fail Messages : " << nb << " :\n";
for (i = 1; i <= nb; i ++) {
S << ach->Fail(i) << "\n";
}
nb = ach->NbWarnings();
if (nb > 0) S << " Warning Messages : " << nb << " :\n";
for (i = 1; i <= nb; i ++) {
S << ach->Warning(i) << "\n";
}
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void Interface_CheckTool::Print(const Interface_CheckIterator& list,
const Handle(Message_Messenger)& S) const
{
Handle(Interface_InterfaceModel) model = theshare.Model();
list.Print(S,model,Standard_False);
}
// .... Check General sur un Modele ....
// Check : Une Entite d un Modele, designee par son rang
//=======================================================================
//function : Check
//purpose :
//=======================================================================
Handle(Interface_Check) Interface_CheckTool::Check(const Standard_Integer num)
{
Handle(Interface_InterfaceModel) model = theshare.Model();
Handle(Standard_Transient) ent = model->Value(num);
Handle(Interface_Check) ach = new Interface_Check(ent); // non filtre par "Warning" : tel quel
errh = 1;
FillCheck(ent,theshare,ach);
return ach;
}
// CheckSuccess : test passe-passe pas, sur CheckList(Fail) des Entites
//=======================================================================
//function : CheckSuccess
//purpose :
//=======================================================================
void Interface_CheckTool::CheckSuccess (const Standard_Boolean reset)
{
if (reset) thestat = 0;
if (thestat > 3) Interface_CheckFailure::Raise // deja teste avec erreur
("Interface Model : Global Check");
Handle(Interface_InterfaceModel) model = theshare.Model();
if (model->GlobalCheck()->NbFails() > 0) Interface_CheckFailure::Raise
("Interface Model : Global Check");
Handle(Interface_Check) modchk = new Interface_Check;
model->VerifyCheck(modchk);
if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),modchk);
if (modchk->HasFailed()) Interface_CheckFailure::Raise
("Interface Model : Verify Check");
if (thestat == 3) return; // tout teste et ca passe
errh = 0; // Pas de try/catch, car justement on raise
Standard_Integer nb = model->NbEntities();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (model->IsErrorEntity(i)) Interface_CheckFailure::Raise
("Interface Model : an Entity is recorded as Erroneous");
Handle(Standard_Transient) ent = model->Value(i);
if (thestat & 1) {
if (!model->IsErrorEntity(i)) continue; // deja verify, reste analyse
}
if (thestat & 2) {
if ( model->IsErrorEntity(i)) continue; // deja analyse, reste verify
}
Handle(Interface_Check) ach = new Interface_Check(ent);
FillCheck(ent,theshare,ach);
if (ach->HasFailed()) Interface_CheckFailure::Raise
("Interface Model : Check on an Entity has Failed");
}
}
// CompleteCheckList : Tous Tests : GlobalCheck, Analyse-Verify en Fail ou en
// Warning; plus les Unknown Entities (par Check vide)
//=======================================================================
//function : CompleteCheckList
//purpose :
//=======================================================================
Interface_CheckIterator Interface_CheckTool::CompleteCheckList ()
{
thestat = 3;
Handle(Interface_InterfaceModel) model = theshare.Model();
Interface_CheckIterator res;
res.SetModel(model);
Handle(Interface_Check) globch = model->GlobalCheck(); // GlobalCheck Statique
if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),globch);
model->VerifyCheck(globch); // GlobalCheck Dynamique
if (globch->HasFailed() || globch->HasWarnings()) res.Add(globch,0);
if (globch->HasFailed()) thestat |= 12;
Standard_Integer i=0,n0 = 1, nb = model->NbEntities();
errh = 0;
while (n0 <= nb) {
Handle(Interface_Check) ach = new Interface_Check;
Handle(Standard_Transient) ent;
try {
OCC_CATCH_SIGNALS
for (i = n0; i <= nb; i ++) {
ach->Clear();
ent = model->Value(i);
ach->SetEntity(ent);
if (model->IsReportEntity(i)) {
ach = model->ReportEntity(i)->Check(); // INCLUT Unknown
if (ach->HasFailed()) // FAIL : pas de Check semantique
{ res.Add(ach,i); thestat |= 12; continue; }
}
if (!model->HasSemanticChecks()) FillCheck(ent,theshare,ach);
else ach->GetMessages (model->Check (i,Standard_False));
if (ach->HasFailed() || ach->HasWarnings())
{ res.Add(ach,i); if (ach->HasFailed()) thestat |= 12; }
}
n0 = nb+1;
}
catch(Standard_Failure) {
n0 = i+1;
raisecheck(ach);
res.Add(ach,i); thestat |= 12;
}
}
return res;
}
// CheckList : Check Fail sur Entites, en Analyse (Read time) ou Verify
//=======================================================================
//function : CheckList
//purpose :
//=======================================================================
Interface_CheckIterator Interface_CheckTool::CheckList ()
{
thestat = 3;
Handle(Interface_InterfaceModel) model = theshare.Model();
Interface_CheckIterator res;
res.SetModel(model);
Standard_Integer i=0, n0 = 1, nb = model->NbEntities();
Handle(Interface_Check) globch = model->GlobalCheck();
if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),globch);
model->VerifyCheck(globch);
if (globch->HasFailed()) { thestat |= 12; res.Add(globch,0); }
errh = 0;
while (n0 <= nb) {
Handle(Interface_Check) ach = new Interface_Check;
Handle(Standard_Transient) ent;
try {
OCC_CATCH_SIGNALS
for (i = n0; i <= nb; i ++) {
if (model->IsReportEntity(i)) {
ach = model->ReportEntity(i)->Check();
if (ach->HasFailed()) { thestat |= 12; res.Add(ach,i); }
}
else {
ent = model->Value(i);
ach->Clear();
ach->SetEntity(ent);
if (!model->HasSemanticChecks()) FillCheck(ent,theshare,ach);
else ach = model->Check (i,Standard_False);
if (ach->HasFailed()) { thestat |= 12; res.Add(ach,i); }
}
}
n0 = nb+1;
}
catch(Standard_Failure) {
n0 = i+1;
raisecheck(ach);
res.Add(ach,i); thestat |= 12;
}
}
return res;
}
// AnalyseCheckList : Fail au chargement des Entites (Read time)
//=======================================================================
//function : AnalyseCheckList
//purpose :
//=======================================================================
Interface_CheckIterator Interface_CheckTool::AnalyseCheckList ()
{
thestat = 2;
Handle(Interface_InterfaceModel) model = theshare.Model();
Interface_CheckIterator res;
res.SetModel(model);
Standard_Integer i=0, n0 = 1, nb = model->NbEntities();
errh = 0;
while (n0 <= nb) {
Handle(Interface_Check) ach = new Interface_Check;
try {
OCC_CATCH_SIGNALS
for (i = n0; i <= nb; i ++) {
if (!model->IsReportEntity(i)) continue;
Handle(Interface_ReportEntity) rep = model->ReportEntity(i);
ach = rep->Check();
if (ach->HasFailed() || ach->HasWarnings())
{ thestat |= 8; res.Add(ach,i); }
}
n0 = nb+1;
}
catch(Standard_Failure) {
n0 = i+1;
raisecheck(ach);
res.Add(ach,i); thestat |= 8;
}
}
return res;
}
// VerifyCheckList : Fail/Warning sur Analyse (Entites chargees OK. Valides ?)
//=======================================================================
//function : VerifyCheckList
//purpose :
//=======================================================================
Interface_CheckIterator Interface_CheckTool::VerifyCheckList ()
{
thestat = 1;
Handle(Interface_InterfaceModel) model = theshare.Model();
Interface_CheckIterator res;
res.SetModel(model);
Standard_Integer i=0, n0 = 1, nb = model->NbEntities();
errh = 0;
while (n0 <= nb) {
Handle(Standard_Transient) ent;
Handle(Interface_Check) ach = new Interface_Check;
try {
OCC_CATCH_SIGNALS
for (i = n0; i <= nb; i ++) {
if (model->IsErrorEntity(i)) continue;
ent = model->Value(i);
ach->Clear();
ach->SetEntity(ent);
if (!model->HasSemanticChecks()) FillCheck(ent,theshare,ach);
else ach = model->Check (i,Standard_False);
if (ach->HasFailed() || ach->HasWarnings())
{ thestat |= 4; res.Add(ach,i); }
}
n0 = nb+1;
}
catch(Standard_Failure) {
n0 = i+1;
raisecheck(ach);
res.Add(ach,i); thestat |= 4;
}
}
return res;
}
// Warnings sur Entites (Read time ou apres)
//=======================================================================
//function : WarningCheckList
//purpose :
//=======================================================================
Interface_CheckIterator Interface_CheckTool::WarningCheckList ()
{
thestat = 3;
Handle(Interface_InterfaceModel) model = theshare.Model();
Interface_CheckIterator res;
res.SetModel(model);
Standard_Integer i=0, n0 = 1, nb = model->NbEntities();
errh = 0;
while (n0 <= nb) {
Handle(Interface_Check) ach = new Interface_Check;
Handle(Standard_Transient) ent;
try {
OCC_CATCH_SIGNALS
for (i = n0; i <= nb; i ++) {
ach->Clear();
ach->SetEntity (ent);
if (model->IsReportEntity(i)) {
Handle(Interface_ReportEntity) rep = model->ReportEntity(i);
if (rep->IsError()) { thestat |= 12; continue; }
ach = rep->Check();
}
ent = model->Value(i);
if (!model->HasSemanticChecks()) FillCheck(ent,theshare,ach);
else ach = model->Check (i,Standard_False);
if (ach->HasFailed()) thestat |= 12;
else if (ach->HasWarnings()) res.Add(ach,i);
}
n0 = nb+1;
}
catch(Standard_Failure) {
n0 = i+1;
raisecheck(ach);
res.Add(ach,i); thestat |= 12;
}
}
return res;
}
//=======================================================================
//function : UnknownEntities
//purpose :
//=======================================================================
Interface_EntityIterator Interface_CheckTool::UnknownEntities ()
{
Handle(Interface_InterfaceModel) model = theshare.Model();
Interface_EntityIterator res;
Standard_Integer nb = model->NbEntities();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (model->IsUnknownEntity(i)) res.GetOneItem(model->Value(i));
}
return res;
}

View File

@@ -0,0 +1,39 @@
-- File: Interface_CopyControl.cdl
-- Created: Thu Apr 8 11:28:45 1993
-- Author: Christian CAILLET
-- <cky@sdsun2>
---Copyright: Matra Datavision 1993
deferred class CopyControl from Interface inherits TShared
---Purpose : This deferred class describes the services required by
-- CopyTool to work. They are very simple and correspond
-- basically to the management of an indexed map.
-- But they can be provided by various classes which can
-- control a Transfer. Each Starting Entity have at most
-- one Result (Mapping one-one)
uses Transient
raises InterfaceError
is
Clear (me : mutable) is deferred;
---Purpose : Clears List of Copy Results. Gets Ready to begin another Copy
-- Process.
Bind (me : mutable; ent : Transient; res : mutable Transient)
---Purpose : Bind a Result to a Starting Entity identified by its Number
raises InterfaceError is deferred;
-- Error if <num> is already bound or is out of range
Search (me; ent : Transient; res : out mutable Transient)
returns Boolean is deferred;
---Purpose : Searches for the Result bound to a Startingf Entity identified
-- by its Number.
-- If Found, returns True and fills <res>
-- Else, returns False and nullifies <res>
end CopyControl;

View File

@@ -0,0 +1 @@
#include <Interface_CopyControl.ixx>

View File

@@ -0,0 +1,48 @@
-- File: Interface_CopyMap.cdl
-- Created: Tue Mar 16 12:19:37 1993
-- Author: Christian CAILLET
-- <cky@phylox>
---Copyright: Matra Datavision 1993
class CopyMap from Interface inherits CopyControl
---Purpose : Manages a Map for the need of single Transfers, such as Copies
-- In such transfer, Starting Entities are read from a unique
-- Starting Model, and each transferred Entity is bound to one
-- and only one Result, which cannot be changed later.
uses Transient, Array1OfTransient from TColStd, InterfaceModel
raises InterfaceError
is
Create (amodel : InterfaceModel) returns mutable CopyMap;
---Purpose : Creates a CopyMap adapted to work from a Model
Clear (me : mutable);
---Purpose : Clears Transfer List. Gets Ready to begin another Transfer
Model (me) returns InterfaceModel is static;
---Purpose : Returns the InterfaceModel used at Creation time
Bind (me : mutable; ent : Transient; res : mutable Transient)
---Purpose : Binds a Starting Entity identified by its Number <num> in the
-- Starting Model, to a Result of Transfer <res>
raises InterfaceError;
-- Error if <num> is already bound to a result, or is out of range
Search (me; ent : Transient; res : out mutable Transient)
returns Boolean;
---Purpose : Search for the result of a Starting Object (i.e. an Entity,
-- identified by its Number <num> in the Starting Model)
-- Returns True if a Result is Bound (and fills <res>)
-- Returns False if no result is Bound (and nullifies <res>)
fields
themod : InterfaceModel; -- Starting Model
theres : Array1OfTransient; -- list of bound Results
end CopyMap;

View File

@@ -0,0 +1,44 @@
#include <Interface_CopyMap.ixx>
#include <Interface_InterfaceError.hxx>
// CopyMap : rien de plus qu une Map passive
Interface_CopyMap::Interface_CopyMap
(const Handle(Interface_InterfaceModel)& amodel)
: theres (0,amodel->NbEntities())
{ themod = amodel; }
void Interface_CopyMap::Clear ()
{
Standard_Integer nb = theres.Upper();
Handle(Standard_Transient) bid; // Null
for (Standard_Integer i = 1; i <= nb; i ++) theres.SetValue(i,bid);
}
Handle(Interface_InterfaceModel) Interface_CopyMap::Model () const
{ return themod; }
void Interface_CopyMap::Bind
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Transient)& res)
{
Standard_Integer num = themod->Number(ent);
if (num == 0 || num > theres.Upper()) Interface_InterfaceError::Raise
("CopyMap : Bind, Starting Entity not issued from Starting Model");
if (!theres.Value(num).IsNull()) Interface_InterfaceError::Raise
("CopyMap : Bind, Starting Entity already bound");
theres.SetValue(num,res);
}
Standard_Boolean Interface_CopyMap::Search
(const Handle(Standard_Transient)& ent,
Handle(Standard_Transient)& res) const
{
Standard_Integer num = themod->Number(ent);
if (num == 0) return Standard_False;
res = theres.Value(num);
return (!res.IsNull());
}

View File

@@ -0,0 +1,204 @@
-- File: Interface_CopyTool.cdl
-- Created: Tue Feb 2 16:22:56 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
class CopyTool from Interface
---Purpose : Performs Deep Copies of sets of Entities
-- Allows to perform Copy of Interface Entities from a Model to
-- another one. Works by calling general services GetFromAnother
-- and GetImplied.
-- Uses a CopyMap to bind a unique Result to each Copied Entity
--
-- It is possible to command Copies of Entities (and those they
-- reference) by call to the General Service Library, or to
-- enforce results for transfer of some Entities (calling Bind)
--
-- A Same CopyTool can be used for several successive Copies from
-- the same Model : either by restarting from scratch (e.g. to
-- copy different parts of a starting Model to several Targets),
-- or incremental : in that case, it is possible to know what is
-- the content of the last increment (defined by last call to
-- ClearLastFlags and queried by call to LastCopiedAfter)
--
-- Works in two times : first, create the list of copied Entities
-- second, pushes them to a target Model (manages also Model's
-- Header) or returns the Result as an Iterator, as desired
--
-- The core action (Copy) works by using ShallowCopy (method
-- attached to each class) and Copy from GeneralLib (itself using
-- dedicated tools). It can be redefined for specific actions.
uses Transient, SequenceOfInteger from TColStd, BitMap,
InterfaceModel, EntityIterator, CopyControl, CopyMap,
GeneralModule, GeneralLib, Protocol from Interface
raises InterfaceError
is
Create (amodel : InterfaceModel; lib : GeneralLib) returns CopyTool;
---Purpose : Creates a CopyTool adapted to work from a Model. Works
-- with a General Service Library, given as an argument
Create (amodel : InterfaceModel; protocol : Protocol from Interface)
returns CopyTool;
---Purpose : Same as above, but Library is defined through a Protocol
Create (amodel : InterfaceModel) returns CopyTool
---Purpose : Same as above, but works with the Active Protocol
raises InterfaceError;
-- Error if no Active Protocol is defined
Model (me) returns InterfaceModel;
---Purpose : Returns the Model on which the CopyTool works
SetControl (me : in out; othermap : mutable CopyControl);
---Purpose : Changes the Map of Result for another one. This allows to work
-- with a more sophisticated Mapping Control than the Standard
-- one which is CopyMap (e.g. TransferProcess from Transfer)
Control (me) returns mutable CopyControl;
---Purpose : Returns the object used for Control
-- -- Basic Operations -- --
Clear (me : in out) is virtual;
---Purpose : Clears Transfer List. Gets Ready to begin another Transfer
NewVoid (me : in out; entfrom : Transient; entto : out mutable Transient)
returns Boolean is virtual protected;
---Purpose : Creates a new void instance (just created) of the same class
-- as <entfrom>. Uses the general service GeneralModule:NewVoid
-- Returns True if OK (Recognize has succeeded), False else
-- (in such a case, the standard method ShallowCopy is called
-- to produce <ento> from <entfrom> : hence it is not void)
--
-- No mapping is managed by this method
Copy (me : in out; entfrom : Transient; entto : out mutable Transient;
mapped : Boolean; errstat : Boolean)
returns Boolean is virtual;
---Purpose : Creates the CounterPart of an Entity (by ShallowCopy), Binds
-- it, then Copies the content of the former Entity to the other
-- one (same Type), by call to the General Service Library
-- It may command the Copy of Referenced Entities
-- Then, its returns True.
--
-- If <mapped> is True, the Map is used to store the Result
-- Else, the Result is simply produced : it can be used to Copy
-- internal sub-parts of Entities, which are not intended to be
-- shared (Strings, Arrays, etc...)
-- If <errstat> is True, this means that the Entity is recorded
-- in the Model as Erroneous : in this case, the General Service
-- for Deep Copy is not called (this could be dangerous) : hence
-- the Counter-Part is produced but empty, it can be referenced.
--
-- This method does nothing and returns False if the Protocol
-- does not recognize <ent>.
-- It basically makes a Deep Copy without changing the Types.
-- It can be redefined for special uses.
Implied (me : in out; entfrom : Transient; entto : mutable Transient)
is virtual private;
---Purpose : Renews the Implied References of one already Copied Entity
Transferred (me : in out; ent : Transient) returns mutable Transient
---Purpose : Transfers one Entity, if not yet bound to a result
-- Remark : For an Entity which is reported in the Starting Model,
-- the ReportEntity will also be copied with its Content if it
-- has one (at least ShallowCopy; Complete Copy if the Protocol
-- recognizes the Content : see method Copy)
raises InterfaceError;
-- This method can raise any kind of Interface exception.
-- Especially if <ent> is not contained in Starting Model.
Bind (me : in out; ent : Transient; res : mutable Transient)
---Purpose : Defines a Result for the Transfer of a Starting object.
-- Used by method Transferred (which performs a normal Copy),
-- but can also be called to enforce a result : in the latter
-- case, the enforced result must be compatible with the other
-- Transfers which are performed
raises InterfaceError;
-- Error if a Result is already bound with this Starting Object
Search (me; ent : Transient; res : out mutable Transient)
returns Boolean;
---Purpose : Search for the result of a Starting Object (i.e. an Entity)
-- Returns True if a Result is Bound (and fills "result")
-- Returns False if no result is Bound
ClearLastFlags (me : in out);
---Purpose : Clears LastFlags only. This allows to know what Entities are
-- copied after its call (see method LastCopiedAfter). It can be
-- used when copies are done by increments, which must be
-- distinghished. ClearLastFlags is also called by Clear.
LastCopiedAfter (me; numfrom : Integer;
ent : out Transient; res : out mutable Transient) returns Integer;
---Purpose : Returns an copied Entity and its Result which were operated
-- after last call to ClearLastFlags. It returns the first
-- "Last Copied Entity" which Number follows <numfrom>, Zero if
-- none. It is used in a loop as follow :
-- Integer num = 0;
-- while ( (num = CopyTool.LastCopiedAfter(num,ent,res)) ) {
-- .. Process Starting <ent> and its Result <res>
-- }
-- -- General Operations -- --
TransferEntity (me : in out; ent : Transient)
---Purpose : Transfers one Entity and records result into the Transfer List
-- Calls method Transferred
raises InterfaceError;
-- This method can raise any kind of Interface exception
RenewImpliedRefs (me : in out) raises InterfaceError;
---Purpose : Renews the Implied References. These References do not involve
-- Copying of referenced Entities. For such a Reference, if the
-- Entity which defines it AND the referenced Entity are both
-- copied, then this Reference is renewed. Else it is deleted in
-- the copied Entities.
-- Remark : this concerns only some specific references, such as
-- "back pointers".
FillModel (me : in out; bmodel : mutable InterfaceModel)
raises InterfaceError;
---Purpose : Fills a Model with the result of the transfer (TransferList)
-- Commands copy of Header too, and calls RenewImpliedRefs
CompleteResult (me; withreports : Boolean = Standard_False)
returns EntityIterator;
---Purpose : Returns the complete list of copied Entities
-- If <withreports> is given True, the entities which were
-- reported in the Starting Model are replaced in the list
-- by the copied ReportEntities
RootResult (me; withreports : Boolean = Standard_False)
returns EntityIterator;
---Purpose : Returns the list of Root copied Entities (those which were
-- asked for copy by the user of CopyTool, not by copying
-- another Entity)
Destroy (me: in out) is virtual;
---C++: alias "Standard_EXPORT virtual ~Interface_CopyTool() { Destroy(); }"
fields
themod : InterfaceModel; -- Starting Model & Entities
themap : CopyControl; -- Basic Copy Results
therep : CopyMap; -- Report Results (if any)
thelst : BitMap;
thelib : GeneralLib is protected; -- (heirs can use it)
thelev : Integer; -- Current recursive Call Level (Root = 0)
therts : SequenceOfInteger from TColStd; -- "Root" Entities (thelev = 0)
theimp : Boolean; -- are Implied Refs renewed
theent : Transient; -- Last processed
themdu : GeneralModule;
theCN : Integer;
end CopyTool;

View File

@@ -0,0 +1,315 @@
#include <Interface_CopyTool.ixx>
#include <Interface_GeneralModule.hxx>
#include <Interface_ReportEntity.hxx>
#include <Interface_InterfaceError.hxx>
#include <TCollection_HAsciiString.hxx>
// Se souvenir qu une version plus riche de CopyTool existe : c est
// TransferDispatch (package Transfer). Cette classe offre beaucoup plus de
// possibilite (parametrage des actions, gestion du Mapping ...)
// Mais le principe (transfert en 2 passes) reste le meme, a savoir :
// Passe 1 normale : les entites a transferer sont designees, elles entrainent
// leurs sous-references vraies
// Passe 2 : une fois tous les transferts faits, les relations "Imply" sont
// mises, pour les entites designees ET QUI ONT ETE AUSSI TRANSFEREES, la
// relation est reconduite (pas de nouveau Share)
// #####################################################################
// .... CONSTRUCTEURS ....
Interface_CopyTool::Interface_CopyTool
(const Handle(Interface_InterfaceModel)& amodel,
const Interface_GeneralLib& lib)
: thelib (lib) , thelst (amodel->NbEntities())
{
thelst.Init(Standard_False);
themod = amodel;
themap = new Interface_CopyMap (amodel);
therep = new Interface_CopyMap (amodel);
thelev = 0; theimp = Standard_False;
}
Interface_CopyTool::Interface_CopyTool
(const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_Protocol)& protocol)
: thelib (protocol) , thelst (amodel->NbEntities())
{
thelst.Init(Standard_False);
themod = amodel;
themap = new Interface_CopyMap (amodel);
therep = new Interface_CopyMap (amodel);
thelev = 0; theimp = Standard_False;
}
Interface_CopyTool::Interface_CopyTool
(const Handle(Interface_InterfaceModel)& amodel)
: thelib (Interface_Protocol::Active()) , thelst (amodel->NbEntities())
{
if (Interface_Protocol::Active().IsNull()) Interface_InterfaceError::Raise
("Interface CopyTool : Create with Active Protocol undefined");
thelst.Init(Standard_False);
themod = amodel;
themap = new Interface_CopyMap (amodel);
therep = new Interface_CopyMap (amodel);
thelev = 0; theimp = Standard_False;
}
Handle(Interface_InterfaceModel) Interface_CopyTool::Model () const
{ return themod; }
void Interface_CopyTool::SetControl
(const Handle(Interface_CopyControl)& othermap)
{ themap = othermap; }
Handle(Interface_CopyControl) Interface_CopyTool::Control () const
{ return themap; }
// #####################################################################
// .... Actions Individuelles ....
void Interface_CopyTool::Clear ()
{
themap->Clear();
therep->Clear();
thelev = 0; theimp = Standard_False;
therts.Clear();
ClearLastFlags();
}
Standard_Boolean Interface_CopyTool::NewVoid
(const Handle(Standard_Transient)& entfrom,
Handle(Standard_Transient)& entto)
{
if (entfrom == theent) {
if (themdu.IsNull()) return Standard_False;
return themdu->NewVoid(theCN,entto);
}
theent = entfrom;
Standard_Boolean res = thelib.Select (entfrom,themdu,theCN);
if (res) res = themdu->NewVoid (theCN,entto);
if (!res) res = themdu->NewCopiedCase (theCN,entfrom,entto,*this);
// if (!res) entto = entfrom->ShallowCopy(); sorry, nothing more possible
return res;
}
Standard_Boolean Interface_CopyTool::Copy
(const Handle(Standard_Transient)& entfrom,
Handle(Standard_Transient)& entto,
const Standard_Boolean mapped, const Standard_Boolean errstat)
{
Standard_Boolean res = Standard_True;
if (entfrom == theent) {
if (themdu.IsNull()) res = Standard_False;
} else {
theent = entfrom;
res = thelib.Select(entfrom,themdu,theCN);
}
if (!res) {
// Built-in :
if (entfrom.IsNull()) return res;
if (entfrom->DynamicType() == STANDARD_TYPE(TCollection_HAsciiString)) {
entto = new TCollection_HAsciiString
( Handle(TCollection_HAsciiString)::DownCast(entfrom)->ToCString() );
res = Standard_True;
}
return res;
}
// On cree l Entite vide (NewVoid), la Copie reste a faire
res = NewVoid(entfrom,entto);
if (mapped) themap->Bind (entfrom,entto); // Mapper avant de continuer ...
// A present, on effectue la Copie (selon cas; si ShallowCopy ne suffit pas :
// c est <themdu> qui decide)
// Une Entite en Erreur n est pas copiee (pas de sens et c est risque ...)
// Cependant, elle est "Copiee a Vide (NewVoid)" donc referencable
if (!errstat) themdu->CopyCase(theCN,entfrom,entto,*this);
return res;
}
void Interface_CopyTool::Implied
(const Handle(Standard_Transient)& entfrom,
const Handle(Standard_Transient)& entto)
{
Handle(Interface_GeneralModule) module;
Standard_Integer CN;
if (thelib.Select(entfrom,module,CN))
module->RenewImpliedCase(CN,entfrom,entto,*this);
}
// .... Alimentation de la Map ....
Handle(Standard_Transient) Interface_CopyTool::Transferred
(const Handle(Standard_Transient)& ent)
{
Handle(Standard_Transient) res;
if (ent.IsNull()) return res; // Copie d un Null : tres simple ...
Standard_Integer nument = themod->Number(ent);
// <nument> == 0 -> Peut etre une sous-partie non partagee ...
// On accepte mais on se protege contre un bouclage
if (nument == 0 && thelev > 100) Interface_InterfaceError::Raise
("CopyTool : Transferred, Entity is not contained in Starting Model");
if (!themap->Search(ent,res)) { // deja transfere ? sinon, le faire
// On opere la Copie (enfin, on tente)
// En cas d echec, rien n est enregistre
if (!Copy(ent,res, (nument != 0), themod->IsRedefinedContent(nument) ))
return res;
thelev ++;
if (nument != 0) thelst.SetTrue (nument);
Handle(Interface_ReportEntity) rep;
if (nument != 0) rep = themod->ReportEntity (nument);
if (!rep.IsNull()) {
// ATTENTION ATTENTION, si ReportEntity : Copier aussi Content et refaire une
// ReportEntity avec les termes initiaux
if (rep->IsUnknown()) therep->Bind
(ent, new Interface_ReportEntity(res));
else {
Handle(Standard_Transient) contfrom, contto;
contfrom = rep->Content();
Handle(Interface_ReportEntity) repto =
new Interface_ReportEntity (rep->Check(),res);
if (!contfrom.IsNull()) {
if (contfrom == ent) contto = res;
else Copy (contfrom,contto, themod->Contains(contfrom), Standard_False);
repto->SetContent (contto);
}
therep->Bind (ent,repto);
}
}
// Gerer le niveau d imbrication (0 = racine du transfert)
thelev --;
}
if (thelev == 0 && nument > 0) therts.Append(nument);
return res;
}
void Interface_CopyTool::Bind
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Transient)& res)
{
Standard_Integer num = themod->Number(ent);
themap->Bind (ent,res);
thelst.SetTrue (num);
}
Standard_Boolean Interface_CopyTool::Search
(const Handle(Standard_Transient)& ent,
Handle(Standard_Transient)& res) const
{ return themap->Search (ent,res); }
// ## ## ## ## ## ## ## ## ## ## ## ## ##
// LastFlag
void Interface_CopyTool::ClearLastFlags ()
{ thelst.Init(Standard_False); }
Standard_Integer Interface_CopyTool::LastCopiedAfter
(const Standard_Integer numfrom,
Handle(Standard_Transient)& ent, Handle(Standard_Transient)& res) const
{
Standard_Integer nb = thelst.Length();
for (Standard_Integer num = numfrom + 1; num <= nb; num ++) {
if (thelst.Value(num)) {
ent = themod->Value(num);
if (themap->Search(ent,res)) return num;
}
}
return 0;
}
// #########################################################################
// .... Actions Generales ....
void Interface_CopyTool::TransferEntity
(const Handle(Standard_Transient)& ent)
{ Handle(Standard_Transient) res = Transferred(ent); }
void Interface_CopyTool::RenewImpliedRefs ()
{
if (theimp) return; // deja fait
theimp = Standard_True;
// Transfert Passe 2 : recuperation des relations non "Share" (mais "Imply")
// c-a-d portant sur des entites qui ont pu ou non etre transferees
// (Et que la 1re passe n a pas copie mais laisse en Null)
// N.B. : on devrait interdire de commander des nouveaux transferts ...
Standard_Integer nb = themod->NbEntities();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) ent = themod->Value(i);
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue; // entite pas transferee
// Reconduction des references "Imply". Attention, ne pas copier si non chargee
Handle(Interface_ReportEntity) rep;
if (!therep->Search(ent,rep)) Implied (ent,res);
else if (!rep->HasNewContent()) Implied (ent,res);
}
}
void Interface_CopyTool::FillModel
(const Handle(Interface_InterfaceModel)& bmodel)
{
// Travaux preparatoires concernant les modeles
// On commence : cela implique le Header
bmodel->Clear();
bmodel->GetFromAnother(themod);
// Transfert Passe 1 : On prend les Entites prealablement copiees
Interface_EntityIterator list = CompleteResult(Standard_True);
bmodel->GetFromTransfer(list);
// Transfert Passe 2 : recuperation des relations non "Share" (mais "Imply")
RenewImpliedRefs();
}
Interface_EntityIterator Interface_CopyTool::CompleteResult
(const Standard_Boolean withreports) const
{
Interface_EntityIterator iter;
Standard_Integer nb = themod->NbEntities();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) ent = themod->Value(i);
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue;
if (withreports) {
Handle(Interface_ReportEntity) rep;
if (therep->Search(ent,rep)) res = rep;
}
iter.GetOneItem(res);
}
return iter;
}
Interface_EntityIterator Interface_CopyTool::RootResult
(const Standard_Boolean withreports) const
{
Interface_EntityIterator iter;
Standard_Integer nb = therts.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
Standard_Integer j = therts.Value(i);
Handle(Standard_Transient) ent = themod->Value(j);
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue;
if (withreports) {
Handle(Interface_ReportEntity) rep;
if (therep->Search(ent,rep)) res = rep;
}
iter.GetOneItem(res);
}
return iter;
}
void Interface_CopyTool::Destroy(){}

View File

@@ -0,0 +1,108 @@
-- File: EntityCluster.cdl
-- Created: Mon Nov 2 16:03:55 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
private class EntityCluster from Interface inherits TShared
---Purpose : Auxiliary class for EntityList. An EntityList designates an
-- EntityCluster, which brings itself an fixed maximum count of
-- Entities. If it is full, it gives access to another cluster
-- ("Next"). This class is intended to give a good compromise
-- between access time (faster than a Sequence, good for little
-- count) and memory use (better than a Sequence in any case,
-- overall for little count, better than an Array for a very
-- little count. It is designed for a light management.
-- Remark that a new Item may not be Null, because this is the
-- criterium used for "End of List"
uses EntityIterator, Transient
raises OutOfRange, NullObject
is
Create returns mutable EntityCluster;
---Purpose : Creates an empty, non-chained, EntityCluster
Create (ent : any Transient) returns mutable EntityCluster;
---Purpose : Creates a non-chained EntityCluster, filled with one Entity
Create (ec : mutable EntityCluster) returns mutable EntityCluster;
---Purpose : Creates an empty EntityCluster, chained with another one
-- (that is, put BEFORE this other one in the list)
Create (ant : any Transient; ec : mutable EntityCluster)
returns mutable EntityCluster;
---Purpose : Creates an EntityCluster, filled with a first Entity, and
-- chained to another EntityCluster (BEFORE it, as above)
Append (me : mutable; ent : any Transient)
---Purpose : Appends an Entity to the Cluster. If it is not full, adds the
-- entity directly inside itself. Else, transmits to its Next
-- and Creates it if it does not yet exist
raises NullObject is static;
-- Error if <ent> is Null
Remove (me : mutable; ent : any Transient) returns Boolean
---Purpose : Removes an Entity from the Cluster. If it is not found, calls
-- its Next one to do so.
-- Returns True if it becomes itself empty, False else
-- (thus, a Cluster which becomes empty is deleted from the list)
raises NullObject is static;
-- Error if <ent> is Null
Remove (me : mutable; num : Integer) returns Boolean
---Purpose : Removes an Entity from the Cluster, given its rank. If <num>
-- is greater than NbLocal, calls its Next with (num - NbLocal),
-- Returns True if it becomes itself empty, False else
raises OutOfRange is static;
-- Raises an Exception if there is no Next to do so.
NbEntities (me) returns Integer is static;
---Purpose : Returns total count of Entities (including Next)
Value (me; num : Integer) returns any Transient
---Purpose : Returns the Entity identified by its rank in the list
-- (including Next)
raises OutOfRange is static;
-- Error if num less than 1 or num more then NbEntities
---C++ : return const &
SetValue (me : mutable; num : Integer; ent : any Transient)
---Purpose : Changes an Entity given its rank.
raises OutOfRange, NullObject is static;
-- Error if <num> is not in [1 - NbEntities], or if <ent> is Null
FillIterator (me; iter : in out EntityIterator) is static;
---Purpose : Fills an Iterator with designated Entities (includes Next)
-- -- Internal Queries, also used by EntityList -- --
IsLocalFull (me) returns Boolean is static private;
---Purpose : Returns True if all the set of entities local to a Cluster is
-- full. Used by EntityList.
NbLocal (me) returns Integer is static private;
---Purpose : Returns count of entities in the local set (without Next)
-- Entities can then be read normally by method Value
HasNext (me) returns Boolean is static private;
---Purpose : Returns True if a Cluster has a Next
Next (me) returns mutable EntityCluster is static private;
---Purpose : Returns Next Cluster in the chain
fields
theents : Transient[4]; -- 4 : best compromise for memory use
thenext : EntityCluster;
friends
class EntityList -- of which EntityCluster stores content
end EntityCluster;

View File

@@ -0,0 +1,156 @@
#include <Interface_EntityCluster.ixx>
#include <Standard_OutOfRange.hxx>
#include <Standard_NullObject.hxx>
// Un Cluster, ce sont 4 entites qui se suivent (dans le principe, nombre fixe,
// meme si pas 4). Elles sont remplies depuis 0. Il y a donc autant d Entites
// que de Handles non Nuls, plus le fait qu ils sont remplis dans l ordre
// Ainsi (avec Next), on consomme 5 Handles pour 4 Entites, avec une pointe
// pour 1 et 2 Entites (on reste a 5 Handles)
// Suppression : On retasse le Cluster pour que les Nulls soient tjrs a la fin
// .... CONSTRUCTEURS ....
Interface_EntityCluster::Interface_EntityCluster () { }
Interface_EntityCluster::Interface_EntityCluster
(const Handle(Standard_Transient)& ent)
{ theents[0] = ent; }
Interface_EntityCluster::Interface_EntityCluster
(const Handle(Interface_EntityCluster)& ec)
{ thenext = ec; }
Interface_EntityCluster::Interface_EntityCluster
(const Handle(Standard_Transient)& ent,
const Handle(Interface_EntityCluster)& ec)
{ theents[0] = ent; thenext = ec; }
// .... AJOUT - SUPPRESSION ....
void Interface_EntityCluster::Append
(const Handle(Standard_Transient)& ent)
{
if (ent.IsNull()) Standard_NullObject::Raise("Interface_EntityCluster Append");
if (theents[0].IsNull()) theents[0] = ent;
else if (theents[1].IsNull()) theents[1] = ent;
else if (theents[2].IsNull()) theents[2] = ent;
else if (theents[3].IsNull()) theents[3] = ent;
else { // Si celui-ci est plein ...
if (thenext.IsNull()) thenext = new Interface_EntityCluster(ent);
else thenext->Append(ent);
}
}
Standard_Boolean Interface_EntityCluster::Remove
(const Handle(Standard_Transient)& ent)
{
if (ent.IsNull()) Standard_NullObject::Raise("Interface_EntityCluster Remove");
Standard_Integer i;
// <ent> est-il ici ? si oui, on a son rang
if (ent == theents[0]) i = 1;
else if (ent == theents[1]) i = 2;
else if (ent == theents[2]) i = 3;
else if (ent == theents[3]) i = 4;
// Sinon, passer au suivant, qui peut du coup devenir vide ->
// On enleve le cluster vide de la liste (en principe cest le dernier)
else { // Pas trouve dans celui-ci ...
if (thenext.IsNull()) return Standard_False;
Standard_Integer res = thenext->Remove(ent);
if (res) thenext = thenext->Next();
return Standard_False;
}
return Remove(i);
}
Standard_Boolean Interface_EntityCluster::Remove
(const Standard_Integer num)
{
if (num < 1) Standard_OutOfRange::Raise("EntityCluster : Remove");
Standard_Integer n = NbLocal();
if (num > n) {
if (thenext.IsNull()) Standard_OutOfRange::Raise("EntityCluster : Remove");
Standard_Boolean res = thenext->Remove (num-n);
if (res) thenext = thenext->Next();
return Standard_False;
}
for (Standard_Integer j = num; j < n; j --) theents[j-1] = theents[j];
theents[3].Nullify(); // On Nullify par la fin
return (n == 1); // Ancien NbLocal == 1 -> devient nul
}
// .... ACCES AUX DONNEES ....
Standard_Integer Interface_EntityCluster::NbEntities() const
{
Standard_Integer nb = NbLocal();
if (!thenext.IsNull()) nb += thenext->NbEntities();
return nb;
}
const Handle(Standard_Transient)& Interface_EntityCluster::Value
(const Standard_Integer num) const
{
Standard_Integer nb = NbLocal();
if (num <= 0) Standard_OutOfRange::Raise("Interface EntityCluster : Value");
if (num > nb) {
if (thenext.IsNull()) Standard_OutOfRange::Raise
("Interface EntityCluster : Value");
return thenext->Value(num-nb);
}
return theents[num-1]; // numerotation a partir de 0
}
void Interface_EntityCluster::SetValue
(const Standard_Integer num, const Handle(Standard_Transient)& ent)
{
if (ent.IsNull()) Standard_NullObject::Raise("Interface_EntityCluster SetValue");
Standard_Integer nb = NbLocal();
if (num <= 0) Standard_OutOfRange::Raise("Interface EntityCluster : SetValue");
if (num > nb) {
if (thenext.IsNull()) Standard_OutOfRange::Raise
("Interface EntityCluster : SetValue");
thenext->SetValue(num-nb,ent);
}
else theents[num-1] = ent; // numerotation a partir de 0
}
void Interface_EntityCluster::FillIterator
(Interface_EntityIterator& iter) const
{
if (!theents[0].IsNull()) iter.GetOneItem(theents[0]);
if (!theents[1].IsNull()) iter.GetOneItem(theents[1]);
if (!theents[2].IsNull()) iter.GetOneItem(theents[2]);
if (!theents[3].IsNull()) iter.GetOneItem(theents[3]);
if (!thenext.IsNull()) thenext->FillIterator(iter);
}
// .... Actions atomiques internes ....
Standard_Boolean Interface_EntityCluster::IsLocalFull () const
{
// Solaris Forte C++ compiler insisted it couldn't cast this,
// even though it seems to do so elsewhere
Handle_Standard_Transient tmp = Handle_Standard_Transient(theents[3]);
return ( !tmp.IsNull() );
}
Standard_Integer Interface_EntityCluster::NbLocal () const
{
Standard_Integer nb;
if (!theents[3].IsNull()) nb = 4;
else if (!theents[2].IsNull()) nb = 3;
else if (!theents[1].IsNull()) nb = 2;
else if (!theents[0].IsNull()) nb = 1;
else nb = 0;
return nb;
}
Standard_Boolean Interface_EntityCluster::HasNext () const
{ return (!thenext.IsNull()); }
Handle(Interface_EntityCluster) Interface_EntityCluster::Next () const
{ return thenext; }

View File

@@ -0,0 +1,83 @@
-- File: EntityIterator.cdl
-- Created: Mon Feb 3 14:08:35 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class EntityIterator from Interface
---Purpose : Defines an Iterator on Entities, complying with GraphTools
-- needs. Allows considering of various criteria
uses Transient, HSequenceOfTransient from TColStd,
IntVal, InterfaceModel
raises NoMoreObject, NoSuchObject
is
Create returns EntityIterator;
---Purpose : Defines an empty iterator (see AddList & AddItem)
Create (list : HSequenceOfTransient) returns EntityIterator;
---Purpose : Defines an iterator on a list, directly i.e. without copying it
AddList (me : in out; list : HSequenceOfTransient);
---Purpose : Gets a list of entities and adds its to the iteration list
AddItem (me : in out; anentity : any Transient);
---Purpose : Adds to the iteration list a defined entity
GetOneItem (me : in out; anentity : any Transient) is static;
---Purpose : same as AddItem (kept for compatibility)
Reset (me : in out) is protected;
---Purpose : Allows subclasses of EntityIterator to reevaluate an iteration
SelectType (me : in out; atype : Type; keep : Boolean);
---Purpose : Selects entities with are Kind of a given type, keep only
-- them (is keep is True) or reject only them (if keep is False)
NbEntities (me) returns Integer is static;
---Purpose : Returns count of entities which will be iterated on
-- Calls Start if not yet done
NbTyped (me; type : Type) returns Integer is static;
---Purpose : Returns count of entities of a given type (kind of)
Typed (me; type : Type) returns EntityIterator;
---Purpose : Returns the list of entities of a given type (kind of)
Start (me) is virtual;
---Purpose : Allows re-iteration (useless for the first iteration)
More (me) returns Boolean;
---Purpose : Says if there are other entities (vertices) to iterate
-- the first time, calls Start
Next (me) raises NoMoreObject;
---Purpose : Sets iteration to the next entity (vertex) to give
Value (me) returns any Transient raises NoSuchObject;
---Purpose : Returns the current Entity iterated, to be used by Interface
-- tools or by GraphTools (where Entity is a Vertex)
---C++ : return const &
Content (me) returns HSequenceOfTransient;
---Purpose : Returns the content of the Iterator, accessed through a Handle
-- to be used by a frontal-engine logic
-- Returns an empty Sequence if the Iterator is empty
-- Calls Start if not yet done
Destroy (me : in out) is virtual;
---Purpose : Clears data of iteration
---C++: alias "Standard_EXPORT virtual ~Interface_EntityIterator() { Destroy();}"
fields
thecurr : IntVal;
thelist : HSequenceOfTransient;
end EntityIterator;

View File

@@ -0,0 +1,142 @@
#include <Interface_EntityIterator.ixx>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
// Iterateur pour ecriture for, ou while avec Next en fin :
// for (creer iterateur; iter.More(); iter.Next()) { val = iter.Value(); ... }
// .... Definitions initiales : en particulier celles requises pour
// les outils de graphe (construction avec le graphe, avec un vertex)
Interface_EntityIterator::Interface_EntityIterator ()
{
// thecurr = new Interface_IntVal;
// thecurr->CValue() = 0;
// thelist = new TColStd_HSequenceOfTransient(); // constructeur vide
// thelist sera construit au premier Add (quelquefois, il nyena pas)
}
Interface_EntityIterator::Interface_EntityIterator
(const Handle(TColStd_HSequenceOfTransient)& list)
{
thecurr = new Interface_IntVal;
thecurr->CValue() = 0;
thelist = list;
}
void Interface_EntityIterator::AddList
(const Handle(TColStd_HSequenceOfTransient)& list)
{
if (thelist.IsNull()) thelist = new TColStd_HSequenceOfTransient();
if (thecurr.IsNull()) thecurr = new Interface_IntVal;
thecurr->CValue() = 0;
thelist->Append(list);
}
void Interface_EntityIterator::AddItem
(const Handle(Standard_Transient)& anentity)
{
if (anentity.IsNull()) return;
if (thecurr.IsNull()) thecurr = new Interface_IntVal;
if (thelist.IsNull()) thelist = new TColStd_HSequenceOfTransient();
thecurr->CValue() = 0;
thelist->Append(anentity);
}
void Interface_EntityIterator::GetOneItem
(const Handle(Standard_Transient)& anentity)
{ AddItem(anentity); }
void Interface_EntityIterator::Reset ()
{
if (thecurr.IsNull()) thecurr = new Interface_IntVal;
thecurr->CValue() = 0;
thelist = new TColStd_HSequenceOfTransient();
}
// .... Fonctionnalites de tri prealable a l'iteration ....
// Facon "bete" : supprimer les termes qui ne conviennent pas : lent !
// Mieux vaut refaire une autre sequence a cote
void Interface_EntityIterator::SelectType
(const Handle(Standard_Type)& atype, const Standard_Boolean keep)
{
if (thelist.IsNull()) return;
Standard_Integer i, n = thelist->Length();
Handle(TColStd_HSequenceOfTransient) nlist = new TColStd_HSequenceOfTransient();
for (i = 1 ; i <= n ; i ++) {
if (thelist->Value(i)->IsKind(atype) == keep) nlist->Append(thelist->Value(i));
}
thelist = nlist;
}
// .... Iteration proprement dite ....
Standard_Integer Interface_EntityIterator::NbEntities () const
{
if (thelist.IsNull()) return 0;
if (!thecurr.IsNull() && thecurr->Value() == 0) Start();
return thelist->Length();
}
Standard_Integer Interface_EntityIterator::NbTyped
(const Handle(Standard_Type)& atype) const
{
Standard_Integer res = 0;
if (thelist.IsNull()) return res;
Standard_Integer i, n = thelist->Length();
for (i = 1 ; i <= n ; i ++) {
if (thelist->Value(i)->IsKind(atype)) res ++;
}
return res;
}
Interface_EntityIterator Interface_EntityIterator::Typed
(const Handle(Standard_Type)& atype) const
{
Interface_EntityIterator res;
if (thelist.IsNull()) return res;
Standard_Integer i, n = thelist->Length();
for (i = 1 ; i <= n ; i ++) {
if (thelist->Value(i)->IsKind(atype)) res.AddItem (thelist->Value(i));
}
return res;
}
void Interface_EntityIterator::Start () const
{ if (!thecurr.IsNull()) thecurr->CValue() = 1 ; } // peut etre redefini ...
Standard_Boolean Interface_EntityIterator::More () const
{
if (thecurr.IsNull()) return Standard_False;
if (thecurr->Value() == 0) Start(); // preparation de l iteration
if (thelist.IsNull()) return Standard_False;
return (thecurr->Value() <= thelist->Length());
}
void Interface_EntityIterator::Next () const
{ thecurr->CValue() ++; } // Next ne verifie rien : soin laisse a Value
const Handle(Standard_Transient)& Interface_EntityIterator::Value () const
{
// NbEntity pas const (on ne sait pas comment il est implemente apres tout)
if (thelist.IsNull()) Standard_NoSuchObject::Raise("Interface_EntityIterator");
if (thecurr->Value() < 1 || thecurr->Value() > thelist->Length())
Standard_NoSuchObject::Raise("Interface_EntityIterator");
return thelist->Value(thecurr->Value());
}
Handle(TColStd_HSequenceOfTransient) Interface_EntityIterator::Content () const
{
if (!thecurr.IsNull() && thecurr->Value() == 0) Start();
if (thelist.IsNull()) return new TColStd_HSequenceOfTransient(); // vide
return thelist;
}
void Interface_EntityIterator::Destroy ()
{ thecurr.Nullify(); } // redevient vide !

View File

@@ -0,0 +1,101 @@
-- File: EntityList.cdl
-- Created: Mon Nov 2 15:44:34 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class EntityList from Interface -- inherits Storable
---Purpose : This class defines a list of Entities (Transient Objects),
-- it can be used as a field of other Transient classes, with
-- these features :
-- - oriented to define a little list, that is, slower than an
-- Array or a Map of Entities for a big count (about 100 and
-- over), but faster than a Sequence
-- - allows to work as a Sequence, limited to Clear, Append,
-- Remove, Access to an Item identified by its rank in the list
-- - space saving, compared to a Sequence, especially for little
-- amounts; better than an Array for a very little amount (less
-- than 10) but less good for a greater amount
--
-- Works in conjunction with EntityCluster
-- An EntityList gives access to a list of Entity Clusters, which
-- are chained (in one sense : Single List)
-- Remark : a new Item may not be Null, because this is the
-- criterium used for "End of List"
uses Type, Transient, EntityCluster, EntityIterator
raises OutOfRange, InterfaceError, NullObject
is
Create returns EntityList;
---Purpose : Creates a List as beeing empty
Clear (me : in out) is static;
---Purpose : Clears the List
Append (me : in out; ent : any Transient)
---Purpose : Appends an Entity, that is to the END of the list
-- (keeps order, but works slowerly than Add, see below)
raises NullObject is static;
-- Error if <ent> is Null
Add (me : in out; ent : any Transient)
---Purpose : Adds an Entity to the list, that is, with NO REGARD about the
-- order (faster than Append if count becomes greater than 10)
raises NullObject is static;
-- Error if <ent> is Null
Remove (me : in out; ent : any Transient)
---Purpose : Removes an Entity from the list, if it is there
raises NullObject is static;
-- Error if <ent> is Null
Remove (me : in out; num : Integer)
---Purpose : Removes an Entity from the list, given its rank
raises OutOfRange is static;
-- Error if <num> is not in range [1 - NbEntities]
IsEmpty (me) returns Boolean is static;
---Purpose : Returns True if the list is empty
NbEntities (me) returns Integer is static;
---Purpose : Returns count of recorded Entities
Value (me; num : Integer) returns any Transient
---Purpose : Returns an Item given its number. Beware about the way the
-- list was filled (see above, Add and Append)
raises OutOfRange is static;
-- Error if <num> is not in range [1 - NbEntities]
---C++ : return const &
SetValue (me : in out; num : Integer; ent : any Transient)
---Purpose : Returns an Item given its number. Beware about the way the
-- list was filled (see above, Add and Append)
raises OutOfRange, NullObject is static;
-- Error if <num> is not in [1 - NbEntities], or if <ent> is Null
FillIterator (me; iter : in out EntityIterator) is static;
---Purpose : fills an Iterator with the content of the list
-- (normal way to consult a list which has been filled with Add)
NbTypedEntities (me; atype : any Type) returns Integer is static;
---Purpose : Returns count of Entities of a given Type (0 : none)
TypedEntity (me; atype : any Type; num : Integer = 0) returns any Transient
---Purpose : Returns the Entity which is of a given type.
-- If num = 0 (D), there must be ONE AND ONLY ONE
-- If num > 0, returns the num-th entity of this type
raises InterfaceError is static;
-- Error if none or several found (num=0), or not enough (num>0)
fields
theval : Transient; -- Null(zero), a Transient(one), EntityCluster(more)
-- Mandatory only one field
end EntityList;

View File

@@ -0,0 +1,199 @@
#include <Interface_EntityList.ixx>
#include <Interface_EntityCluster.hxx>
#include <Interface_InterfaceError.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_NullObject.hxx>
// Une EntityList, c est au fond un "Handle" bien entoure :
// S il est nul, la liste est vide
// Si c est une Entite, la liste comprend cette entite et rien d autre
// Si c est un EntityCluster, il definit (avec ses Next eventuels) le contenu
// de la liste
Interface_EntityList::Interface_EntityList () { }
void Interface_EntityList::Clear ()
{ theval.Nullify(); }
// .... EDITIONS (ajout-suppression) ....
void Interface_EntityList::Append
(const Handle(Standard_Transient)& ent)
{
if (ent.IsNull()) Standard_NullObject::Raise("Interface_EntityList Append");
if (theval.IsNull()) { theval = ent; return; }
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (!ec.IsNull()) ec->Append(ent); // EntityCluster
else { // reste InterfaceEntity ...
Handle(Interface_EntityCluster) ec = new Interface_EntityCluster(theval);
ec->Append(ent);
theval = ec;
}
}
// Difference avec Append : on optimise, en evitant la recursivite
// En effet, quand un EntityCluster est plein, Append transmet au Next
// Ici, EntityList garde le controle, le temps de traitement reste le meme
// Moyennant quoi, l ordre n est pas garanti
void Interface_EntityList::Add
(const Handle(Standard_Transient)& ent)
{
if (ent.IsNull()) Standard_NullObject::Raise("Interface_EntityList Add");
if (theval.IsNull()) { theval = ent; return; }
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (!ec.IsNull()) { // EntityCluster
if (ec->IsLocalFull()) theval = new Interface_EntityCluster(ent,ec);
else ec->Append (ent);
} else { // reste InterfaceEntity ...
Handle(Interface_EntityCluster) ec = new Interface_EntityCluster(theval);
ec->Append(ent);
theval = ec;
}
}
// Remove : Par Identification d Item a supprimer, ou par Rang
// Identification : Item supprime ou qu il soit
// N.B.: La liste peut devenir vide ... cf retour Remove de Cluster
void Interface_EntityList::Remove (const Handle(Standard_Transient)& ent)
{
if (ent.IsNull()) Standard_NullObject::Raise("Interface_EntityList Remove");
if (theval.IsNull()) return;
if (theval == ent) {
theval.Nullify();
return;
}
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (ec.IsNull()) return; // Une seule Entite et pas la bonne
Standard_Boolean res = ec->Remove(ent);
if (res) theval.Nullify();
}
// Remove par rang : tester OutOfRange
void Interface_EntityList::Remove (const Standard_Integer num)
{
if (theval.IsNull()) Standard_OutOfRange::Raise("EntityList : Remove");
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (ec.IsNull()) {
if (num != 1) Standard_OutOfRange::Raise("EntityList : Remove");
theval.Nullify();
return;
}
Standard_Boolean res = ec->Remove(num);
if (res) theval.Nullify();
}
// .... ACCES Unitaire AUX DONNEES ....
Standard_Boolean Interface_EntityList::IsEmpty () const
{ return (theval.IsNull()); }
Standard_Integer Interface_EntityList::NbEntities () const
{
if (theval.IsNull()) return 0;
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (ec.IsNull()) return 1; // Une seuke Entite
return ec->NbEntities();
}
const Handle(Standard_Transient)& Interface_EntityList::Value
(const Standard_Integer num) const
{
if (theval.IsNull()) Standard_OutOfRange::Raise("Interface EntityList : Value");
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (!ec.IsNull()) return ec->Value(num); // EntityCluster
else if (num != 1) Standard_OutOfRange::Raise("Interface EntityList : Value");
return theval;
}
void Interface_EntityList::SetValue
(const Standard_Integer num, const Handle(Standard_Transient)& ent)
{
if (ent.IsNull()) Standard_NullObject::Raise("Interface_EntityList SetValue");
if (theval.IsNull()) Standard_OutOfRange::Raise("Interface EntityList : SetValue");
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (!ec.IsNull()) ec->SetValue(num,ent); // EntityCluster
else if (num != 1) Standard_OutOfRange::Raise("Interface EntityList : SetValue");
else theval = ent;
}
// .... Interrogations Generales ....
void Interface_EntityList::FillIterator
(Interface_EntityIterator& iter) const
{
if (theval.IsNull()) return;
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (!ec.IsNull()) ec->FillIterator(iter); // EntityCluster;
else iter.GetOneItem(theval);
}
Standard_Integer Interface_EntityList::NbTypedEntities
(const Handle(Standard_Type)& atype) const
{
Standard_Integer res = 0;
if (theval.IsNull()) return 0;
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (!ec.IsNull()) { // EntityCluster
while (!ec.IsNull()) {
for (Standard_Integer i = ec->NbLocal(); i > 0; i --) {
if (ec->Value(i)->IsKind(atype)) res ++;
}
if (!ec->HasNext()) break;
ec = ec->Next();
}
} else { // Une seule Entite
if (theval->IsKind(atype)) res = 1;
}
return res;
}
Handle(Standard_Transient) Interface_EntityList::TypedEntity
(const Handle(Standard_Type)& atype, const Standard_Integer num) const
{
Standard_Integer res = 0;
Handle(Standard_Transient) entres;
if (theval.IsNull()) Interface_InterfaceError::Raise
("Interface EntityList : TypedEntity , none found");
Handle(Interface_EntityCluster) ec =
Handle(Interface_EntityCluster)::DownCast(theval);
if (!ec.IsNull()) { // EntityCluster
while (!ec.IsNull()) {
for (Standard_Integer i = ec->NbLocal(); i > 0; i --) {
if (ec->Value(i)->IsKind(atype)) {
res ++;
if (num == 0 && res > 1) Interface_InterfaceError::Raise
("Interface EntityList : TypedEntity , several found");
entres = ec->Value(i);
if (res == num) return entres;
}
}
if (!ec->HasNext()) break;
ec = ec->Next();
}
} else if (num > 1) {
Interface_InterfaceError::Raise
("Interface EntityList : TypedEntity ,out of range");
} else { // InterfaceEntity
if (!theval->IsKind(atype)) Interface_InterfaceError::Raise
("Interface EntityList : TypedEntity , none found");
entres = theval;
}
return entres;
}

View File

@@ -0,0 +1,59 @@
-- File: FileParameter.cdl
-- Created: Mon Feb 3 15:49:37 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class FileParameter from Interface
---Purpose : Auxiliary class to store a litteral parameter in a file
-- intermediate directory or in an UndefinedContent : a reference
-- type Parameter detains an Integer which is used to address a
-- record in the directory.
-- FileParameter is intended to be stored in a ParamSet : hence
-- memory management is performed by ParamSet, which calls Clear
-- to work, while the Destructor (see Destroy) does nothing.
-- Also a FileParameter can be read for consultation only, not to
-- be read from a Structure to be included into another one.
uses Integer, CString, AsciiString from TCollection, ParamType
is
Create returns FileParameter;
Init (me : in out; val : AsciiString from TCollection; typ : ParamType)
is static;
---Purpose : Fills fields (with Entity Number set to zero)
Init (me : in out; val : CString; typ : ParamType) is static;
---Purpose : Same as above, but builds the Value from a CString
CValue (me) returns CString is static;
---Purpose : Same as above, but as a CString (for immediate exploitation)
-- was C++ : return const
ParamType (me) returns ParamType is static;
---Purpose : Returns the type of the parameter
SetEntityNumber (me : in out; num : Integer) is static;
---Purpose : Allows to set a reference to an Entity in a numbered list
EntityNumber (me) returns Integer is static;
---Purpose : Returns value set by SetEntityNumber
Clear (me : in out) is static;
---Purpose : Clears stored data : frees memory taken for the String Value
Destroy (me : in out) is static;
---Purpose : Destructor. Does nothing because Memory is managed by ParamSet
---C++ : alias ~
fields
thetype : ParamType; -- for ParamType
theval : PCharacter; -- for Value
thenum : Integer; -- for EntityNumber
end FileParameter;

View File

@@ -0,0 +1,83 @@
#include <Interface_FileParameter.ixx>
//=======================================================================
//function : Interface_FileParameter
//purpose :
//=======================================================================
Interface_FileParameter::Interface_FileParameter ()
{
thetype = Interface_ParamMisc; thenum = 0;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void Interface_FileParameter::Init(const TCollection_AsciiString& val,
const Interface_ParamType typ)
{
theval = new char[val.Length()+1];
strcpy(theval,val.ToCString());
thetype = typ;
thenum = 0;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void Interface_FileParameter::Init (const Standard_CString val,
const Interface_ParamType typ)
{
theval = (Standard_PCharacter)val; // Principe : Allocation geree par contenant (ParamSet)
thetype = typ;
thenum = 0;
}
//=======================================================================
//function : CValue
//purpose :
//=======================================================================
Standard_CString Interface_FileParameter::CValue () const
{
return theval;
}
//=======================================================================
//function : ParamType
//purpose :
//=======================================================================
Interface_ParamType Interface_FileParameter::ParamType () const
{
return thetype;
}
//=======================================================================
//function : SetEntityNumber
//purpose :
//=======================================================================
void Interface_FileParameter::SetEntityNumber (const Standard_Integer num)
{
thenum = num;
}
//=======================================================================
//function : EntityNumber
//purpose :
//=======================================================================
Standard_Integer Interface_FileParameter::EntityNumber () const
{
return thenum;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void Interface_FileParameter::Clear ()
{
theval = NULL;
} // delete theval; pas si gere par ParamSet
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void Interface_FileParameter::Destroy ()
{
}

View File

@@ -0,0 +1,200 @@
-- File: FileReaderData.cdl
-- Created: Mon Feb 10 16:51:50 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
deferred class FileReaderData from Interface inherits TShared
---Purpose : This class defines services which permit to access Data issued
-- from a File, in a form which does not depend of physical
-- format : thus, each Record has an attached ParamList (to be
-- managed) and resulting Entity.
--
-- Each Interface defines its own FileReaderData : on one hand by
-- defining deferred methods given here, on the other hand by
-- describing literal data and their accesses, with the help of
-- basic classes such as String, Array1OfString, etc...
--
-- FileReaderData is used by a FileReaderTool, which is also
-- specific of each Norm, to read an InterfaceModel of the Norm
-- FileReaderData inherits TShared to be accessed by Handle :
-- this allows FileReaderTool to define more easily the specific
-- methods, and improves memory management.
uses Integer, Boolean, CString, Transient, AsciiString from TCollection,
Array1OfInteger from TColStd, Array1OfTransient from TColStd,
InterfaceModel, Check, FileParameter, ParamSet, ParamList, ParamType
raises NoSuchObject
is
Initialize (nbr : Integer; npar : Integer);
---Purpose : Initializes arrays of Entities and of ParamLists attached
-- to registered records
-- <nbr> must be the maximum number of records to get (no way to
-- extend it at run-time) : count entities and sub-entities ...
-- <npar> is the total count of parameters (if it is not exact,
-- it will be extented as necessary)
--
-- Hence, to each record can be bound an Entity and a list of
-- Parameters. Each kind of FileReaderData can add other data, by
-- having them in parallel (other arrays with same sizes)
-- Else, it must manage binding between items and their data
NbRecords (me) returns Integer is virtual;
---Purpose : Returns the count of registered records
-- That is, value given for Initialization (can be redefined)
NbEntities (me) returns Integer is virtual;
---Purpose : Returns the count of entities. Depending of each norm, records
-- can be Entities or SubParts (SubList in STEP, SubGroup in SET
-- ...). NbEntities counts only Entities, not Subs
-- Used for memory reservation in InterfaceModel
-- Default implementation uses FindNextRecord
-- Can be redefined into a more performant way
FindNextRecord (me; num : Integer) returns Integer is deferred;
---Purpose : Determines the record number defining an Entity following a
-- given record number. Specific to each sub-class of
-- FileReaderData. Returning zero means no record found
-- -- access to Paramaters -- --
InitParams (me : mutable; num : Integer);
---Purpose : attaches an empty ParamList to a Record
AddParam (me : mutable; num : Integer; aval : CString;
atype : ParamType; nument : Integer = 0);
---Purpose : Adds a parameter to record no "num" and fills its fields
-- (EntityNumber is optional)
-- Warning : <aval> is assumed to be memory-managed elsewhere : it is NOT
-- copied. This gives a best speed : strings remain stored in
-- pages of characters
AddParam (me : mutable; num : Integer; aval : AsciiString from TCollection;
atype : ParamType; nument : Integer = 0);
---Purpose : Same as above, but gets a AsciiString from TCollection
-- Remark that the content of the AsciiString is locally copied
-- (because its content is most often lost after using)
AddParam (me : mutable; num : Integer; FP : FileParameter);
---Purpose : Same as above, but gets a complete FileParameter
-- Warning : Content of <FP> is NOT copied : its original address and space
-- in memory are assumed to be managed elsewhere (see ParamSet)
SetParam (me : mutable; num, nump : Integer; FP : FileParameter);
---Purpose : Sets a new value for a parameter of a record, given by :
-- num : record number; nump : parameter number in the record
NbParams (me; num : Integer) returns Integer is static;
---Purpose : Returns count of parameters attached to record "num"
-- If <num> = 0, returns the total recorded count of parameters
Params (me; num : Integer) returns ParamList is static;
---Purpose : Returns the complete ParamList of a record (read only)
-- num = 0 to return the whole param list for the file
Param (me; num, nump : Integer) returns FileParameter is static;
---Purpose : Returns parameter "nump" of record "num", as a complete
-- FileParameter
---C++ : return const &
ChangeParam (me : mutable; num, nump : Integer) returns FileParameter
is static;
---Purpose : Same as above, but in order to be modified on place
---C++ : return &
ParamType (me; num, nump : Integer) returns ParamType is static;
---Purpose : Returns type of parameter "nump" of record "num"
-- ParamValue (me; num, nump : Integer) returns AsciiString from TCollection;
---Purpose : Returns literal value of parameter "nump" of record "num"
-- was C++ : return const &
ParamCValue (me; num, nump : Integer) returns CString is static;
---Purpose : Same as above, but as a CString
-- was C++ : return const
IsParamDefined (me; num, nump : Integer) returns Boolean is static;
---Purpose : Returns True if parameter "nump" of record "num" is defined
-- (it is not if its type is ParamVoid)
ParamNumber (me; num, nump : Integer) returns Integer is static;
---Purpose : Returns record number of an entity referenced by a parameter
-- of type Ident; 0 if no EntityNumber has been determined
-- Note that it is used to reference Entities but also Sublists
-- (sublists are not objects, but internal descriptions)
ParamEntity (me; num, nump : Integer)
returns mutable Transient raises NoSuchObject is static;
---Purpose : Returns the StepEntity referenced by a parameter
-- Error if none
---C++ : return const &
ChangeParameter (me : mutable; numpar : Integer) returns FileParameter
is static protected;
---Purpose : Returns a parameter given its absolute rank in the file
-- in order to be consulted or modified in specilaized actions
---C++ : return &
ParamPosition (me; numpar : Integer; num,nump : out Integer)
is static protected;
---Purpose : For a given absolute rank of parameter, determines the
-- record to which its belongs, and the parameter number for it
ParamFirstRank (me; num : Integer) returns Integer is static;
---Purpose : Returns the absolute rank of the beginning of a record
-- (its lsit is from ParamFirstRank+1 to ParamFirstRank+NbParams)
-- -- binding empty entities before loading model -- --
BoundEntity (me; num : Integer) returns mutable Transient;
---Purpose : Returns the entity bound to a record, set by SetEntities
---C++ : return const &
BindEntity (me : mutable; num : Integer; ent : mutable Transient);
---Purpose : Binds an entity to a record
SetErrorLoad (me : mutable; val : Boolean);
---Purpose : Sets the status "Error Load" on, to overside check fails
-- <val> True : declares unloaded
-- <val> False : declares loaded
-- If not called before loading (see FileReaderTool), check fails
-- give the status
-- IsErrorLoad says if SetErrorLoad has been called by user
-- ResetErrorLoad resets it (called by FileReaderTool)
-- This allows to specify that the currently loaded entity
-- remains unloaded (because of syntactic fail)
IsErrorLoad (me) returns Boolean;
---Purpose : Returns True if the status "Error Load" has been set (to True
-- or False)
ResetErrorLoad (me : mutable) returns Boolean;
---Purpose : Returns the former value of status "Error Load" then resets it
-- Used to read the status then ensure it is reset
-- -- specials -- --
Destroy (me : mutable);
---Purpose : Destructor (waiting for memory management)
---C++ : alias ~
Fastof (myclass; str : CString) returns Real;
---Purpose : Same spec.s as standard <atof> but 5 times faster
fields
thenum0 : Integer; -- current data for access to parameters
thenump0 : Integer;
therrload : Integer;
theparams : ParamSet; -- the general set of parameters
thenumpar : Array1OfInteger from TColStd; -- beginning of each one
-- thenbpar : Array1OfInteger from TColStd; -- its size
theents : Array1OfTransient from TColStd; -- entities bound to records
end FileReaderData;

View File

@@ -0,0 +1,409 @@
//====================================================================
//#10 smh 22.12.99 Protection (case of unexisting directory entry in file)
//sln 21.01.2002 OCC133: Exception handling was added in method Interface_FileReaderData::BoundEntity
//====================================================================
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Interface_FileReaderData.ixx>
// Stoque les Donnees issues d un Fichier (Conservees sous forme Litterale)
// Chaque norme peut s en servir comme base (listes de parametres litteraux,
// entites associees) et y ajoute ses donnees propres.
// Travaille sous le controle de FileReaderTool
// Optimisation : Champs pas possibles, car Param est const. Dommage
// Donc, on suppose qu on lit un fichier a la fois (hypothese raisonnable)
// On note en champ un numero de fichier, par rapport auquel on optimise
static Standard_Integer thefic = 0;
static Standard_Integer thenm0 = -1;
static Standard_Integer thenp0 = -1;
Interface_FileReaderData::Interface_FileReaderData (const Standard_Integer nbr,
const Standard_Integer npar)
: therrload (0), thenumpar (0,nbr), theents (0,nbr)
{
theparams = new Interface_ParamSet (npar);
thenumpar.Init(0);
thenm0 = -1;
thenum0 = ++thefic;
}
Standard_Integer Interface_FileReaderData::NbRecords () const
{ return thenumpar.Upper(); }
Standard_Integer Interface_FileReaderData::NbEntities () const
{
Standard_Integer nb = 0; Standard_Integer num = 0;
while ( (num = FindNextRecord(num)) > 0) nb ++;
return nb;
}
// .... Gestion des Parametres attaches aux Records ....
void Interface_FileReaderData::InitParams (const Standard_Integer num)
{
thenumpar.SetValue (num,theparams->NbParams());
//thenbpar.SetValue (num,0);
}
void Interface_FileReaderData::AddParam
(const Standard_Integer num,
const Standard_CString aval, const Interface_ParamType atype,
const Standard_Integer nument)
{
// Interface_FileParameter FP;
// FP.Init(aval,atype);
theparams->Append(aval,-1,atype,nument);
//thenbpar(num) ++; // SetValue(num,thenbpar(num)+1);
}
void Interface_FileReaderData::AddParam
(const Standard_Integer num,
const TCollection_AsciiString& aval, const Interface_ParamType atype,
const Standard_Integer nument)
{
// Interface_FileParameter FP;
// FP.Init(aval,atype);
theparams->Append(aval.ToCString(),aval.Length(),atype,nument);
//thenbpar(num) ++; // .SetValue(num,thenbpar(num)+1);
}
void Interface_FileReaderData::AddParam
(const Standard_Integer num,
const Interface_FileParameter& FP)
{
theparams->Append(FP);
//thenbpar(num) ++; // .SetValue(num,thenbpar(num)+1);
}
void Interface_FileReaderData::SetParam
(const Standard_Integer num, const Standard_Integer nump,
const Interface_FileParameter& FP)
{
//if (nump <= thenbpar.Value(num))
theparams->SetParam(thenumpar(num-1)+nump,FP);
}
Standard_Integer Interface_FileReaderData::NbParams
(const Standard_Integer num) const
{
if (num > 1) return (thenumpar(num) - thenumpar(num-1));
else if(num ==1) return thenumpar(num); //thenbpar(num);
else return theparams->NbParams();
}
Handle(Interface_ParamList) Interface_FileReaderData::Params
(const Standard_Integer num) const
{
if (num == 0) return theparams->Params(0,0); // complet
else if(num ==1) return theparams->Params(0,thenumpar(1));
else return theparams->Params ( thenumpar(num-1)+1, (thenumpar(num) - thenumpar(num-1)) );
}
const Interface_FileParameter& Interface_FileReaderData::Param
(const Standard_Integer num, const Standard_Integer nump) const
{
if (thefic != thenum0) return theparams->Param(thenumpar(num-1)+nump);
if (thenm0 != num) { thenp0 = thenumpar(num-1); thenm0 = num; }
return theparams->Param (thenp0+nump);
}
Interface_FileParameter& Interface_FileReaderData::ChangeParam
(const Standard_Integer num, const Standard_Integer nump)
{
if (thefic != thenum0) return theparams->ChangeParam(thenumpar(num-1)+nump);
if (thenm0 != num) { thenp0 = thenumpar(num-1); thenm0 = num; }
return theparams->ChangeParam (thenp0+nump);
}
Interface_ParamType Interface_FileReaderData::ParamType
(const Standard_Integer num, const Standard_Integer nump) const
{ return Param(num,nump).ParamType(); }
Standard_CString Interface_FileReaderData::ParamCValue
(const Standard_Integer num, const Standard_Integer nump) const
{ return Param(num,nump).CValue(); }
Standard_Boolean Interface_FileReaderData::IsParamDefined
(const Standard_Integer num, const Standard_Integer nump) const
{ return (Param(num,nump).ParamType() != Interface_ParamVoid); }
Standard_Integer Interface_FileReaderData::ParamNumber
(const Standard_Integer num, const Standard_Integer nump) const
{ return Param(num,nump).EntityNumber(); }
const Handle(Standard_Transient)& Interface_FileReaderData::ParamEntity
(const Standard_Integer num, const Standard_Integer nump) const
{ return BoundEntity (Param(num,nump).EntityNumber()); }
Interface_FileParameter& Interface_FileReaderData::ChangeParameter
(const Standard_Integer numpar)
{ return theparams->ChangeParam (numpar); }
void Interface_FileReaderData::ParamPosition
(const Standard_Integer numpar,
Standard_Integer& num, Standard_Integer& nump) const
{
Standard_Integer nbe = thenumpar.Upper();
if (numpar <= 0) { num = nump = 0; return; }
for (Standard_Integer i = 1; i <= nbe; i ++) {
if (thenumpar(i) > numpar)
{ num = i; nump = numpar - thenumpar(i) +1; return; }
}
num = nbe; nump = numpar - thenumpar(nbe) +1;
}
Standard_Integer Interface_FileReaderData::ParamFirstRank
(const Standard_Integer num) const
{ return thenumpar(num); }
void Interface_FileReaderData::SetErrorLoad (const Standard_Boolean val)
{ therrload = (val ? 1 : -1); }
Standard_Boolean Interface_FileReaderData::IsErrorLoad () const
{ return (therrload != 0); }
Standard_Boolean Interface_FileReaderData::ResetErrorLoad ()
{ Standard_Boolean res = (therrload > 0); therrload = 0; return res; }
// .... Gestion des Entites Associees aux Donnees du Fichier ....
const Handle(Standard_Transient)& Interface_FileReaderData::BoundEntity
(const Standard_Integer num) const
// { return theents(num); }
{
if (num >= theents.Lower() && num <= theents.Upper()) {
return theents(num);
}
else {
static Handle(Standard_Transient) dummy;
return dummy;
}
}
/* //static Handle(Standard_Transient) dummy;
{
//smh#10 Protection. If iges entity does not exist, return null pointer.
try {
OCC_CATCH_SIGNALS
Handle(Standard_Transient) temp = theents.Value(num);
}
////sln 21.01.2002 OCC133: Exception handling
// catch (Standard_OutOfRange) {
// cout<<" Catch of sln"<<endl;
// return dummy;
// }
catch (Standard_Failure) {
// some work-around, the best would be to modify CDL to
// return "Handle(Standard_Transient)" not "const Handle(Standard_Transient)&"
static Handle(Standard_Transient) dummy;
// cout<<" Catch of smh"<<endl;
return dummy;
}
}
//cout<<" Normal"<<endl;
if (theents.Value(num).IsImmutable()) cout << "IMMUTABLE:"<<num<<endl;
return theents(num);
}
*/
void Interface_FileReaderData::BindEntity
(const Standard_Integer num, const Handle(Standard_Transient)& ent)
// { theents.SetValue(num,ent); }
{
// #ifdef DEB
// if (ent.IsImmutable())
// cout << "Bind IMMUTABLE:"<<num<<endl;
// #endif
theents.SetValue(num,ent);
}
void Interface_FileReaderData::Destroy ()
{
}
#define MAXCHIF 80
static const Standard_Real vtab[] =
{ 1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 20., 30., 40., 50., 60., 70., 80., 90.,
100., 200., 300., 400., 500., 600., 700., 800., 900.,
1000., 2000., 3000., 4000., 5000., 6000., 7000., 8000., 9000.,
10000., 20000., 30000., 40000., 50000., 60000., 70000., 80000., 90000.,
1.E+05, 2.E+05, 3.E+05, 4.E+05, 5.E+05, 6.E+05, 7.E+05, 8.E+05, 9.E+05,
1.E+06, 2.E+06, 3.E+06, 4.E+06, 5.E+06, 6.E+06, 7.E+06, 8.E+06, 9.E+06,
1.E+07, 2.E+07, 3.E+07, 4.E+07, 5.E+07, 6.E+07, 7.E+07, 8.E+07, 9.E+07,
1.E+08, 2.E+08, 3.E+08, 4.E+08, 5.E+08, 6.E+08, 7.E+08, 8.E+08, 9.E+08,
1.E+09, 2.E+09, 3.E+09, 4.E+09, 5.E+09, 6.E+09, 7.E+09, 8.E+09, 9.E+09,
1.E+10, 2.E+10, 3.E+10, 4.E+10, 5.E+10, 6.E+10, 7.E+10, 8.E+10, 9.E+10,
1.E+11, 2.E+11, 3.E+11, 4.E+11, 5.E+11, 6.E+11, 7.E+11, 8.E+11, 9.E+11,
1.E+12, 2.E+12, 3.E+12, 4.E+12, 5.E+12, 6.E+12, 7.E+12, 8.E+12, 9.E+12,
1.E+13, 2.E+13, 3.E+13, 4.E+13, 5.E+13, 6.E+13, 7.E+13, 8.E+13, 9.E+13,
1.E+14, 2.E+14, 3.E+14, 4.E+14, 5.E+14, 6.E+14, 7.E+14, 8.E+14, 9.E+14,
1.E+15, 2.E+15, 3.E+15, 4.E+15, 5.E+15, 6.E+15, 7.E+15, 8.E+15, 9.E+15,
1.E+16, 2.E+16, 3.E+16, 4.E+16, 5.E+16, 6.E+16, 7.E+16, 8.E+16, 9.E+16,
1.E+17, 2.E+17, 3.E+17, 4.E+17, 5.E+17, 6.E+17, 7.E+17, 8.E+17, 9.E+17,
1.E+18, 2.E+18, 3.E+18, 4.E+18, 5.E+18, 6.E+18, 7.E+18, 8.E+18, 9.E+18,
1.E+19, 2.E+19, 3.E+19, 4.E+19, 5.E+19, 6.E+19, 7.E+19, 8.E+19, 9.E+19,
1.E+20, 2.E+20, 3.E+20, 4.E+20, 5.E+20, 6.E+20, 7.E+20, 8.E+20, 9.E+20,
1.E+21, 2.E+21, 3.E+21, 4.E+21, 5.E+21, 6.E+21, 7.E+21, 8.E+21, 9.E+21,
1.E+22, 2.E+22, 3.E+22, 4.E+22, 5.E+22, 6.E+22, 7.E+22, 8.E+22, 9.E+22,
1.E+23, 2.E+23, 3.E+23, 4.E+23, 5.E+23, 6.E+23, 7.E+23, 8.E+23, 9.E+23,
1.E+24, 2.E+24, 3.E+24, 4.E+24, 5.E+24, 6.E+24, 7.E+24, 8.E+24, 9.E+24,
1.E+25, 2.E+25, 3.E+25, 4.E+25, 5.E+25, 6.E+25, 7.E+25, 8.E+25, 9.E+25,
1.E+26, 2.E+26, 3.E+26, 4.E+26, 5.E+26, 6.E+26, 7.E+26, 8.E+26, 9.E+26,
1.E+27, 2.E+27, 3.E+27, 4.E+27, 5.E+27, 6.E+27, 7.E+27, 8.E+27, 9.E+27,
1.E+28, 2.E+28, 3.E+28, 4.E+28, 5.E+28, 6.E+28, 7.E+28, 8.E+28, 9.E+28,
1.E+29, 2.E+29, 3.E+29, 4.E+29, 5.E+29, 6.E+29, 7.E+29, 8.E+29, 9.E+29,
1.E+30, 2.E+30, 3.E+30, 4.E+30, 5.E+30, 6.E+30, 7.E+30, 8.E+30, 9.E+30,
1.E+31, 2.E+31, 3.E+31, 4.E+31, 5.E+31, 6.E+31, 7.E+31, 8.E+31, 9.E+31,
1.E+32, 2.E+32, 3.E+32, 4.E+32, 5.E+32, 6.E+32, 7.E+32, 8.E+32, 9.E+32,
1.E+33, 2.E+33, 3.E+33, 4.E+33, 5.E+33, 6.E+33, 7.E+33, 8.E+33, 9.E+33,
1.E+34, 2.E+34, 3.E+34, 4.E+34, 5.E+34, 6.E+34, 7.E+34, 8.E+34, 9.E+34,
1.E+35, 2.E+35, 3.E+35, 4.E+35, 5.E+35, 6.E+35, 7.E+35, 8.E+35, 9.E+35,
1.E+36, 2.E+36, 3.E+36, 4.E+36, 5.E+36, 6.E+36, 7.E+36, 8.E+36, 9.E+36,
1.E+37, 2.E+37, 3.E+37, 4.E+37, 5.E+37, 6.E+37, 7.E+37, 8.E+37, 9.E+37,
1.E+38, 2.E+38, 3.E+38, 4.E+38, 5.E+38, 6.E+38, 7.E+38, 8.E+38, 9.E+38,
1.E+39, 2.E+39, 3.E+39, 4.E+39, 5.E+39, 6.E+39, 7.E+39, 8.E+39, 9.E+39,
1.E+40, 2.E+40, 3.E+40, 4.E+40, 5.E+40, 6.E+40, 7.E+40, 8.E+40, 9.E+40,
1.E+41, 2.E+41, 3.E+41, 4.E+41, 5.E+41, 6.E+41, 7.E+41, 8.E+41, 9.E+41,
1.E+42, 2.E+42, 3.E+42, 4.E+42, 5.E+42, 6.E+42, 7.E+42, 8.E+42, 9.E+42,
1.E+43, 2.E+43, 3.E+43, 4.E+43, 5.E+43, 6.E+43, 7.E+43, 8.E+43, 9.E+43,
1.E+44, 2.E+44, 3.E+44, 4.E+44, 5.E+44, 6.E+44, 7.E+44, 8.E+44, 9.E+44,
1.E+45, 2.E+45, 3.E+45, 4.E+45, 5.E+45, 6.E+45, 7.E+45, 8.E+45, 9.E+45,
1.E+46, 2.E+46, 3.E+46, 4.E+46, 5.E+46, 6.E+46, 7.E+46, 8.E+46, 9.E+46,
1.E+47, 2.E+47, 3.E+47, 4.E+47, 5.E+47, 6.E+47, 7.E+47, 8.E+47, 9.E+47,
1.E+48, 2.E+48, 3.E+48, 4.E+48, 5.E+48, 6.E+48, 7.E+48, 8.E+48, 9.E+48,
1.E+49, 2.E+49, 3.E+49, 4.E+49, 5.E+49, 6.E+49, 7.E+49, 8.E+49, 9.E+49,
1.E+50, 2.E+50, 3.E+50, 4.E+50, 5.E+50, 6.E+50, 7.E+50, 8.E+50, 9.E+50,
1.E+51, 2.E+51, 3.E+51, 4.E+51, 5.E+51, 6.E+51, 7.E+51, 8.E+51, 9.E+51,
1.E+52, 2.E+52, 3.E+52, 4.E+52, 5.E+52, 6.E+52, 7.E+52, 8.E+52, 9.E+52,
1.E+53, 2.E+53, 3.E+53, 4.E+53, 5.E+53, 6.E+53, 7.E+53, 8.E+53, 9.E+53,
1.E+54, 2.E+54, 3.E+54, 4.E+54, 5.E+54, 6.E+54, 7.E+54, 8.E+54, 9.E+54,
1.E+55, 2.E+55, 3.E+55, 4.E+55, 5.E+55, 6.E+55, 7.E+55, 8.E+55, 9.E+55,
1.E+56, 2.E+56, 3.E+56, 4.E+56, 5.E+56, 6.E+56, 7.E+56, 8.E+56, 9.E+56,
1.E+57, 2.E+57, 3.E+57, 4.E+57, 5.E+57, 6.E+57, 7.E+57, 8.E+57, 9.E+57,
1.E+58, 2.E+58, 3.E+58, 4.E+58, 5.E+58, 6.E+58, 7.E+58, 8.E+58, 9.E+58,
1.E+59, 2.E+59, 3.E+59, 4.E+59, 5.E+59, 6.E+59, 7.E+59, 8.E+59, 9.E+59,
1.E+60, 2.E+60, 3.E+60, 4.E+60, 5.E+60, 6.E+60, 7.E+60, 8.E+60, 9.E+60,
1.E+61, 2.E+61, 3.E+61, 4.E+61, 5.E+61, 6.E+61, 7.E+61, 8.E+61, 9.E+61,
1.E+62, 2.E+62, 3.E+62, 4.E+62, 5.E+62, 6.E+62, 7.E+62, 8.E+62, 9.E+62,
1.E+63, 2.E+63, 3.E+63, 4.E+63, 5.E+63, 6.E+63, 7.E+63, 8.E+63, 9.E+63,
1.E+64, 2.E+64, 3.E+64, 4.E+64, 5.E+64, 6.E+64, 7.E+64, 8.E+64, 9.E+64,
1.E+65, 2.E+65, 3.E+65, 4.E+65, 5.E+65, 6.E+65, 7.E+65, 8.E+65, 9.E+65,
1.E+66, 2.E+66, 3.E+66, 4.E+66, 5.E+66, 6.E+66, 7.E+66, 8.E+66, 9.E+66,
1.E+67, 2.E+67, 3.E+67, 4.E+67, 5.E+67, 6.E+67, 7.E+67, 8.E+67, 9.E+67,
1.E+68, 2.E+68, 3.E+68, 4.E+68, 5.E+68, 6.E+68, 7.E+68, 8.E+68, 9.E+68,
1.E+69, 2.E+69, 3.E+69, 4.E+69, 5.E+69, 6.E+69, 7.E+69, 8.E+69, 9.E+69,
1.E+70, 2.E+70, 3.E+70, 4.E+70, 5.E+70, 6.E+70, 7.E+70, 8.E+70, 9.E+70,
1.E+71, 2.E+71, 3.E+71, 4.E+71, 5.E+71, 6.E+71, 7.E+71, 8.E+71, 9.E+71,
1.E+72, 2.E+72, 3.E+72, 4.E+72, 5.E+72, 6.E+72, 7.E+72, 8.E+72, 9.E+72,
1.E+73, 2.E+73, 3.E+73, 4.E+73, 5.E+73, 6.E+73, 7.E+73, 8.E+73, 9.E+73,
1.E+74, 2.E+74, 3.E+74, 4.E+74, 5.E+74, 6.E+74, 7.E+74, 8.E+74, 9.E+74,
1.E+75, 2.E+75, 3.E+75, 4.E+75, 5.E+75, 6.E+75, 7.E+75, 8.E+75, 9.E+75,
1.E+76, 2.E+76, 3.E+76, 4.E+76, 5.E+76, 6.E+76, 7.E+76, 8.E+76, 9.E+76,
1.E+77, 2.E+77, 3.E+77, 4.E+77, 5.E+77, 6.E+77, 7.E+77, 8.E+77, 9.E+77,
1.E+78, 2.E+78, 3.E+78, 4.E+78, 5.E+78, 6.E+78, 7.E+78, 8.E+78, 9.E+78,
1.E+79, 2.E+79, 3.E+79, 4.E+79, 5.E+79, 6.E+79, 7.E+79, 8.E+79, 9.E+79,
1.E+80, 2.E+80, 3.E+80, 4.E+80, 5.E+80, 6.E+80, 7.E+80, 8.E+80, 9.E+80,
1.E+81, 2.E+81, 3.E+81, 4.E+81, 5.E+81, 6.E+81, 7.E+81, 8.E+81, 9.E+81,
1.E+82, 2.E+82, 3.E+82, 4.E+82, 5.E+82, 6.E+82, 7.E+82, 8.E+82, 9.E+82,
1.E+83, 2.E+83, 3.E+83, 4.E+83, 5.E+83, 6.E+83, 7.E+83, 8.E+83, 9.E+83,
1.E+84, 2.E+84, 3.E+84, 4.E+84, 5.E+84, 6.E+84, 7.E+84, 8.E+84, 9.E+84,
1.E+85, 2.E+85, 3.E+85, 4.E+85, 5.E+85, 6.E+85, 7.E+85, 8.E+85, 9.E+85,
1.E+86, 2.E+86, 3.E+86, 4.E+86, 5.E+86, 6.E+86, 7.E+86, 8.E+86, 9.E+86,
1.E+87, 2.E+87, 3.E+87, 4.E+87, 5.E+87, 6.E+87, 7.E+87, 8.E+87, 9.E+87,
1.E+88, 2.E+88, 3.E+88, 4.E+88, 5.E+88, 6.E+88, 7.E+88, 8.E+88, 9.E+88,
1.E+89, 2.E+89, 3.E+89, 4.E+89, 5.E+89, 6.E+89, 7.E+89, 8.E+89, 9.E+89,
1.E+90, 2.E+90, 3.E+90, 4.E+90, 5.E+90, 6.E+90, 7.E+90, 8.E+90, 9.E+90,
1.E+91, 2.E+91, 3.E+91, 4.E+91, 5.E+91, 6.E+91, 7.E+91, 8.E+91, 9.E+91,
1.E+92, 2.E+92, 3.E+92, 4.E+92, 5.E+92, 6.E+92, 7.E+92, 8.E+92, 9.E+92,
1.E+93, 2.E+93, 3.E+93, 4.E+93, 5.E+93, 6.E+93, 7.E+93, 8.E+93, 9.E+93,
1.E+94, 2.E+94, 3.E+94, 4.E+94, 5.E+94, 6.E+94, 7.E+94, 8.E+94, 9.E+94,
1.E+95, 2.E+95, 3.E+95, 4.E+95, 5.E+95, 6.E+95, 7.E+95, 8.E+95, 9.E+95,
1.E+96, 2.E+96, 3.E+96, 4.E+96, 5.E+96, 6.E+96, 7.E+96, 8.E+96, 9.E+96,
1.E+97, 2.E+97, 3.E+97, 4.E+97, 5.E+97, 6.E+97, 7.E+97, 8.E+97, 9.E+97,
1.E+98, 2.E+98, 3.E+98, 4.E+98, 5.E+98, 6.E+98, 7.E+98, 8.E+98, 9.E+98,
1.E+99, 2.E+99, 3.E+99, 4.E+99, 5.E+99, 6.E+99, 7.E+99, 8.E+99, 9.E+99 };
Standard_Real Interface_FileReaderData::Fastof (const Standard_CString ligne)
{
Standard_Real val = 0., valdiv;
int i, jj, j, k, je, jx;
int chiffre[MAXCHIF]; int point, prem, moins, exp, grexp;
j = jj = je = jx = 0;
moins = exp = grexp = 0;
prem = MAXCHIF + 1; point = -1; // ligne[MAXCHIF+1] = '\0'; fin forcee
/* Analyse de la ligne (reputee representer un Flottant) */
for (i = 0; ; i ++) { // critere d arret : cf '\0'
const char& car = ligne[i];
/* critere d arret : ne pas l oublier, mais eviter de freiner le traitement
DONC, une fois en fin, plus une fois pour 1er passage
if (car == '\0')
{ if (point < 0) { point = i; jx = point - prem; }; break; } */
if (prem > MAXCHIF) {
if (car == '0') continue;
if (car == '.') { point = i; continue; }
if (car == '+') continue;
if (car == '-') { moins = 1; continue; }
if (car == '\0')
{ if (point < 0) { point = i; jx = point - prem; }; break; }
if (car < 33) continue;
prem = i;
if (point >= 0) jx = point - prem + 1;
}
if (car > 48 && car <= 57)
{ chiffre[j] = car - 48; jj = ++j; continue; } // j++ puis jj = j
if (car == '0') { chiffre[j] = 0; j ++; continue; }
if (car == '.') { point = i; jx = point - prem; continue; }
if ((car & 94) == 68) { // prend : e E d D
je = i; exp = atoi(&ligne[i+1]); jx += exp;
if (exp < -100 || exp > 100) grexp = 1; break;
}
if (car == '\0')
{ if (point < 0) { point = i; jx = point - prem; }; break; }
}
/* Interpretation : on decale le Point Decimal selon l Exposant
Puis on considere par rapport a <jj>, <prem> :
chiffre[i, pour i < point - prem] : partie entiere
chiffre[i, pour i >= point - prem] : partie decimale
*/
// jx = (point < prem ? point - prem + 1 : point - prem) + exp; deja calcule
// Puissance de 10 premiere decimale <0>
// limite : le PLUS PETIT SIGNIFIANT doit etre >= 1e-99
je = jx*9;
if (jx > jj) {
valdiv = 1.;
if (jx >= 100 || grexp) return atof(ligne); // issue de secours
} else {
k = jj*9;
if (jj >= 100 || grexp || (k-je >= 900)) return atof(ligne); // issue de secours
valdiv = vtab[k-je];
je = k;
}
je --;
// val = 0.; mis a la creation
for (i = 0; i < jj; i ++) {
je -= 9;
const int& chif = chiffre[i];
if (chif != 0) val += vtab[chif+je];
}
if (valdiv != 1.) val = val/valdiv;
if (moins) val = -val;
return val;
}

View File

@@ -0,0 +1,191 @@
-- File: Interface_FileReaderTool.cdl
-- Created: Thu Feb 4 17:00:08 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
deferred class FileReaderTool from Interface
---Purpose : Defines services which are required to load an InterfaceModel
-- from a File. Typically, it may firstly transform a system
-- file into a FileReaderData object, then work on it, not longer
-- considering file contents, to load an Interface Model.
-- It may also work on a FileReaderData already loaded.
--
-- FileReaderTool provides, on one hand, some general services
-- which are common to all read operations but can be redefined,
-- plus general actions to be performed specifically for each
-- Norm, as deferred methods to define.
--
-- In particular, FileReaderTool defines the Interface's Unknown
-- and Error entities
uses Integer, Boolean, Transient, HArray1OfTransient,
FileReaderData, InterfaceModel, Check, Protocol from Interface,
Messenger from Message,
GeneralLib, ReaderLib
raises DomainError, NoSuchObject
is
-- -- generals -- --
Initialize returns FileReaderTool from Interface;
---Purpose: Constructor; sets default fields
SetData (me : in out; reader : mutable FileReaderData;
protocol : Protocol from Interface);
---Purpose : Sets Data to a FileReaderData. Works with a Protocol
Protocol (me) returns Protocol from Interface;
---Purpose : Returns the Protocol given at creation time
Data (me) returns mutable FileReaderData;
---Purpose : Returns the FileReaderData which is used to work
SetModel (me : in out; amodel : mutable InterfaceModel);
---Purpose : Stores a Model. Used when the Model has been loaded
Model (me) returns mutable InterfaceModel;
---Purpose : Returns the stored Model
-- -- setting empty entities before loading model -- --
SetMessenger (me: out; messenger: Messenger from Message);
---Purpose : Sets Messenger used for outputting messages
Messenger (me) returns Messenger from Message;
---Purpose : Returns Messenger used for outputting messages.
-- The returned object is guaranteed to be non-null;
-- default is Message::Messenger().
SetTraceLevel (me: out; tracelev: Integer);
---Purpose : Sets trace level used for outputting messages
-- - 0: no trace at all
-- - 1: errors
-- - 2: errors and warnings
-- - 3: all messages
-- Default is 1 : Errors traced
TraceLevel (me) returns Integer;
---Purpose : Returns trace level used for outputting messages.
SetErrorHandle (me : in out; err : Boolean);
---Purpose : Allows controlling whether exception raisings are handled
-- If err is False, they are not (hence, dbx can take control)
-- If err is True, they are, and they are traced
-- (by putting on messenger Entity's Number and file record num)
-- Default given at Model's creation time is True
ErrorHandle (me) returns Boolean;
---Purpose : Returns ErrorHandle flag
-- -- setting empty entities before loading model -- --
SetEntities (me : in out);
---Purpose : Fills records with empty entities; once done, each entity can
-- ask the FileReaderTool for any entity referenced through an
-- identifier. Calls Recognize which is specific to each specific
-- type of FileReaderTool
Recognize (me : in out; num : Integer;
ach : in out Check; ent : out mutable Transient)
returns Boolean is deferred;
---Purpose : Recognizes a record, given its number. Specific to each
-- Interface; called by SetEntities. It can call the basic method
-- RecognizeByLib.
-- Returns False if recognition has failed, True else.
-- <ach> has not to be filled if simply Recognition has failed :
-- it must record true error messages : RecognizeByLib can
-- generate error messages if NewRead is called
--
-- Note that it works thru a Recognizer (method Evaluate) which
-- has to be memorized before starting
RecognizeByLib (me; num : Integer;
glib : in out GeneralLib; rlib : in out ReaderLib;
ach : in out Check; ent : out mutable Transient)
returns Boolean;
---Purpose : Recognizes a record with the help of Libraries. Can be used
-- to implement the method Recognize.
-- <rlib> is used to find Protocol and CaseNumber to apply
-- <glib> performs the creation (by service NewVoid, or NewRead
-- if NewVoid gave no result)
-- <ach> is a check, which is transmitted to NewRead if it is
-- called, gives a result but which is false
-- <ent> is the result
-- Returns False if recognition has failed, True else
UnknownEntity (me) returns mutable Transient;
---Purpose : Provides an unknown entity, specific to the Interface
-- called by SetEntities when Recognize has failed (Unknown alone)
-- or by LoadModel when an Entity has caused a Fail on reading
-- (to keep at least its literal description)
-- Uses Protocol to do it
-- -- loading entities into the model -- --
NewModel (me) returns mutable InterfaceModel;
---Purpose : Creates an empty Model of the norm. Uses Protocol to do it
LoadModel (me : in out; amodel : mutable InterfaceModel)
raises DomainError;
---Purpose : Reads and fills Entities from the FileReaderData set by
-- SetData to an InterfaceModel.
-- It enchains required operations, the specific ones correspond
-- to deferred methods (below) to be defined for each Norm.
-- It manages also error recovery and trace.
-- Remark : it calls SetModel.
-- It Can raise any error which can occur during a load
-- operation, unless Error Handling is set.
-- This method can also be redefined if judged necessary.
LoadedEntity (me : in out; num : Integer) returns mutable Transient;
---Purpose : Reads, Fills and Returns one Entity read from a Record of the
-- FileReaderData. This Method manages also case of Fail or
-- Warning, by producing a ReportEntyty plus , for a Fail, a
-- literal Content (as an UnknownEntity). Performs also Trace
BeginRead (me : in out; amodel : mutable InterfaceModel) is deferred;
---Purpose : Fills model's header; each Interface defines for its Model its
-- own file header; this method fills it from FileReaderTool.+
-- It is called by AnalyseFile from InterfaceModel
AnalyseRecord (me : in out;
num : Integer; anent : mutable Transient; acheck : in out Check)
returns Boolean is deferred;
---Purpose : Fills an Entity, given record no; specific to each Interface,
-- called by AnalyseFile from InterfaceModel (which manages its
-- calling arguments)
-- To work, each Interface can define a method in its proper
-- Transient class, like this (given as an example) :
-- AnalyseRecord (me : mutable; FR : in out FileReaderTool;
-- num : Integer; acheck : in out Check)
-- returns Boolean;
-- and call it from AnalyseRecord
--
-- Returned Value : True if the entity could be loaded, False
-- else (in case of syntactic fail)
Destroy (me: in out) is virtual;
---C++ : alias "Standard_EXPORT virtual ~Interface_FileReaderTool() { Destroy(); }"
EndRead (me : in out; amodel : mutable InterfaceModel) is virtual;
---Purpose : Ends file reading after reading all the entities
-- default is doing nothing; redefinable as necessary
fields
theproto : Protocol from Interface;
thereader : FileReaderData;
themodel : InterfaceModel;
themessenger:Messenger from Message;
thetrace : Integer; -- trace level (exceptions,errors, etc...)
theerrhand : Boolean; -- to handle or not exceptions
thenbrep0 : Integer; -- (reports at creation time)
thenbreps : Integer; -- (all reports)
thereports : HArray1OfTransient;
end FileReaderTool;

View File

@@ -0,0 +1,551 @@
// dce 21/01/99 S3767 : Suppression of general messages
#include <Interface_FileReaderTool.ixx>
#include <Interface_ReportEntity.hxx>
#include <Interface_InterfaceMismatch.hxx>
#include <Interface_CheckFailure.hxx>
#include <Interface_GeneralModule.hxx>
#include <Interface_ReaderModule.hxx>
#include <Message_Messenger.hxx>
#include <Message_Msg.hxx>
#include <Message.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Standard_TypeMismatch.hxx>
#ifdef WNT
#include <OSD_Exception.hxx>
#else
#include <OSD_Signal.hxx>
#endif
#include <stdio.h>
// MGE 16/06/98
// To use Msg class
#include <Message_Msg.hxx>
// To use TCollectionHAsciiString
#include <TCollection_HAsciiString.hxx>
// Failure pour recuperer erreur en lecture fichier,
// TypeMismatch pour message d erreur circonstancie (cas particulier important)
// Gere le chargement d un Fichier, prealablement transforme en FileReaderData
// (de la bonne norme), dans un Modele
//=======================================================================
//function : Interface_FileReaderTool
//purpose :
//=======================================================================
Interface_FileReaderTool::Interface_FileReaderTool ()
{
themessenger = Message::DefaultMessenger();
theerrhand = Standard_True;
thetrace = 1;
thenbrep0 = thenbreps = 0;
}
//=======================================================================
//function : SetData
//purpose :
//=======================================================================
void Interface_FileReaderTool::SetData(const Handle(Interface_FileReaderData)& reader,
const Handle(Interface_Protocol)& protocol)
{
thereader = reader;
theproto = protocol;
}
//=======================================================================
//function : Protocol
//purpose :
//=======================================================================
Handle(Interface_Protocol) Interface_FileReaderTool::Protocol () const
{
return theproto;
}
//=======================================================================
//function : Data
//purpose :
//=======================================================================
Handle(Interface_FileReaderData) Interface_FileReaderTool::Data () const
{
return thereader;
}
//=======================================================================
//function : SetModel
//purpose :
//=======================================================================
void Interface_FileReaderTool::SetModel
(const Handle(Interface_InterfaceModel)& amodel)
{
themodel = amodel;
}
//=======================================================================
//function : Model
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) Interface_FileReaderTool::Model () const
{
return themodel;
}
//=======================================================================
//function : SetMessenger
//purpose :
//=======================================================================
void Interface_FileReaderTool::SetMessenger (const Handle(Message_Messenger)& messenger)
{
if ( messenger.IsNull() )
themessenger = Message::DefaultMessenger();
else
themessenger = messenger;
}
//=======================================================================
//function : Messenger
//purpose :
//=======================================================================
Handle(Message_Messenger) Interface_FileReaderTool::Messenger () const
{
return themessenger;
}
//=======================================================================
//function : SetTraceLevel
//purpose :
//=======================================================================
void Interface_FileReaderTool::SetTraceLevel (const Standard_Integer tracelev)
{
thetrace = tracelev;
}
//=======================================================================
//function : TraceLevel
//purpose :
//=======================================================================
Standard_Integer Interface_FileReaderTool::TraceLevel () const
{
return thetrace;
}
//=======================================================================
//function : SetErrorHandle
//purpose :
//=======================================================================
void Interface_FileReaderTool::SetErrorHandle(const Standard_Boolean err)
{
theerrhand = err;
}
//=======================================================================
//function : ErrorHandle
//purpose :
//=======================================================================
Standard_Boolean Interface_FileReaderTool::ErrorHandle() const
{
return theerrhand;
}
// .... Actions Connexes au CHARGEMENT DU MODELE ....
// SetEntities fait appel a des methodes a fournir :
// s appuyant sur un Recognizer adapte a l interface :
// - Recognize fait reco->Evaluate(... : selon record no num)
// et recupere le resultat
// ainsi que la definition de l entite inconnue de l interface
//=======================================================================
//function : SetEntities
//purpose :
//=======================================================================
void Interface_FileReaderTool::SetEntities ()
{
Standard_Integer num;
thenbreps = 0; thenbrep0 = 0;
for (num = thereader->FindNextRecord(0); num > 0;
num = thereader->FindNextRecord(num)) {
Handle(Standard_Transient) newent;
Handle(Interface_Check) ach = new Interface_Check;
if (!Recognize (num,ach,newent)) {
newent = UnknownEntity();
if (thereports.IsNull()) thereports =
new TColStd_HArray1OfTransient (1,thereader->NbRecords());
thenbreps ++; thenbrep0 ++;
thereports->SetValue (num,new Interface_ReportEntity(ach,newent));
}
else if ((ach->NbFails() + ach->NbWarnings() > 0) && !newent.IsNull()) {
if (thereports.IsNull()) thereports =
new TColStd_HArray1OfTransient (1,thereader->NbRecords());
thenbreps ++; thenbrep0 ++;
thereports->SetValue (num,new Interface_ReportEntity(ach,newent));
}
thereader->BindEntity (num,newent);
}
}
//=======================================================================
//function : RecognizeByLib
//purpose :
//=======================================================================
Standard_Boolean Interface_FileReaderTool::RecognizeByLib(const Standard_Integer num,
Interface_GeneralLib& glib,
Interface_ReaderLib& rlib,
Handle(Interface_Check)& ach,
Handle(Standard_Transient)& ent) const
{
Handle(Interface_GeneralModule) gmod;
Handle(Interface_ReaderModule) rmod;
Handle(Interface_Protocol) proto;
Standard_Integer CN = 0;
// Chercher dans ReaderLib : Reconnaissance de cas -> CN , proto
for (rlib.Start(); rlib.More(); rlib.Next()) {
rmod = rlib.Module();
if (rmod.IsNull()) continue;
CN = rmod->CaseNum(thereader,num);
if (CN > 0) { proto = rlib.Protocol(); break; }
}
if (CN <= 0 || proto.IsNull()) return Standard_False;
// Se recaler dans GeneralLib : Creation de l entite vide
Handle(Standard_Type) typrot = proto->DynamicType();
for (glib.Start(); glib.More(); glib.Next()) {
proto = glib.Protocol();
if (proto.IsNull()) continue;
if (proto->DynamicType() != typrot) continue;
Standard_Boolean res = glib.Module()->NewVoid(CN,ent);
if (res) return res;
if (!rmod.IsNull()) return rmod->NewRead (CN,thereader,num,ach,ent);
// return res;
}
return Standard_False;
}
//=======================================================================
//function : UnknownEntity
//purpose :
//=======================================================================
Handle(Standard_Transient) Interface_FileReaderTool::UnknownEntity() const
{
return theproto->UnknownEntity();
}
//=======================================================================
//function : NewModel
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) Interface_FileReaderTool::NewModel() const
{
return theproto->NewModel();
}
//=======================================================================
//function : EndRead
//purpose :
//=======================================================================
void Interface_FileReaderTool::EndRead(const Handle(Interface_InterfaceModel)& )
{
} // par defaut, ne fait rien; redefinissable selon besoin
// .... (Sa Majeste le) CHARGEMENT DU MODELE ....
//=======================================================================
//function : LoadModel
//purpose :
//=======================================================================
void Interface_FileReaderTool::LoadModel
(const Handle(Interface_InterfaceModel)& amodel)
//
// Methode generale de lecture d un fichier : il est lu via un FileReaderData
// qui doit y donner acces de la facon la plus performante possible
// chaque interface definit son FileHeader avec ses methodes, appelees ici
{
// MGE 16/06/98
// Building of Messages
//====================================
Handle(Message_Messenger) TF = Messenger();
//====================================
Handle(Interface_Check) ach = new Interface_Check;
SetModel(amodel);
// .. Demarrage : Lecture du Header ..
if (theerrhand) {
try {
OCC_CATCH_SIGNALS
BeginRead(amodel); // selon la norme
}
catch (Standard_Failure) {
// Sendinf of message : Internal error during the header reading
Message_Msg Msg11("XSTEP_11");
TF->Send (Msg11, Message_Info);
}
}
else
BeginRead(amodel); // selon la norme
// .. Lecture des Entites ..
amodel->Reservate (thereader->NbEntities());
Standard_Integer num, num0 = thereader->FindNextRecord(0);
num = num0;
while (num > 0) {
Standard_Integer ierr = 0; // erreur sur analyse d une entite
Handle(Standard_Transient) anent;
try {
OCC_CATCH_SIGNALS
for (num = num0; num > 0; num = thereader->FindNextRecord(num)) {
num0 = num;
// Lecture sous protection contre crash
// (fait aussi AddEntity mais pas SetReportEntity)
anent = LoadedEntity(num);
// Lecture non protegee : utile pour travailler avec dbx
//// else
//// anent = LoadedEntity(num);
// .. Fin Lecture ..
if (anent.IsNull()) {
// Sending of message : Number of ignored Null Entities
Message_Msg Msg21("XSTEP_21");
Msg21.Arg(amodel->NbEntities());
TF->Send (Msg21, Message_Info);
continue;
}
// LoadedEntity fait AddEntity MAIS PAS SetReport (en bloc a la fin)
} // ---- fin boucle sur entites
num0 = 0; // plus rien
} // ---- fin du try, le catch suit
// En cas d erreur NON PREVUE par l analyse, recuperation par defaut
// Attention : la recuperation peut elle-meme planter ... (cf ierr)
catch (Standard_Failure) {
// Au passage suivant, on attaquera le record suivant
num0 = thereader->FindNextRecord(num); //:g9 abv 28 May 98: tr8_as2_ug.stp - infinite cycle: (0);
Handle(Standard_Failure) afail = Standard_Failure::Caught();
#ifdef WNT
if (afail.IsNull() || afail->IsKind(STANDARD_TYPE(OSD_Exception))) ierr = 2;
#else
if (afail.IsNull() || afail->IsKind(STANDARD_TYPE(OSD_Signal))) ierr = 2;
#endif
//:abv 03Apr00: anent is actually a previous one: if (anent.IsNull())
anent = thereader->BoundEntity(num);
if (anent.IsNull()) {
if (thetrace > 0)
{
// Sending of message : Number of ignored Null Entities
Message_Msg Msg21("XSTEP_21");
Msg21.Arg(amodel->NbEntities()+1);
TF->Send (Msg21, Message_Info);
continue;
}
}
/*Handle(Interface_Check)*/ ach = new Interface_Check(anent);
//: abv 03 Apr 00: trj3_s1-tc-214.stp: generate a message on exception
Message_Msg Msg278("XSTEP_278");
Msg278.Arg(amodel->StringLabel(anent));
ach->SendFail (Msg278);
if (ierr == 2) {
// Sending of message : reading of entity failed
Message_Msg Msg22("XSTEP_22");
Msg22.Arg(amodel->StringLabel(anent));
TF->Send (Msg22, Message_Info);
return;
}
if (!ierr) {
//char mess[100]; svv #2
ierr = 1;
// ce qui serait bien ici serait de recuperer le texte de l erreur pour ach ...
if (thetrace > 0) {
// Sending of message : recovered entity
Message_Msg Msg23("XSTEP_23");
Msg23.Arg(num);
TF->Send (Msg23, Message_Info);
}
// Finalement, on charge une Entite Inconnue
thenbreps ++;
Handle(Interface_ReportEntity) rep =
new Interface_ReportEntity(ach,anent);
Handle(Standard_Transient) undef = UnknownEntity();
AnalyseRecord(num,undef,ach);
rep->SetContent(undef);
if (thereports.IsNull()) thereports =
new TColStd_HArray1OfTransient (1,thereader->NbRecords());
thenbreps ++;
thereports->SetValue (num,rep);
//if(isValid)
amodel->AddEntity (anent); // pas fait par LoadedEntity ...
}
else {
if (thetrace > 0) {
// Sending of message : reading of entity failed
Message_Msg Msg22("XSTEP_22");
Msg22.Arg(amodel->StringLabel(anent));
TF->Send (Msg22, Message_Info);
}
// On garde <rep> telle quelle : pas d analyse fichier supplementaire,
// Mais la phase preliminaire eventuelle est conservee
// (en particulier, on garde trace du Type lu du fichier, etc...)
}
} // ----- fin complete du try/catch
} // ----- fin du while
// .. Ajout des Reports, silya
if (!thereports.IsNull()) {
if (thetrace > 0)
{
// Sending of message : report
Message_Msg Msg24("XSTEP_24");
Msg24.Arg(thenbreps);
TF->Send (Msg24, Message_Info);
}
amodel->Reservate (-thenbreps-10);
thenbreps = thereports->Upper();
for (Standard_Integer nr = 1; nr <= thenbreps; nr ++) {
if (thereports->Value(nr).IsNull()) continue;
Handle(Standard_Transient) anent = thereader->BoundEntity (nr);
Handle(Interface_ReportEntity) rep =
Handle(Interface_ReportEntity)::DownCast(thereports->Value(nr));
amodel->SetReportEntity (-amodel->Number(anent),rep);
}
}
// Conclusion : peut ne rien faire : selon necessite
if (theerrhand) {
try {
OCC_CATCH_SIGNALS
EndRead(amodel); // selon la norme
}
catch (Standard_Failure) {
// Sendinf of message : Internal error during the header reading
Message_Msg Msg11("XSTEP_11");
TF->Send (Msg11, Message_Info);
}
}
else
EndRead(amodel); // selon la norme
}
//=======================================================================
//function : LoadedEntity
//purpose :
//=======================================================================
Handle(Standard_Transient) Interface_FileReaderTool::LoadedEntity
(const Standard_Integer num)
{
Handle(Standard_Transient) anent = thereader->BoundEntity(num);
Handle(Interface_Check) ach = new Interface_Check(anent);
Handle(Interface_ReportEntity) rep; // entite Report, s il y a lieu
Standard_Integer irep = 0;
//Standard_Integer nbe = 0; svv #2
if (thenbrep0 > 0) {
rep = Handle(Interface_ReportEntity)::DownCast(thereports->Value(num));
if (!rep.IsNull()) { irep = num; ach = rep->Check(); }
}
// Trace Entite Inconnue
if (thetrace >= 2 && theproto->IsUnknownEntity(anent)) {
Handle(Message_Messenger) TF = Messenger();
Message_Msg Msg22("XSTEP_22");
// Sending of message : reading of entity failed
Msg22.Arg(themodel->StringLabel(anent)->String());
TF->Send (Msg22, Message_Info);
}
// .. Chargement proprement dit : Specifique de la Norme ..
AnalyseRecord(num,anent,ach);
// .. Ajout dans le modele de l entite telle quelle ..
// ATTENTION, ReportEntity traitee en bloc apres les Load
themodel->AddEntity(anent);
// Erreur ou Correction : On cree une ReportEntity qui memorise le Check,
// l Entite, et en cas d Erreur une UndefinedEntity pour les Parametres
// On exploite ici le flag IsLoadError : s il a ete defini (a vrai ou faux)
// il a priorite sur les fails du check. Sinon, ce sont les fails qui parlent
Standard_Integer nbf = ach->NbFails();
Standard_Integer nbw = ach->NbWarnings();
if (nbf + nbw > 0) {
//Standard_Integer n0; svv #2
themodel->NbEntities();
rep = new Interface_ReportEntity(ach,anent);
if (irep == 0) {
if (thereports.IsNull()) thereports =
new TColStd_HArray1OfTransient (1,thereader->NbRecords());
irep = num;
thenbreps ++;
}
thereports->SetValue(irep,rep);
if ( thetrace >= 2)
ach->Print (Messenger(),2);
}
// Rechargement ? si oui, dans une UnknownEntity fournie par le protocole
if (thereader->IsErrorLoad()) nbf = (thereader->ResetErrorLoad() ? 1 : 0);
if (nbf > 0) {
Handle(Standard_Transient) undef = UnknownEntity();
AnalyseRecord(num,undef,ach);
rep->SetContent(undef);
}
// Conclusion (Unknown : traite en externe because traitement Raise)
//// if (irep > 0) themodel->SetReportEntity (nbe,rep); en bloc a la fin
return anent;
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void Interface_FileReaderTool::Destroy(){}

View File

@@ -0,0 +1,96 @@
-- File: Interface_FloatWriter.cdl
-- Created: Fri Apr 15 08:51:31 1994
-- Author: Christian CAILLET
-- <cky@ecolox>
---Copyright: Matra Datavision 1994
class FloatWriter from Interface
---Purpose : This class converts a floting number (Real) to a string
-- It can be used if the standard C-C++ output functions
-- (sprintf or cout<<) are not convenient. That is to say :
-- - to suppress trailing '0' and 'E+00' (if desired)
-- - to control exponant output and floating point output
--
-- Formats are given in the form used by printf-sprintf
uses Boolean, Character, Real, CString
is
Create (chars : Integer = 0) returns FloatWriter;
---Purpose : Creates a FloatWriter ready to work, with default options -
-- - zero suppress option is set
-- - main format is set to "%E"
-- - secondary format is set to "%f" for values between 0.1 and
-- 1000. in absolute values
-- If <chars> is given (and positive), it will produce options
-- to produce this count of characters : "%<chars>f","%<chars>%E"
-- Options for Real Formats --
SetFormat (me : in out; form : CString; reset : Boolean = Standard_True);
---Purpose : Sets a specific Format for Sending Reals (main format)
-- (Default from Creation is "%E")
-- If <reset> is given True (default), this call clears effects
-- of former calls to SetFormatForRange and SetZeroSuppress
SetFormatForRange (me : in out; form : CString; R1, R2 : Real);
---Purpose : Sets a secondary Format for Real, to be applied between R1 and
-- R2 (in absolute values). A Call to SetRealForm cancels this
-- secondary form if <reset> is True.
-- (Default from Creation is "%f" between 0.1 and 1000.)
-- Warning : if the condition (0. <= R1 < R2) is not fulfilled, this
-- secondary form is canceled.
SetZeroSuppress (me : in out; mode : Boolean);
---Purpose : Sets Sending Real Parameters to suppress trailing Zeros and
-- Null Exponant ("E+00"), if <mode> is given True, Resets this
-- mode if <mode> is False (in addition to Real Forms)
-- A call to SetRealFrom resets this mode to False ig <reset> is
-- given True (Default from Creation is True)
SetDefaults (me : in out; chars : Integer = 0);
---Purpose : Sets again options to the defaults given by Create
Options (me; zerosup, range : out Boolean; R1, R2 : out Real);
---Purpose : Returns active options : <zerosup> is the option ZeroSuppress,
-- <range> is True if a range is set, False else
-- R1,R2 give the range (if it is set)
MainFormat (me) returns CString;
---Purpose : Returns the main format
-- was C++ : return const
FormatForRange (me) returns CString;
---Purpose : Returns the format for range, if set
-- Meaningful only if <range> from Options is True
-- was C++ : return const
Write (me; val : Real; text : CString) returns Integer is static;
---Purpose : Writes a Real value <val> to a string <text> by using the
-- options. Returns the useful Length of produced string.
-- It calls the class method Convert.
-- Warning : <text> is assumed to be wide enough (20-30 is correct)
-- And, even if declared in, its content will be modified
Convert (myclass; val : Real; text : CString;
zerosup : Boolean; Range1,Range2 : Real;
mainform, rangeform : CString)
returns Integer;
---Purpose : This class method converts a Real Value to a string, given
-- options given as arguments. It can be called independantly.
-- Warning : even if declared in, content of <text> will be modified
fields -- options
themainform : Character[12]; -- Main Printing from for Reals
therange1 : Real; -- range for second printing form (if any)
therange2 : Real; -- range for second printing form (if any)
therangeform : Character[12]; -- Printing form applying inside Range
thezerosup : Boolean; -- Trailing Zero Suppression Status
end FloatWriter;

View File

@@ -0,0 +1,137 @@
//#52 rln 23.12.98
#include <Interface_FloatWriter.ixx>
#include <stdio.h>
Interface_FloatWriter::Interface_FloatWriter (const Standard_Integer chars)
{
SetDefaults(chars);
}
// .... Controle d Envoi des Flottants ....
void Interface_FloatWriter::SetFormat
(const Standard_CString form, const Standard_Boolean reset)
{
strcpy(themainform,form);
if (!reset) return;
therange1 = therange2 = 0.; // second form : inhibee
thezerosup = Standard_False;
}
void Interface_FloatWriter::SetFormatForRange
(const Standard_CString form,
const Standard_Real R1, const Standard_Real R2)
{
strcpy(therangeform,form);
therange1 = R1;
therange2 = R2;
}
void Interface_FloatWriter::SetZeroSuppress (const Standard_Boolean mode)
{ thezerosup = mode; }
void Interface_FloatWriter::SetDefaults (const Standard_Integer chars)
{
if (chars <= 0) {
strcpy(themainform ,"%E");
strcpy(therangeform ,"%f");
} else {
char pourcent = '%'; char point = '.';
sprintf(themainform, "%c%d%c%dE",pourcent,chars+2,point,chars);
sprintf(therangeform, "%c%d%c%df",pourcent,chars+2,point,chars);
}
therange1 = 0.1; therange2 = 1000.;
thezerosup = Standard_True;
}
void Interface_FloatWriter::Options
(Standard_Boolean& zerosup, Standard_Boolean& range,
Standard_Real& R1, Standard_Real& R2) const
{
zerosup = thezerosup;
range = (therange2 >= therange1 && therange1 >= 0.);
R1 = therange1;
R2 = therange2;
}
Standard_CString Interface_FloatWriter::MainFormat () const
{ const Standard_CString mainform = Standard_CString(&themainform[0]); return mainform; }
Standard_CString Interface_FloatWriter::FormatForRange () const
{ const Standard_CString rangeform = Standard_CString(&therangeform[0]); return rangeform; }
// ########################################################################
Standard_Integer Interface_FloatWriter::Write
(const Standard_Real val, const Standard_CString text) const
{
const Standard_CString mainform = Standard_CString(themainform);
const Standard_CString rangeform = Standard_CString(therangeform);
return Convert
(val,text,thezerosup,therange1,therange2,mainform,rangeform);
}
//=======================================================================
//function : Convert
//purpose :
//=======================================================================
Standard_Integer Interface_FloatWriter::Convert (const Standard_Real val,
const Standard_CString text,
const Standard_Boolean zsup,
const Standard_Real R1,
const Standard_Real R2,
const Standard_CString mainform,
const Standard_CString rangeform)
{
// Valeur flottante, expurgee de "0000" qui trainent et de "E+00"
// char lval[20];
char lxp[6], *pText;
int i0,j0=0;
lxp[0] = lxp[4] = '\0';
pText=(char *)text;
//
if ( (val >= R1 && val < R2) ||
(val <= -R1 && val > -R2) ) {
sprintf(pText,rangeform,val);
}
else {
sprintf(pText,mainform,val);
}
if (zsup) {
for (int i = 0; i < 16; i ++) {
i0 = i;
if (text[i] == 'e' || text[i] == 'E') {
lxp[0] = 'E';
lxp[1] = text[i+1];
lxp[2] = text[i+2];
lxp[3] = text[i+3];
lxp[4] = text[i+4];
if (lxp[1] == '+' && lxp[2] == '0' && lxp[3] == '0' && lxp[4] == '\0') {
lxp[0] = '\0';
}
pText[i] = '\0';
}
if (text[i] == '\0') {
break;
}
}
//#52 rln 23.12.98 converting 1e-07 throws exception
for (int j = i0-1; j >= 0; j --) {
j0 = j;
if (text[j] != '0') {
break;
}
pText[j] = '\0';
}
pText[j0+1] = lxp[0];
pText[j0+2] = lxp[1];
pText[j0+3] = lxp[2];
pText[j0+4] = lxp[3];
pText[j0+5] = lxp[4];
pText[j0+6] = '\0';
}
return strlen(text);
}

View File

@@ -0,0 +1,86 @@
-- File: Interface_GTool.cdl
-- Created: Thu Jan 8 14:42:05 1998
-- Author: Christian CAILLET
-- <xstep@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class GTool from Interface inherits TShared
---Purpose : GTool - General Tool for a Model
-- Provides the functions performed by Protocol/GeneralModule for
-- entities of a Model, and recorded in a GeneralLib
-- Optimized : once an entity has been queried, the GeneralLib is
-- not longer queried
-- Shareable between several users : as a Handle
uses Transient,
Protocol, GeneralLib, GeneralModule,
SignType, InterfaceModel,
IndexedDataMapOfTransientTransient from TColStd,
DataMapOfTransientInteger from Interface
is
Create returns mutable GTool;
---Purpose : Creates an empty, not set, GTool
Create (proto : Protocol; nbent : Integer = 0) returns mutable GTool;
---Purpose : Creates a GTool from a Protocol
-- Optional starting count of entities
SetSignType (me : mutable; sign : SignType);
---Purpose : Sets a new SignType
SignType (me) returns SignType;
---Purpose : Returns the SignType. Can be null
SignValue (me; ent : Transient; model : InterfaceModel)
returns CString;
---Purpose : Returns the Signature for a Transient Object in a Model
-- It calls SignType to do that
-- If SignType is not defined, return ClassName of <ent>
SignName (me) returns CString;
---Purpose : Returns the Name of the SignType, or "Class Name"
SetProtocol (me : mutable; proto : Protocol; enforce : Boolean = Standard_False);
---Purpose : Sets a new Protocol
-- if <enforce> is False and the new Protocol equates the old one
-- then nothing is done
Protocol (me) returns Protocol;
---Purpose : Returns the Protocol. Warning : it can be Null
Lib (me : mutable) returns GeneralLib;
---Purpose : Returns the GeneralLib itself
---C++ : return &
Reservate (me : mutable; nb : Integer; enforce : Boolean = Standard_False);
---Purpose : Reservates maps for a count of entities
-- <enforce> False : minimum count
-- <enforce> True : clears former reservations
-- Does not clear the maps
ClearEntities (me : mutable);
---Purpose : Clears the maps which record, for each already recorded entity
-- its Module and Case Number
Select (me : mutable; ent : Transient;
gmod : out mutable GeneralModule;
CN : out Integer;
enforce : Boolean = Standard_False) returns Boolean;
---Purpose : Selects for an entity, its Module and Case Number
-- It is optimised : once done for each entity, the result is
-- mapped and the GeneralLib is not longer queried
-- <enforce> True overpasses this optimisation
fields
theproto : Protocol;
thesign : SignType;
thelib : GeneralLib;
thentnum : DataMapOfTransientInteger;
thentmod : IndexedDataMapOfTransientTransient;
end GTool;

View File

@@ -0,0 +1,83 @@
#include <Interface_GTool.ixx>
Interface_GTool::Interface_GTool () { }
Interface_GTool::Interface_GTool
(const Handle(Interface_Protocol)& proto, const Standard_Integer nb)
: theproto (proto) , thelib (proto)
{ if (nb > 0) { thentnum.ReSize(nb); thentmod.ReSize(nb); } }
void Interface_GTool::SetSignType (const Handle(Interface_SignType)& sign)
{ thesign = sign; }
Handle(Interface_SignType) Interface_GTool::SignType () const
{ return thesign; }
Standard_CString Interface_GTool::SignValue
(const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& model) const
{
if (ent.IsNull()) return "";
if (thesign.IsNull()) return Interface_SignType::ClassName(ent->DynamicType()->Name());
return thesign->Value (ent,model);
}
Standard_CString Interface_GTool::SignName () const
{
if (thesign.IsNull()) return "Class Name";
return thesign->Name();
}
void Interface_GTool::SetProtocol
(const Handle(Interface_Protocol)& proto, const Standard_Boolean enforce)
{
if (proto == theproto && !enforce) return;
theproto = proto;
thelib.Clear();
thelib.AddProtocol (proto);
}
Handle(Interface_Protocol) Interface_GTool::Protocol () const
{ return theproto; }
Interface_GeneralLib& Interface_GTool::Lib ()
{ return thelib; }
void Interface_GTool::Reservate
(const Standard_Integer nb, const Standard_Boolean enforce)
{
Standard_Integer n = thentnum.NbBuckets();
if (n < nb && !enforce) return;
thentnum.ReSize (nb); thentmod.ReSize (nb);
}
void Interface_GTool::ClearEntities ()
{ thentnum.Clear(); thentmod.Clear(); }
//=======================================================================
//function : Select
//purpose :
//=======================================================================
Standard_Boolean Interface_GTool::Select (const Handle(Standard_Transient)& ent,
Handle(Interface_GeneralModule)& gmod,
Standard_Integer& CN,
const Standard_Boolean enforce)
{
// const Handle(Standard_Type)& aType = ent->DynamicType();
Standard_Integer num = thentmod.FindIndex (ent);
if (num == 0 || enforce) {
if (thelib.Select (ent,gmod,CN)) {
num = thentmod.Add (ent,gmod);
thentnum.Bind (ent,CN);
return Standard_True;
}
return Standard_False;
}
gmod = Handle(Interface_GeneralModule)::DownCast (thentmod.FindFromIndex(num));
CN = thentnum.Find (ent);
return Standard_True;
}

View File

@@ -0,0 +1,176 @@
-- File: Interface_GeneralModule.cdl
-- Created: Tue Feb 2 12:20:12 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
deferred class GeneralModule from Interface inherits TShared
---Purpose : This class defines general services, which must be provided
-- for each type of Entity (i.e. of Transient Object processed
-- by an Interface) : Shared List, Check, Copy, Delete, Category
--
-- To optimise processing (e.g. firstly bind an Entity to a Module
-- then calls Module), each recognized Entity Type corresponds
-- to a Case Number, determined by the Protocol each class of
-- GeneralModule belongs to.
uses Transient, HAsciiString from TCollection,
InterfaceModel, ShareTool, Check, EntityIterator, CopyTool
is
FillShared (me; model : InterfaceModel; CN : Integer; ent : Transient;
iter : in out EntityIterator) is virtual;
---Purpose : Specific filling of the list of Entities shared by an Entity
-- <ent>, according a Case Number <CN> (formerly computed by
-- CaseNum), considered in the context of a Model <model>
-- Default calls FillSharedCase (i.e., ignores the model)
-- Can be redefined to use the model for working
FillSharedCase (me; CN : Integer; ent : Transient;
iter : in out EntityIterator) is deferred;
---Purpose : Specific filling of the list of Entities shared by an Entity
-- <ent>, according a Case Number <CN> (formerly computed by
-- CaseNum). Can use the internal utility method Share, below
Share (me; iter : in out EntityIterator; shared : Transient);
---Purpose : Adds an Entity to a Shared List (uses GetOneItem on <iter>)
ListImplied (me; model : InterfaceModel; CN : Integer; ent : Transient;
iter : in out EntityIterator) is virtual;
---Purpose : List the Implied References of <ent> considered in the context
-- of a Model <model> : i.e. the Entities which are Referenced
-- while not considered as Shared (not copied if <ent> is,
-- references not renewed by CopyCase but by ImpliedCase, only
-- if referenced Entities have been Copied too)
-- FillShared + ListImplied give the complete list of References
-- Default calls ListImpliedCase (i.e. ignores the model)
-- Can be redefined to use the model for working
ListImpliedCase (me; CN : Integer; ent : Transient;
iter : in out EntityIterator) is virtual;
---Purpose : List the Implied References of <ent> (see above)
-- are Referenced while not considered as Shared (not copied if
-- <ent> is, references not renewed by CopyCase but by
-- ImpliedCase, only if referenced Entities have been Copied too)
-- FillSharedCase + ListImpliedCase give the complete list of
-- Referenced Entities
-- The provided default method does nothing (Implied References
-- are specific of a little amount of Entity Classes).
CheckCase (me; CN : Integer; ent : Transient; shares : ShareTool;
ach : in out Check) is deferred;
---Purpose : Specific Checking of an Entity <ent>
-- Can check context queried through a ShareTool, as required
CanCopy (me; CN : Integer; ent : Transient) returns Boolean is virtual;
---Purpose : Specific answer to the question "is Copy properly implemented"
-- Remark that it should be in phase with the implementation of
-- NewVoid+CopyCase/NewCopyCase
-- Default returns always False, can be redefined
Dispatch (me; CN : Integer;
entfrom : Transient; entto : out mutable Transient;
TC : in out CopyTool) returns Boolean is virtual;
---Purpose : Dispatches an entity
-- Returns True if it works by copy, False if it just duplicates
-- the starting Handle
--
-- Dispatching means producing a new entity, image of the
-- starting one, in order to be put into a new Model, this Model
-- being itself the result of a dispatch from an original Model
--
-- According to the cases, dispatch can either
-- * just return <entto> as equating <entfrom>
-- -> the new model designates the starting entity : it is
-- lighter, but the dispatched entity being shared might not be
-- modified for dispatch
-- * copy <entfrom> to <entto>
-- by calling NewVoid+CopyCase (two steps) or NewCopiedCase (1)
-- -> the dispatched entity is a COPY, hence it can be modified
--
-- The provided default just duplicates the handle without
-- copying, then returns False. Can be redefined
NewVoid (me; CN : Integer; entto : out mutable Transient)
returns Boolean is deferred;
---Purpose : Creates a new void entity <entto> according to a Case Number
-- This entity remains to be filled, by reading from a file or
-- by copying from another entity of same type (see CopyCase)
CopyCase (me; CN : Integer;
entfrom : Transient; entto : mutable Transient;
TC : in out CopyTool) is deferred;
---Purpose : Specific Copy ("Deep") from <entfrom> to <entto> (same type)
-- by using a CopyTool which provides its working Map.
-- Use method Transferred from CopyTool to work
NewCopiedCase (me; CN : Integer;
entfrom : Transient; entto : out mutable Transient;
TC : in out CopyTool) returns Boolean is virtual;
---Purpose : Specific operator (create+copy) defaulted to do nothing.
-- It can be redefined : When it is not possible to work in two
-- steps (NewVoid then CopyCase). This can occur when there is
-- no default constructor : hence the result <entto> must be
-- created with an effective definition.
-- Remark : if NewCopiedCase is defined, CopyCase has nothing to do
-- Returns True if it has produced something, false else
RenewImpliedCase (me; CN : Integer;
entfrom : Transient; entto : mutable Transient;
TC : CopyTool) is virtual;
---Purpose : Specific Copying of Implied References
-- A Default is provided which does nothing (must current case !)
-- Already copied references (by CopyFrom) must remain unchanged
-- Use method Search from CopyTool to work
WhenDeleteCase (me; CN : Integer;
ent : mutable Transient; dispatched : Boolean) is virtual;
---Purpose : Prepares an entity to be deleted. What does it mean :
-- Basically, any class of entity may define its own destructor
-- By default, it does nothing but calling destructors on fields
-- With the Memory Manager, it is useless to call destructor,
-- it is done automatically when the Handle is nullified(cleared)
-- BUT this is ineffective in looping structures (whatever these
-- are "Implied" references or not).
--
-- THUS : if no loop may appear in definitions, a class which
-- inherits from TShared is correctly managed by automatic way
-- BUT if there can be loops (or simply back pointers), they must
-- be broken, for instance by clearing fields of one of the nodes
-- The default does nothing, to be redefined if a loop can occur
-- (Implied generally requires WhenDelete, but other cases can
-- occur)
--
-- Warning : <dispatched> tells if the entity to be deleted has been
-- produced by Dispatch or not. Hence WhenDelete must be in
-- coherence with Dispatch
-- Dispatch can either copy or not.
-- If it copies the entity, this one should be deleted
-- If it doesnt (i.e. duplicates the handle) nothing to do
--
-- If <dispatch> is False, normal deletion is to be performed
CategoryNumber (me; CN : Integer; ent : Transient; shares : ShareTool)
returns Integer is virtual;
---Purpose : Returns a category number which characterizes an entity
-- Category Numbers are managed by the class Category
-- <shares> can be used to evaluate this number in the context
-- Default returns 0 which means "unspecified"
Name (me; CN : Integer; ent : Transient; shares : ShareTool)
returns HAsciiString from TCollection is virtual;
---Purpose : Determines if an entity brings a Name (or widerly, if a Name
-- can be attached to it, through the ShareTool
-- By default, returns a Null Handle (no name can be produced)
-- Can be redefined
--
-- Warning : While this string may be edited on the spot, if it is a read
-- field, the returned value must be copied before.
end GeneralModule;

View File

@@ -0,0 +1,69 @@
#include <Interface_GeneralModule.ixx>
void Interface_GeneralModule::FillShared
(const Handle(Interface_InterfaceModel)& /*model*/,
const Standard_Integer casenum,
const Handle(Standard_Transient)& ent,
Interface_EntityIterator& iter) const
{ FillSharedCase (casenum,ent,iter); } // Par defaut, model ne sert pas
void Interface_GeneralModule::Share
(Interface_EntityIterator& iter,
const Handle(Standard_Transient)& shared) const
{ iter.GetOneItem(shared); } // Plus joli d appeler Share
void Interface_GeneralModule::ListImplied
(const Handle(Interface_InterfaceModel)& /*model*/,
const Standard_Integer casenum,
const Handle(Standard_Transient)& ent,
Interface_EntityIterator& iter) const
{ ListImpliedCase (casenum,ent,iter); } // Par defaut, model ne sert pas
void Interface_GeneralModule::ListImpliedCase
(const Standard_Integer /*casenum*/,
const Handle(Standard_Transient)& /*ent*/,
Interface_EntityIterator& /*iter*/) const
{ } // Par defaut, pas d Imply
Standard_Boolean Interface_GeneralModule::CanCopy
(const Standard_Integer /*CN*/, const Handle(Standard_Transient)& /*ent*/) const
{ return Standard_False; }
Standard_Boolean Interface_GeneralModule::Dispatch
(const Standard_Integer, const Handle(Standard_Transient)& entfrom,
Handle(Standard_Transient)& entto, Interface_CopyTool& ) const
{ entto = entfrom; return Standard_False; }
Standard_Boolean Interface_GeneralModule::NewCopiedCase
(const Standard_Integer, const Handle(Standard_Transient)&,
Handle(Standard_Transient)&, Interface_CopyTool& ) const
{ return Standard_False; }
void Interface_GeneralModule::RenewImpliedCase
(const Standard_Integer /*casenum*/,
const Handle(Standard_Transient)& /*entfrom*/,
const Handle(Standard_Transient)& /*entto*/,
const Interface_CopyTool& /*TC*/) const
{ } // Par defaut, ne fait rien
void Interface_GeneralModule::WhenDeleteCase
(const Standard_Integer /*casenum*/,
const Handle(Standard_Transient)& /*ent*/,
const Standard_Boolean /*dispatched*/) const
{ } // par defaut, ne fait rien
Standard_Integer Interface_GeneralModule::CategoryNumber
(const Standard_Integer , const Handle(Standard_Transient)& ,
const Interface_ShareTool& ) const
{ return 0; } // par defaut, non specifie
Handle(TCollection_HAsciiString) Interface_GeneralModule::Name
(const Standard_Integer , const Handle(Standard_Transient)& ,
const Interface_ShareTool& ) const
{ Handle(TCollection_HAsciiString) str; return str; } // par defaut, non specifie

321
src/Interface/Interface_Graph.cdl Executable file
View File

@@ -0,0 +1,321 @@
-- File: Graph.cdl
-- Created: Tue Sep 22 19:01:29 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class Graph from Interface
---Purpose : Gives basic data structure for operating and storing
-- graph results (usage is normally internal)
-- Entities are Mapped according their Number in the Model
--
-- Each Entity from the Model can be known as "Present" or
-- not; if it is, it is Mapped with a Status : an Integer
-- which can be used according to needs of each algorithm
-- In addition, the Graph brings a BitMap which can be used
-- by any caller
--
-- Also, it is bound with two lists : a list of Shared
-- Entities (in fact, their Numbers in the Model) which is
-- filled by a ShareTool, and a list of Sharing Entities,
-- computed by deduction from the Shared Lists
--
-- Moreover, it is possible to redefine the list of Entities
-- Shared by an Entity (instead of standard answer by general
-- service Shareds) : this new list can be empty; it can
-- be changed or reset (i.e. to come back to standard answer)
uses Transient, Type,
Array1OfInteger from TColStd,
AsciiString from TCollection, HAsciiString from TCollection,
Protocol from Interface, GeneralLib, InterfaceModel, GTool,
EntityIterator, IntList, BitMap
raises DomainError
is
Create (amodel : InterfaceModel; lib : GeneralLib) returns Graph;
---Purpose : Creates an empty graph, ready to receive Entities from amodel
-- Note that this way of Creation allows <me> to verify that
-- Entities to work with are contained in <amodel>
-- Basic Shared and Sharing lists are obtained from a General
-- Services Library, given directly as an argument
Create (amodel : InterfaceModel; protocol : Protocol from Interface)
returns Graph;
---Purpose : Same as above, but the Library is defined through a Protocol
Create (amodel : InterfaceModel; gtool : GTool from Interface)
returns Graph;
---Purpose : Same as above, but the Library is defined through a Protocol
Create (amodel : InterfaceModel) returns Graph;
---Purpose : Same a above but works with the Protocol recorded in the Model
Create (agraph : Graph; copied : Boolean = Standard_False) returns Graph;
---Purpose : Creates a Graph from another one, getting all its data
-- Remark that status are copied from <agraph>, but the other
-- lists (sharing/shared) are copied only if <copied> = True
Evaluate (me : in out; lib : GeneralLib; gtool : GTool) is static private;
---Purpose : Performs the Evaluation of the Graph, from an initial Library,
-- either defined through a Protocol, or given dierctly
-- Called by the non-empty Constructors
--
-- Normally, gtool suffices. But if a Graph is created from a
-- GeneralLib directly, it cannot be used
-- If <gtool> is defined, it has priority
EvalSharings (me : in out) is static;
---Purpose : Reevaluates the Sharing Lists of the Graph, starting from the
-- Shared Lists (priority to the redefined ones)
BasicSharedTable (me) returns IntList is static private;
---Purpose : Returns the Table of Basic Shared lists. Used to Create
-- another Graph from <me>
RedefinedSharedTable (me) returns IntList is static private;
---Purpose : Returns the Table of redefined Shared lists. Used to Create
-- another Graph from <me>. Null Handle is no one redefinition
SharingTable (me) returns IntList is static private;
---Purpose : Returns the Table of Sharing lists. Used to Create
-- another Graph from <me>
-- NbVertex(me) returns Integer is static; -- for GraphTools requirements
Reset (me : in out) is static;
---Purpose : Erases data, making graph ready to rebegin from void
-- (also resets Shared lists redefinitions)
ResetStatus (me : in out) is static;
---Purpose : Erases Status (Values and Flags of Presence), making graph
-- ready to rebegin from void. Does not concerns Shared lists
Size (me) returns Integer is static;
---Purpose : Returns size (max nb of entities, i.e. Model's nb of entities)
-- -- Fine Actions -- --
EntityNumber (me; ent : Transient) returns Integer is static;
---Purpose : Returns the Number of the entity in the Map, computed at
-- creation time (Entities loaded from the Model)
-- Returns 0 if <ent> not contained by Model used to create <me>
-- (that is, <ent> is unknown from <me>)
IsPresent (me; num : Integer) returns Boolean is static;
---Purpose : Returns True if an Entity is noted as present in the graph
-- (See methods Get... which determine this status)
-- Returns False if <num> is out of range too
IsPresent (me; ent : Transient) returns Boolean;
---Purpose : Same as above but directly on an Entity <ent> : if it is not
-- contained in the Model, returns False. Else calls
-- IsPresent(num) with <num> given by EntityNumber
Entity (me; num : Integer) returns any Transient is static;
---Purpose : Returns mapped Entity given its no (if it is present)
---C++ : return const &
Status (me; num : Integer) returns Integer is static;
---Purpose : Returns Status associated to a numero (only to read it)
CStatus (me : in out; num : Integer) returns Integer is static;
---Purpose : Returns Status associated to a numero, to be read or changed
---C++ : return &
SetStatus (me : in out; num : Integer; stat : Integer) is static;
---Purpose : Modifies Status associated to a numero
RemoveItem (me : in out; num : Integer) is static;
---Purpose : Clears Entity and sets Status to 0, for a numero
ChangeStatus (me : in out; oldstat, newstat : Integer) is static;
---Purpose : Changes all status which value is oldstat to new value newstat
RemoveStatus (me : in out; stat : Integer) is static;
---Purpose : Removes all items of which status has a given value stat
BitMap (me) returns BitMap;
---Purpose : Returns the Bit Map in order to read or edit flag values
---C++ : return const &
CBitMap (me : in out) returns BitMap;
---Purpose : Returns the Bit Map in order to edit it (add new flags)
---C++ : return &
-- -- General Actions -- --
Model (me) returns InterfaceModel is static;
---Purpose : Returns the Model with which this Graph was created
---C++ : return const &
GetFromModel (me : in out) is static;
---Purpose : Loads Graph with all Entities contained in the Model
GetFromEntity (me : in out; ent : Transient; shared : Boolean;
newstat : Integer = 0) is static;
---Purpose : Gets an Entity, plus its shared ones (at every level) if
-- "shared" is True. New items are set to status "newstat"
-- Items already present in graph remain unchanged
-- Of course, redefinitions of Shared lists are taken into
-- account if there are some
GetFromEntity (me : in out; ent : Transient; shared : Boolean;
newstat, overlapstat : Integer; cumul : Boolean)
is static;
---Purpose : Gets an Entity, plus its shared ones (at every level) if
-- "shared" is True. New items are set to status "newstat".
-- Items already present in graph are processed as follows :
-- - if they already have status "newstat", they remain unchanged
-- - if they have another status, this one is modified :
-- if cumul is True, to former status + overlapstat (cumul)
-- if cumul is False, to overlapstat (enforce)
GetFromIter (me : in out; iter : EntityIterator; newstat : Integer)
is static;
---Purpose : Gets Entities given by an EntityIterator. Entities which were
-- not yet present in the graph are mapped with status "newstat"
-- Entities already present remain unchanged
GetFromIter (me : in out; iter : EntityIterator;
newstat, overlapstat : Integer; cumul : Boolean)
is static;
---Purpose : Gets Entities given by an EntityIterator and distinguishes
-- those already present in the Graph :
-- - new entities added to the Graph with status "newstst"
-- - entities already present with status = "newstat" remain
-- unchanged
-- - entities already present with status different form
-- "newstat" have their status modified :
-- if cumul is True, to former status + overlapstat (cumul)
-- if cumul is False, to overlapstat (enforce)
-- (Note : works as GetEntity, shared = False, for each entity)
GetFromGraph (me : in out; agraph : Graph)
---Purpose : Gets all present items from another graph
raises DomainError is static;
-- Error if the other graph has not been created with same Model
GetFromGraph (me : in out; agraph : Graph; stat : Integer)
---Purpose : Gets items from another graph which have a specific Status
raises DomainError is static;
-- Error if the other graph has not been created with same Model
-- -- Shared Lists -- --
HasShareErrors (me; ent : Transient) returns Boolean is static;
---Purpose : Returns True if <ent> or the list of entities shared by <ent>
-- (not redefined) contains items unknown from this Graph
-- Remark : apart from the status HasShareError, these items
-- are ignored
HasRedefinedShareds (me; ent : Transient) returns Boolean is static;
---Purpose : Returns True if Shared list of <ent> has been redefined
-- (Thus, Shareds from Graph gives a result different from
-- general service Shareds)
Shareds (me; ent : Transient) returns EntityIterator
---Purpose : Returns the list of Entities Shared by an Entity, as recorded
-- by the Graph. That is, by default Basic Shared List, else it
-- can be redefined by methods SetShare, SetNoShare ... see below
raises DomainError is static;
-- Error if <ent> is not contained by the model used for Creation
SharedNums (me; num : Integer) returns IntList is static;
---Purpose : Same as Shareds, but under the form of a list of Integers,
-- each one beeing the Number of a Shared Entity in the Graph
-- Especially intended for fast internal uses
-- Returns a Null Handle if <num> is not contained by <themodel>
Sharings (me; ent : Transient) returns EntityIterator
---Purpose : Returns the list of Entities which Share an Entity, computed
-- from the Basic or Redefined Shared Lists
raises DomainError is static;
-- Error if <ent> is not contained by the model used for Creation
SharingNums (me; num : Integer) returns IntList is static;
---Purpose : Same as Sharings, but under the form of a list of Integers
-- each one beeing the Number of a Sharing Entity in the Graph
TypedSharings (me; ent : Transient; type : Type) returns EntityIterator;
---Purpose : Returns the list of sharings entities, AT ANY LEVEL, which are
-- kind of a given type. A sharing entity kind of this type
-- ends the exploration of its branch
RootEntities (me) returns EntityIterator is static;
---Purpose : Returns the Entities which are not Shared (their Sharing List
-- is empty) in the Model
-- -- Redefinitions of Shared-Sharing Lists -- --
SetShare (me : in out; ent : Transient) is static;
---Purpose : Sets explicit the shared list of an Entity <ent>, that is,
-- available for a further edit (Add/Remove). All SetShare and
-- SetNoShare methods allow further edit operations.
-- Effect cancelled by ResetShare
-- Remark that all Redefinition methods work on Shared Lists,
-- but also manage (update) the Sharing Lists
SetShare (me : in out; ent : Transient; list : EntityIterator)
is static;
---Purpose : Sets as Shared list of an Entity <ent> considered by <me>,
-- the list given as an EntityIterator <iter>. It can be empty.
-- This list will now be considered by method Shareds above
-- Does nothing if <ent> is not contained by <themodel>
SetShare (me : in out; ent : Transient; list : IntList)
is static;
---Purpose : Same as above, but the list is given as the list of Numbers
-- of the Entities shared by <ent>
SetNoShare (me : in out; ent : Transient) is static;
---Purpose : Sets the Shared list of an Entity considered in <me> as beeing
-- Empty (if <ent> is contained by <themodel>)
SetNoShare (me : in out; list : EntityIterator) is static;
---Purpose : Sets the Shared lists of a list of Entities to be Empty
AddShared (me : in out; ent,shared : Transient)
---Purpose : Adds a shared Entity to a redefined Shared List (formerly
-- defined by SetShare or SetNoShare). Does nothing if already in
raises DomainError is static;
-- Error if no shared list was formerly redefined for <ent>
RemoveShared (me : in out; ent,shared : Transient)
---Purpose : Removes a shared Entity from a redefined Shared List (formerly
-- defined ...). Does nothing if <shared> no in the list
raises DomainError is static;
-- Error if no shared list was formerly redefined for <ent>
ResetShare (me : in out; ent : Transient) is static;
---Purpose : Comes back to the standard Shared list for <ent> : Cancels all
-- the former redefinitions for it
ResetAllShare (me : in out) is static;
---Purpose : Clears all effects of former redefinition of Shared lists
Name (me; ent : Transient) returns HAsciiString;
---Purpose : Determines the name attached to an entity, by using the
-- general service Name in GeneralModule
-- Returns a null handle if no name could be computed or if
-- the entity is not in the model
fields
themodel : InterfaceModel; -- Model which contains the Entities
thepresents : AsciiString from TCollection; -- flags present/or not
thestats : Array1OfInteger from TColStd; -- numeric status
theflags : BitMap; -- logical flags status
theshareds : IntList; -- Basic Shared Lists (one per Entity)
thesharnews : IntList; -- Shared Lists Redefinitions
thesharings : IntList; -- The Sharing Lists (one per Entity)
end Graph;

692
src/Interface/Interface_Graph.cxx Executable file
View File

@@ -0,0 +1,692 @@
#include <Interface_Graph.ixx>
#include <Interface_GeneralModule.hxx>
#include <Interface_ReportEntity.hxx>
#include <Standard_DomainError.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Interface_ShareTool.hxx>
// Flags : 0 = Presence, 1 = Sharing Error
#define Graph_Present 0
#define Graph_ShareError 1
// ###########################################################################
// .... CONSTRUCTEURS ....
// .... Construction a partir de la connaissance des Entites ....
Interface_Graph::Interface_Graph
(const Handle(Interface_InterfaceModel)& amodel,
const Interface_GeneralLib& lib)
: themodel (amodel), thepresents ("") , thestats (0,amodel->NbEntities()) ,
theflags (amodel->NbEntities(),2) ,
theshareds (amodel->NbEntities()) , /*thesharnews(amodel->NbEntities()) , */
thesharings (amodel->NbEntities())
{
Handle(Interface_GTool) gtool; // null
theflags.AddFlag ("ShareError"); // -> flag n0 1
Evaluate(lib,gtool);
}
Interface_Graph::Interface_Graph
(const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_Protocol)& protocol)
: themodel (amodel) , thepresents ("") ,
thestats (0,amodel->NbEntities()) , theflags (amodel->NbEntities(),2) ,
theshareds (amodel->NbEntities()) , /*thesharnews(amodel->NbEntities()) ,*/
thesharings (amodel->NbEntities())
{
Handle(Interface_GTool) gtool; // null
theflags.AddFlag ("ShareError"); // -> flag n0 1
Evaluate(Interface_GeneralLib(protocol),gtool);
}
Interface_Graph::Interface_Graph
(const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_GTool)& gtool)
: themodel (amodel) , thepresents ("") ,
thestats (0,amodel->NbEntities()) , theflags (amodel->NbEntities(),2) ,
theshareds (amodel->NbEntities()) , /*thesharnews(amodel->NbEntities()) , */
thesharings (amodel->NbEntities())
{
theflags.AddFlag ("ShareError"); // -> flag n0 1
Evaluate(gtool->Lib(),gtool);
}
Interface_Graph::Interface_Graph
(const Handle(Interface_InterfaceModel)& amodel)
: themodel (amodel) , thepresents ("") ,
thestats (0,amodel->NbEntities()) , theflags (amodel->NbEntities(),2) ,
theshareds (amodel->NbEntities()) ,
/*thesharnews(amodel->NbEntities()) ,*/ thesharings (amodel->NbEntities())
{
theflags.AddFlag ("ShareError"); // -> flag n0 1
Handle(Interface_GTool) gtool = amodel->GTool();
if (gtool.IsNull()) return;
gtool->Reservate(amodel->NbEntities());
Evaluate (gtool->Lib(),gtool);
}
void Interface_Graph::Evaluate
(const Interface_GeneralLib& lib, const Handle(Interface_GTool)& gtool)
{
// Evaluation d un Graphe de dependances : sur chaque Entite, on prend sa
// liste "Shared". On en deduit les "Sharing" directement
Standard_Boolean patool = gtool.IsNull();
Standard_Integer n = Size(), total = 0;
theshareds.Clear();
thesharings.Clear();
TColStd_Array1OfInteger counts (0,n); counts.Init(0);
TColStd_Array1OfInteger lasts (0,n); lasts.Init(0);
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= n; i ++) {
theshareds.SetNumber (i);
// ATTENTION : Si Entite non chargee donc illisible, basculer sur son
// "Contenu" equivalent
Handle(Standard_Transient) ent = themodel->Value(i);
if (themodel->IsRedefinedContent(i)) ent = themodel->ReportEntity(i)->Content();
// Resultat obtenu via GeneralLib
Interface_EntityIterator iter;
Handle(Interface_GeneralModule) module;
Standard_Integer CN;
if (patool) {
if (lib.Select(ent,module,CN)) module->FillShared(themodel,CN,ent,iter);
} else {
if (gtool->Select(ent,module,CN)) module->FillShared(themodel,CN,ent,iter);
}
theshareds.Reservate (iter.NbEntities());
// Mise en forme : liste d entiers
for (iter.Start(); iter.More(); iter.Next()) {
// num = 0 -> on sort du Model de depart, le noter "Error" et passer
Standard_Integer num = EntityNumber(iter.Value());
if (num == 0) theflags.SetTrue (i,Graph_ShareError);
else {
// controle d unicite de couple (pere-fils)
if (lasts(num) == i) continue;
total ++;
lasts.ChangeValue(num) = i;
theshareds.Add (num);
counts.ChangeValue(num) ++;
// References inverses : plus tard
}
}
}
// Les references inverses : preallocation (pour compte > 1 seulement)
thesharings.SetNumber(0); thesharings.Reservate (total);
for (i = 1; i <= n; i ++) {
if (counts(i) < 2) continue;
thesharings.SetNumber(i);
thesharings.Reservate (-counts(i));
}
// Enregistrement par inversion
for (i = 1; i <= n; i ++) {
theshareds.SetNumber (i);
Standard_Integer j,num, nb = theshareds.Length();
for (j = 1; j <= nb; j ++) {
num = theshareds.Value(j);
thesharings.SetNumber(-num);
thesharings.Add(-i);
}
}
}
void Interface_Graph::EvalSharings ()
{
thesharings.Clear();
Standard_Integer n = thesharings.NbEntities();
// Difference avec Evaluate : SharedNums prend les Redefinis si necessaire
for (Standard_Integer i = 1; i <= n; i ++) {
Standard_Integer nb, num;
if (thesharnews.IsRedefined(i)) {
thesharnews.SetNumber(i);
nb = thesharnews.Length();
for (Standard_Integer j = 1; j <= nb; j ++) {
num = thesharnews.Value (j);
thesharings.SetNumber (num);
thesharings.Reservate (thesharings.Length()+1);
thesharings.Add (i);
}
} else {
theshareds.SetNumber(i);
nb = theshareds.Length();
for (Standard_Integer j = 1; j <= nb; j ++) {
num = theshareds.Value (j);
thesharings.SetNumber (num);
thesharings.Reservate (thesharings.Length()+1);
thesharings.Add (i);
}
}
}
}
// .... Construction depuis un autre Graph ....
Interface_Graph::Interface_Graph
(const Interface_Graph& agraph, const Standard_Boolean /*copied*/)
: themodel (agraph.Model()), thepresents ("") ,
thestats (0,agraph.Size()) ,
theflags (agraph.BitMap(),Standard_True) ,
theshareds (agraph.BasicSharedTable(),Standard_True) ,
thesharnews (agraph.RedefinedSharedTable(),Standard_True) ,
thesharings (agraph.SharingTable(),Standard_True)
{
Standard_Integer nb = Size();
for (Standard_Integer i = 1; i <= nb; i ++)
thestats.SetValue (i,agraph.Status(i));
}
Interface_IntList Interface_Graph::BasicSharedTable () const
{ return theshareds; }
Interface_IntList Interface_Graph::RedefinedSharedTable () const
{ return thesharnews; }
Interface_IntList Interface_Graph::SharingTable () const
{ return thesharings; }
// ###########################################################################
// .... ACCES UNITAIRES AUX DONNEES DE BASE ....
void Interface_Graph::Reset ()
{
thestats.Init(0);
theflags.Init (Standard_False, Graph_Present);
thesharnews.Clear();
EvalSharings();
}
void Interface_Graph::ResetStatus ()
{ thestats.Init(0); theflags.Init (Standard_False, Graph_Present); }
Standard_Integer Interface_Graph::Size () const
{ return thestats.Upper(); }
Standard_Integer Interface_Graph::EntityNumber
(const Handle(Standard_Transient)& ent) const
{ return themodel->Number(ent); }
Standard_Boolean Interface_Graph::IsPresent
(const Standard_Integer num) const
{
if (num <= 0 || num > Size()) return Standard_False;
return theflags.Value (num,Graph_Present);
}
Standard_Boolean Interface_Graph::IsPresent
(const Handle(Standard_Transient)& ent) const
{ return IsPresent(EntityNumber(ent)); }
const Handle(Standard_Transient)& Interface_Graph::Entity
(const Standard_Integer num) const
{ return themodel->Value(num); }
Standard_Integer Interface_Graph::Status (const Standard_Integer num) const
{ return thestats.Value(num); }
Standard_Integer& Interface_Graph::CStatus (const Standard_Integer num)
{ return thestats.ChangeValue(num); }
void Interface_Graph::SetStatus
(const Standard_Integer num, const Standard_Integer stat)
{ thestats.SetValue(num,stat); }
void Interface_Graph::RemoveItem(const Standard_Integer num)
{
thestats.SetValue(num,0); theflags.SetFalse (num,Graph_Present);
}
void Interface_Graph::ChangeStatus
(const Standard_Integer oldstat, const Standard_Integer newstat)
{
Standard_Integer nb = thestats.Upper();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thestats.Value(i) == oldstat) thestats.SetValue(i,newstat);
}
}
void Interface_Graph::RemoveStatus(const Standard_Integer stat)
{
Standard_Integer nb = thestats.Upper();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thestats.Value(i) == stat) RemoveItem(i);
}
}
const Interface_BitMap& Interface_Graph::BitMap () const
{ return theflags; }
Interface_BitMap& Interface_Graph::CBitMap ()
{ return theflags; }
// ###########################################################################
// .... Chargements Elementaires avec Propagation de "Share" .... //
const Handle(Interface_InterfaceModel)& Interface_Graph::Model() const
{ return themodel; }
void Interface_Graph::GetFromModel ()
{
if (themodel.IsNull()) return; // no model ... (-> on n ira pas loin)
theflags.Init (Standard_True,Graph_Present);
thestats.Init (0);
}
void Interface_Graph::GetFromEntity
(const Handle(Standard_Transient)& ent, const Standard_Boolean shared,
const Standard_Integer newstat)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
if (theflags.CTrue(num,Graph_Present)) return; // deja pris : on passe
thestats.SetValue(num,newstat);
if (!shared) return;
// Attention a la redefinition !
Interface_IntList list = thesharnews;
if (!list.IsRedefined(num)) list = theshareds;
list.SetNumber (num);
Standard_Integer nb = list.Length();
for (Standard_Integer i = 1; i <= nb; i ++) GetFromEntity
(themodel->Value (list.Value(i)),Standard_True,newstat);
}
void Interface_Graph::GetFromEntity
(const Handle(Standard_Transient)& ent, const Standard_Boolean shared,
const Standard_Integer newstat, const Standard_Integer overlapstat,
const Standard_Boolean cumul)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
Standard_Boolean pasla = !theflags.CTrue (num,Graph_Present);
Standard_Integer stat = thestats.Value(num);
if (pasla) {
/// theflags.SetTrue (num, Graph_Present); // nouveau : noter avec newstat
thestats.SetValue(num,newstat);
} else {
Standard_Integer overstat = stat;
if (stat != newstat) { // deja pris, meme statut : passer
if (cumul) overstat += overlapstat; // nouveau statut : avec cumul ...
else overstat = overlapstat; // ... ou sans (statut force)
if (stat != overstat) // si repasse deja faite, passer
thestats.SetValue(num,overstat);
}
}
if (!shared) return;
// Attention a la redefinition !
Interface_IntList list = thesharnews;
if (!list.IsRedefined(num)) list = theshareds;
list.SetNumber (num);
Standard_Integer nb = list.Length();
for (Standard_Integer i = 1; i <= nb; i ++) GetFromEntity
(themodel->Value (list.Value(i)),Standard_True,newstat);
}
void Interface_Graph::GetFromIter
(const Interface_EntityIterator& iter, const Standard_Integer newstat)
{
for (iter.Start(); iter.More(); iter.Next()) {
Handle(Standard_Transient) ent = iter.Value();
Standard_Integer num = EntityNumber(ent);
if (num == 0) continue;
if (theflags.CTrue(num,Graph_Present)) continue;
thestats.SetValue(num,newstat);
}
}
void Interface_Graph::GetFromIter
(const Interface_EntityIterator& iter,
const Standard_Integer newstat, const Standard_Integer overlapstat,
const Standard_Boolean cumul)
{
for (iter.Start(); iter.More(); iter.Next()) {
Handle(Standard_Transient) ent = iter.Value();
Standard_Integer num = EntityNumber(ent);
if (num == 0) continue;
/*Standard_Boolean pasla = !*/theflags.Value(num,Graph_Present);
/*Standard_Integer stat = */thestats.Value(num);
GetFromEntity (ent,Standard_False,newstat,overlapstat,cumul);
}
}
void Interface_Graph::GetFromGraph (const Interface_Graph& agraph)
{
if (Model() != agraph.Model()) Standard_DomainError::Raise
("Graph from Interface : GetFromGraph");
Standard_Integer nb = Size();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (agraph.IsPresent(i))
GetFromEntity (agraph.Entity(i),Standard_False,agraph.Status(i));
}
}
void Interface_Graph::GetFromGraph
(const Interface_Graph& agraph, const Standard_Integer stat)
{
if (Model() != agraph.Model()) Standard_DomainError::Raise
("Graph from Interface : GetFromGraph");
Standard_Integer nb = Size();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (agraph.IsPresent(i) && agraph.Status(i) == stat)
GetFromEntity (agraph.Entity(i),Standard_False,stat);
}
}
// #####################################################################
// .... Listage des Entites Partagees ....
Standard_Boolean Interface_Graph::HasShareErrors
(const Handle(Standard_Transient)& ent) const
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return Standard_True;
return theflags.Value (num,Graph_ShareError);
}
// A chaque entite, on peut attacher une Liste de numeros d entites partagees
// Si elle est nulle, BasicShareds convient, sinon on prend RedefinedShareds
Standard_Boolean Interface_Graph::HasRedefinedShareds
(const Handle(Standard_Transient)& ent) const
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return Standard_False;
return thesharnews.IsRedefined (num);
}
Interface_EntityIterator Interface_Graph::Shareds
(const Handle(Standard_Transient)& ent) const
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) Standard_DomainError::Raise ("Interface : Shareds");
Interface_EntityIterator iter;
Interface_IntList list = thesharnews;
if (!list.IsRedefined(num)) list = theshareds;
list.SetNumber (num);
Standard_Integer nb = list.Length();
for (Standard_Integer i = 1; i <= nb; i ++)
iter.GetOneItem (themodel->Value (list.Value(i) ));
return iter;
}
Interface_IntList Interface_Graph::SharedNums
(const Standard_Integer num) const
{
Interface_IntList list = thesharnews;
if (!list.IsRedefined(num)) list = theshareds;
list.SetNumber (num);
return list;
}
Interface_EntityIterator Interface_Graph::Sharings
(const Handle(Standard_Transient)& ent) const
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) Standard_DomainError::Raise ("Interface : Sharings");
Interface_EntityIterator iter;
Interface_IntList list = thesharings; list.SetNumber (num);
Standard_Integer nb = list.Length();
for (Standard_Integer i = 1; i <= nb; i ++)
iter.GetOneItem (themodel->Value(list.Value(i)));
return iter;
}
Interface_IntList Interface_Graph::SharingNums
(const Standard_Integer num) const
{
Interface_IntList list = thesharings;
if (num > 0) list.SetNumber (num);
return list;
}
static void AddTypedSharings
(const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& type,
Interface_EntityIterator& iter, const Standard_Integer n,
const Interface_Graph& G)
{
if (ent.IsNull()) return;
if (ent->IsKind(type)) { iter.AddItem (ent); return; }
if (iter.NbEntities() > n) return;
Interface_IntList list = G.SharingNums(G.EntityNumber(ent));
Standard_Integer nb = list.Length();
for (Standard_Integer i = 1; i <= nb; i ++)
AddTypedSharings (G.Entity(list.Value(i)) ,type,iter,nb,G);
}
Interface_EntityIterator Interface_Graph::TypedSharings
(const Handle(Standard_Transient)& ent, const Handle(Standard_Type)& type) const
{
Interface_EntityIterator iter;
Standard_Integer n = Size();
AddTypedSharings (ent,type,iter,n,*this);
return iter;
}
Interface_EntityIterator Interface_Graph::RootEntities () const
{
Interface_EntityIterator iter;
Standard_Integer nb = Size();
Interface_IntList list (thesharings);
for (Standard_Integer i = 1; i <= nb; i ++) {
list.SetNumber (i);
if (list.Length() == 0) iter.GetOneItem (themodel->Value(i));
}
return iter;
}
// ######################################################################
// .... Redefinition des listes Shared-Sharing ....
void Interface_Graph::SetShare
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
SetShare (ent,SharedNums(num));
}
void Interface_Graph::SetShare
(const Handle(Standard_Transient)& ent,
const Interface_EntityIterator& list)
{
if(!thesharnews.NbEntities())
thesharnews.Initialize(themodel->NbEntities());
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
thesharnews.SetNumber (num);
thesharnews.SetRedefined (Standard_True);
thesharnews.Reservate (list.NbEntities());
for (list.Start(); list.More(); list.Next()) {
Standard_Integer nsh = EntityNumber(list.Value());
if (nsh != 0) thesharnews.Add (nsh);
}
}
void Interface_Graph::SetShare
(const Handle(Standard_Transient)& ent, const Interface_IntList& list)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
if(!thesharnews.NbEntities())
thesharnews.Initialize(themodel->NbEntities());
Standard_Integer i, n = list.Length();
thesharnews.SetNumber (num);
thesharnews.SetRedefined (Standard_True);
thesharnews.Reservate (n);
for (i = 1; i <= n; i ++) {
Standard_Integer nsh = list.Value(i);
if (nsh != 0) thesharnews.Add (nsh);
}
}
void Interface_Graph::SetNoShare
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
if(!thesharnews.NbEntities()) return;
thesharnews.SetNumber (num);
thesharnews.SetRedefined (Standard_False);
}
void Interface_Graph::SetNoShare (const Interface_EntityIterator& list)
{
for (list.Start(); list.More(); list.Next()) SetNoShare(list.Value());
}
void Interface_Graph::AddShared
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Transient)& shared)
{
//Standard_Integer i, nb; svv Feb21 2000 : porting on SIL
Standard_Integer num = EntityNumber(ent);
Standard_Integer nsh = EntityNumber(shared);
if (!thesharnews.IsRedefined(num) || num == 0 || nsh == 0) Standard_DomainError::Raise
("Interface Graph : AddShared, cannot be applied");
if(!thesharnews.NbEntities())
thesharnews.Initialize(themodel->NbEntities());
// Liste Shared(ent)
thesharnews.SetNumber (num);
thesharnews.Reservate (thesharnews.Length()+1);
thesharnews.Add (nsh);
// Liste Sharing(shared)
thesharings.SetNumber (nsh);
thesharings.Reservate (thesharings.Length()+1);
thesharings.Add (num);
}
void Interface_Graph::RemoveShared
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Transient)& shared)
{
Standard_Integer num = EntityNumber(ent);
Standard_Integer nsh = EntityNumber(shared);
if (!thesharnews.IsRedefined(num) || num == 0 || nsh == 0) Standard_DomainError::Raise
("Interface Graph : RemoveShared, cannot be applied");
// Liste Shared (ent)
if(!thesharnews.NbEntities())
thesharnews.Initialize(themodel->NbEntities());
thesharnews.SetNumber (num);
Standard_Integer i,nbsh = thesharnews.Length();
for (i = nbsh; i > 0; i --)
if (thesharnews.Value(i) == nsh) thesharnews.Remove(i);
// Liste Sharing (shared)
thesharings.SetNumber (nsh);
nbsh = thesharings.Length();
for (i = nbsh; i > 0; i --)
if (thesharings.Value(i) == num) thesharings.Remove(i);
}
void Interface_Graph::ResetShare
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = EntityNumber(ent);
if (num == 0) return;
Interface_IntList snew(thesharnews);
if (!thesharnews.NbEntities() || !snew.IsRedefined(num)) return;
snew.SetNumber (num);
Interface_IntList sold(theshareds);
sold.SetNumber (num);
// Attention aux Sharings ... Il va falloir ajouter, supprimer ... laisser !
// Tableau // Entites : 0 hors jeu 1 reapparait 2 disparait 3 reste
Standard_Integer n = Size();
TColStd_Array1OfInteger oldnew(1,n); oldnew.Init(0);
Standard_Integer ns = sold.Length();
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= ns; i ++)
oldnew.SetValue(sold.Value(i),1); // pourra passer en 3 plus tard ...
ns = snew.Length();
for (i = 1; i <= ns; i ++) {
Standard_Integer oldstat = oldnew.Value(snew.Value(i));
oldnew.SetValue(snew.Value(i),oldstat+2); // 0 -> 2, 1 -> 3
}
// Muni de ces donnees, on pourra modifier les listes Sharings impliquees
for (i = 1; i <= n; i ++) {
Standard_Integer oldstat = oldnew.Value(snew.Value(i));
if (oldstat == 0 || oldstat == 2) continue;
thesharings.SetNumber(i);
if (oldstat == 1) {
thesharings.Reservate (thesharings.Length()+1);
thesharings.Add (num);
} else if (oldstat == 3) {
Standard_Integer j,nbsh = thesharings.Length();
for (j = nbsh; j > 0; j --)
if (thesharings.Value(j) == num) thesharings.Remove(j);
}
}
// Shared : beaucoup plus simple, ANNULER Redefined
thesharnews.SetRedefined (Standard_False);
}
void Interface_Graph::ResetAllShare ()
{
thesharnews.Clear();
EvalSharings();
}
Handle(TCollection_HAsciiString) Interface_Graph::Name
(const Handle(Standard_Transient)& ent) const
{
Handle(TCollection_HAsciiString) str;
if (themodel.IsNull()) return str;
if (themodel->Number(ent)) return str;
Handle(Interface_GTool) gtool = themodel->GTool();
if (gtool.IsNull()) return str;
Handle(Interface_GeneralModule) module;
Standard_Integer CN;
if (!gtool->Select(ent,module,CN)) return str;
Interface_ShareTool sht (*this);
return module->Name (CN,ent,sht);
}

View File

@@ -0,0 +1,61 @@
-- File: GraphContent.cdl
-- Created: Wed Sep 23 10:23:20 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class GraphContent from Interface inherits EntityIterator
---Purpose : Defines general form for classes of graph algorithms on
-- Interfaces, this form is that of EntityIterator
-- Each sub-class fills it according to its own algorithm
-- This also allows to combine any graph result to others,
-- all being given under one unique form
uses Transient, Graph
is
Create returns GraphContent;
---Purpose : Creates an empty GraphContent, ready to be filled
Create (agraph : Graph) returns GraphContent;
---Purpose : Creates with all entities designated by a Graph
Create (agraph : Graph; stat : Integer) returns GraphContent;
---Purpose : Creates with entities having specific Status value in a Graph
Create (agraph : Graph; ent : Transient) returns GraphContent;
---Purpose : Creates an Iterator with Shared entities of an entity
-- (equivalente to EntityIterator but with a Graph)
GetFromGraph (me : in out; agraph : Graph);
---Purpose : Gets all Entities designated by a Graph (once created), adds
-- them to those already recorded
GetFromGraph (me : in out; agraph : Graph; stat : Integer);
---Purpose : Gets entities from a graph which have a specific Status value
-- (one created), adds them to those already recorded
Result (me : in out) returns EntityIterator;
---Purpose : Returns Result under the exact form of an EntityIterator :
-- Can be used when EntityIterator itself is required (as a
-- returned value for instance), whitout way for a sub-class
-- -- Evaluation - Iteration -- --
-- Made by Start-More-Next-Value inherited from EntityIterator
-- Start is redefined to call Evaluate moreover
-- Default for Evaluate is given as doing nothing
-- Start (me : in out) is redefined;
Begin (me : in out);
---Purpose : Does the Evaluation before starting the iteration itself
-- (in out)
Evaluate (me : in out) is virtual;
---Purpose : Evaluates list of Entities to be iterated. Called by Start
-- Default is set to doing nothing : intended to be redefined
-- by each sub-class
end GraphContent;

View File

@@ -0,0 +1,65 @@
#include <Interface_GraphContent.ixx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_IntList.hxx>
Interface_GraphContent::Interface_GraphContent () { }
Interface_GraphContent::Interface_GraphContent
(const Interface_Graph& agraph)
{ GetFromGraph(agraph); }
Interface_GraphContent::Interface_GraphContent
(const Interface_Graph& agraph, const Standard_Integer stat)
{ GetFromGraph(agraph,stat); }
Interface_GraphContent::Interface_GraphContent
(const Interface_Graph& agraph, const Handle(Standard_Transient)& ent)
{
Interface_IntList list =
agraph.SharedNums(agraph.EntityNumber(ent));
Standard_Integer nb = list.Length();
if (nb == 0) return; // Liste redefinie a VIDE
Handle(Interface_InterfaceModel) mod = agraph.Model();
for (Standard_Integer i = 1; i <= nb; i ++) {
Standard_Integer num = list.Value(i);
if (agraph.IsPresent(num)) GetOneItem (agraph.Entity(num));
}
}
void Interface_GraphContent::GetFromGraph (const Interface_Graph& agraph)
{
Standard_Integer nb = agraph.Size();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (agraph.IsPresent(i)) GetOneItem (agraph.Entity(i));
}
}
void Interface_GraphContent::GetFromGraph
(const Interface_Graph& agraph, const Standard_Integer stat)
{
Standard_Integer nb = agraph.Size();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (agraph.IsPresent(i) && agraph.Status(i) == stat)
GetOneItem (agraph.Entity(i));
}
}
Interface_EntityIterator Interface_GraphContent::Result ()
{
Interface_EntityIterator iter; // On transvase ...
for (Begin(); More(); Next()) iter.GetOneItem(Value());
return iter;
}
void Interface_GraphContent::Begin ()
{
Evaluate();
Interface_EntityIterator::Start();
}
void Interface_GraphContent::Evaluate ()
{ } // par defaut, Evaluate ne fait rien

View File

@@ -0,0 +1,58 @@
-- File: Interface_HGraph.cdl
-- Created: Thu Apr 22 18:40:22 1993
-- Author: Christian CAILLET
-- <cky@bravox>
---Copyright: Matra Datavision 1993
class HGraph from Interface inherits TShared
---Purpose : This class allows to store a redefinable Graph, via a Handle
-- (usefull for an Object which can work on several successive
-- Models, with the same general conditions)
uses Graph, InterfaceModel, GeneralLib, Protocol, GTool
raises DomainError
is
Create (agraph : Graph) returns mutable HGraph;
---Purpose : Creates an HGraph directly from a Graph.
-- Remark that the starting Graph is duplicated
Create (amodel : InterfaceModel; lib : GeneralLib) returns mutable HGraph;
---Purpose : Creates an HGraph with a Graph created from <amodel> and <lib>
Create (amodel : InterfaceModel; protocol : Protocol from Interface)
returns mutable HGraph;
---Purpose : Creates an HGraph with a graph itself created from <amodel>
-- and <protocol>
Create (amodel : InterfaceModel; gtool : GTool from Interface)
returns mutable HGraph;
---Purpose : Creates an HGraph with a graph itself created from <amodel>
-- and <protocol>
Create (amodel : InterfaceModel) returns mutable HGraph
---Purpose : Same a above, but works with the GTool in the model
raises DomainError;
-- Error if no Active Protocol is defined
Graph (me) returns Graph;
---Purpose : Returns the Graph contained in <me>, for Read Only Operations
-- Remark that it is returns as "const &"
-- Getting it in a new variable instead of a reference would be
-- a pitty, because all the graph's content would be duplicated
---C++ : return const &
CGraph (me : mutable) returns Graph;
---Purpose : Same as above, but for Read-Write Operations
-- Then, The Graph will be modified in the HGraph itself
---C++ : return &
fields
thegraph : Graph;
end HGraph;

View File

@@ -0,0 +1,37 @@
#include <Interface_HGraph.ixx>
Interface_HGraph::Interface_HGraph (const Interface_Graph& agraph)
: thegraph(agraph) { }
Interface_HGraph::Interface_HGraph
(const Handle(Interface_InterfaceModel)& amodel,
const Interface_GeneralLib& lib)
: thegraph (amodel,lib) { }
Interface_HGraph::Interface_HGraph
(const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_Protocol)& protocol)
: thegraph (amodel,protocol) { }
Interface_HGraph::Interface_HGraph
(const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_GTool)& gtool)
: thegraph (amodel,gtool) { }
Interface_HGraph::Interface_HGraph
(const Handle(Interface_InterfaceModel)& amodel)
: thegraph (amodel) { }
const Interface_Graph& Interface_HGraph::Graph () const
{ return thegraph; }
Interface_Graph& Interface_HGraph::CGraph ()
{ return thegraph; }

View File

@@ -0,0 +1,122 @@
-- File: Interface_IntList.cdl
-- Created: Fri May 12 17:48:33 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
class IntList from Interface
---Purpose : This class detains the data which describe a Graph. A Graph
-- has two lists, one for shared refs, one for sharing refs
-- (the reverses). Each list comprises, for each Entity of the
-- Model of the Graph, a list of Entities (shared or sharing).
-- In fact, entities are identified by their numbers in the Model
-- or Graph : this gives better performances.
--
-- A simple way to implement this is to instantiate a HArray1
-- with a HSequenceOfInteger : each Entity Number designates a
-- value, which is a Sequence (if it is null, it is considered as
-- empty : this is a little optimisation).
--
-- This class gives a more efficient way to implement this.
-- It has two lists (two arrays of integers), one to describe
-- list (empty, one value given immediately, or negated index in
-- the second list), one to store refs (pointed from the first
-- list). This is much more efficient than a list of sequences,
-- in terms of speed (especially for read) and of memory
--
-- An IntList can also be set to access data for a given entity
-- number, it then acts as a single sequence
--
-- Remark that if an IntList is created from another one, it can
-- be read, but if it is created without copying, it may not be
-- edited
uses HArray1OfInteger
is
Create returns IntList;
---Purpose :Creates empty IntList.
Create (nbe : Integer) returns IntList;
---Purpose : Creates an IntList for <nbe> entities
Create (other : IntList; copied : Boolean) returns IntList;
---Purpose : Creates an IntList from another one.
-- if <copied> is True, copies data
-- else, data are not copied, only the header object is
Initialize(me : in out;nbe : Integer);
---Purpose :Initialize IntList by number of entities.
Internals (me; nbrefs : out Integer; ents, refs : out mutable HArray1OfInteger);
---Purpose : Returns internal values, used for copying
NbEntities (me) returns Integer;
---Purpose : Returns count of entities to be aknowledged
SetNbEntities (me : in out; nbe : Integer);
---Purpose : Changes the count of entities (ignored if decreased)
SetNumber (me : in out; number : Integer);
---Purpose : Sets an entity number as current (for read and fill)
Number (me) returns Integer;
---Purpose : Returns the current entity number
List (me; number : Integer; copied : Boolean = Standard_False) returns IntList;
---Purpose : Returns an IntList, identical to <me> but set to a specified
-- entity Number
-- By default, not copied (in order to be read)
-- Specified <copied> to produce another list and edit it
SetRedefined (me : in out; mode : Boolean);
---Purpose : Sets current entity list to be redefined or not
-- This is used in a Graph for redefinition list : it can be
-- disable (no redefinition, i.e. list is cleared), or enabled
-- (starts as empty). The original list has not to be "redefined"
Reservate (me : in out; count : Integer);
---Purpose : Makes a reservation for <count> references to be later
-- attached to the current entity. If required, it increases
-- the size of array used to store refs. Remark that if count is
-- less than two, it does nothing (because immediate storing)
Add (me : in out; ref : Integer);
---Purpose : Adds a reference (as an integer value, an entity number) to
-- the current entity number. Zero is ignored
Length (me) returns Integer;
---Purpose : Returns the count of refs attached to current entity number
IsRedefined (me; num : Integer = 0) returns Boolean;
---Purpose : Returns True if the list for a number (default is taken as
-- current) is "redefined" (usefull for empty list)
Value (me; num : Integer) returns Integer;
---Purpose : Returns a reference number in the list for current number,
-- according to its rank
Remove (me : in out; num : Integer) returns Boolean;
---Purpose : Removes an item in the list for current number, given its rank
-- Returns True if done, False else
Clear (me : in out);
---Purpose : Clears all data, hence each entity number has an empty list
AdjustSize (me : in out; margin : Integer = 0);
---Purpose : Resizes lists to exact sizes. For list of refs, a positive
-- margin can be added.
fields
thenbe : Integer;
thenbr : Integer;
thenum : Integer; -- for current entity number :
thecount : Integer;
therank : Integer;
theents : HArray1OfInteger;
therefs : HArray1OfInteger;
end IntList;

View File

@@ -0,0 +1,284 @@
//szv#4 S4163
#include <Interface_IntList.ixx>
// Organisation des donnees :
// theents vaut : 0 pas de reference
// > 0 : une reference, dont voici la valeur; pas de liste
// < 0 : une liste de references; on stocke <rank>, elle debute a <rank>+1
// la liste est dans therefs et est ainsi constitue :
// liste de valeurs negatives, se terminant pas une valeur positive :
// de <rank>+1 a <rank>+nb , <rank>+1 a <rank>+nb-1 sont negatifs et
// <rank>+nb est negatif
// un zero signifie : place libre
// Pre-reservation : <rank> note le nombre courant, en positif strict
// Il faut alors l incrementer a chaque ajout
// Usage contextuel, il faut demander SetNumber(num < 0) pour exploiter cette
// info et Add(ref < 0) pour la gerer.
// Si elle n est pas presente, on bascule en mode courant
Interface_IntList::Interface_IntList ()
{
thenbe = thenbr = thenum = thecount = therank = 0;
}
Interface_IntList::Interface_IntList (const Standard_Integer nbe)
{
Initialize (nbe);
}
Interface_IntList::Interface_IntList (const Interface_IntList& other, const Standard_Boolean copied)
{
thenbe = other.NbEntities();
thenum = thecount = therank = 0; //szv#4:S4163:12Mar99 initialization needed
other.Internals (thenbr, theents, therefs);
if (copied) {
Standard_Integer i;
Handle(TColStd_HArray1OfInteger) ents = new TColStd_HArray1OfInteger (0,thenbe); ents->Init(0);
for (i = 1; i <= thenbe; i ++) ents->SetValue (i,theents->Value(i));
Handle(TColStd_HArray1OfInteger) refs = new TColStd_HArray1OfInteger (0,thenbr); refs->Init(0);
for (i = 1; i <= thenbr; i ++) refs->SetValue (i,therefs->Value(i));
theents = ents;
therefs = refs;
}
SetNumber (other.Number());
}
void Interface_IntList::Initialize (const Standard_Integer nbe)
{
thenbe = nbe; thenbr = thenum = thecount = therank = 0;
theents = new TColStd_HArray1OfInteger (0,nbe); theents->Init(0);
}
void Interface_IntList::Internals (Standard_Integer& nbrefs,
Handle(TColStd_HArray1OfInteger)& ents,
Handle(TColStd_HArray1OfInteger)& refs) const
{
nbrefs = thenbr; ents = theents; refs = therefs;
}
Standard_Integer Interface_IntList::NbEntities () const
{
return thenbe;
}
void Interface_IntList::SetNbEntities (const Standard_Integer nbe)
{
if (nbe <= theents->Upper()) return;
Standard_Integer i;
Handle(TColStd_HArray1OfInteger) ents = new TColStd_HArray1OfInteger (0,nbe); ents->Init(0);
for (i = 1; i <= thenbe; i ++) ents->SetValue (i,theents->Value(i));
theents = ents;
thenbe = nbe;
}
void Interface_IntList::SetNumber (const Standard_Integer number)
{
// Usage en pre-reservation : a demander specifiquement ! -> optimisation
// <preres> verifie que la pre-reservation est valide
if (number < 0) {
if (thenum == -number || number < - thenbe) return;
Standard_Boolean preres = Standard_True;
thenum = -number;
Standard_Integer val = theents->Value (thenum);
if (val == 0) { thecount = 0; therank = 0; }
else if (val > 0) { thecount = 1; therank = -1; }
if (val < -1) {
therank = -val;
thecount = therefs->Value(therank);
if (thecount <= 0) preres = Standard_False;
}
if (preres) return;
}
// Usage courant. La suite en usage courant ou si pas de pre-reservation
else if (number > 0) {
if (thenum == number || number > thenbe) return;
thenum = number;
}
else return;
Standard_Integer val = theents->Value(thenum);
if (val == 0) { thecount = 0; therank = 0; }
else if (val > 0) { thecount = 1; therank = -1; }
else if (val < -1) {
therank = - val; thecount = 0;
if (therefs->Value(therank+1) == 0) thecount = - therefs->Value(therank);
else {
for (Standard_Integer j = 1; ; j ++) {
val = therefs->Value (therank+j);
if (val >= 0) break;
thecount ++;
}
if (val > 0) thecount ++;
}
}
else { thecount = 0; therank = -1; } // val == -1 reste
}
Standard_Integer Interface_IntList::Number () const
{
return thenum;
}
Interface_IntList Interface_IntList::List (const Standard_Integer number,
const Standard_Boolean copied) const
{
Interface_IntList alist (*this,copied);
alist.SetNumber (number);
return alist;
}
void Interface_IntList::SetRedefined (const Standard_Boolean mode)
{
if (!NbEntities() || thenum == 0) return;
Standard_Integer val = theents->Value(thenum);
if (val < -1) return;
else if (mode) {
if (val == 0) theents->SetValue (thenum,-1);
else if (val > 0) {
Reservate (2);
theents->SetValue (thenum, -thenbr);
therefs->SetValue (thenbr+1, val);
thenbr ++;
}
} else if (!mode) {
if (val == -1) theents->SetValue (thenum,0);
else if (therefs->Value (therank+1) >= 0) {
theents->SetValue (thenum, therefs->Value(therank+1));
if (thenbr == therank+1) thenbr --;
}
}
}
void Interface_IntList::Reservate (const Standard_Integer count)
{
// Reservate (-count) = Reservate (count) + allocation sur entite courante + 1
if (count < 0) {
Reservate(-count-1);
if (thenum == 0) return;
thenbr ++;
therefs->SetValue (thenbr,0); // contiendra le nombre ...
therank = thenbr;
theents->SetValue(thenum, -thenbr);
thenbr -= count;
return;
}
Standard_Integer up, oldup = 0;
if (thenbr == 0) { // c-a-d pas encore allouee ...
up = thenbe/2+1; if (up < 2) up = 2;
if (up < count) up = count*3/2;
therefs = new TColStd_HArray1OfInteger (0,up); therefs->Init(0);
thenbr = 2; // on commence apres (commodite d adressage)
}
oldup = therefs->Upper();
if (thenbr + count < oldup) return; // OK
up = oldup*3/2+count; if (up < 2) up = 2;
Handle(TColStd_HArray1OfInteger) refs = new TColStd_HArray1OfInteger (0,up); refs->Init(0);
for (Standard_Integer i = 1; i <= oldup; i ++) refs->SetValue (i,therefs->Value(i));
therefs = refs;
}
void Interface_IntList::Add (const Standard_Integer ref)
{
if (thenum == 0) return;
// ref < 0 : pre-reservation
if (ref < 0) {
Add(-ref);
if (therank <= 0) return;
if (therefs->Value(therank) >= 0) therefs->SetValue (therank, thecount);
return;
}
if (therank == 0)
{ theents->SetValue (thenum,ref); thecount = 1; therank = -1; }
else if (therank < 0) {
Reservate (2);
therank = thenbr;
Standard_Integer val = theents->Value(thenum);
theents->SetValue (thenum, -thenbr);
if (thecount == 1)
{ therefs->SetValue (thenbr+1, -val); thenbr ++; }
therefs->SetValue (thenbr+1, ref); thenbr ++;
thecount ++;
} else if (thenbr == therank+thecount) { // place libre en fin
therefs->SetValue (thenbr, -therefs->Value(thenbr));
therefs->SetValue (thenbr+1, ref); thenbr ++;
thecount ++;
} else if (therefs->Value(therank+thecount+1) == 0) { // place libre apres
therefs->SetValue (therank+thecount, -therefs->Value(therank+thecount));
therefs->SetValue (therank+thecount+1, ref);
thecount ++;
} else { // recopier plus loin !
Reservate (thecount+2);
Standard_Integer rank = therank;
therank = thenbr;
theents->SetValue (thenum,-therank);
for (Standard_Integer i = 1; i < thecount; i ++) {
therefs->SetValue (therank+i, therefs->Value(rank+i));
therefs->SetValue (rank+i,0);
}
therefs->SetValue (therank+thecount, -therefs->Value(rank+thecount));
therefs->SetValue (rank+thecount,0);
therefs->SetValue (therank+thecount+1,ref);
thecount ++; thenbr = therank + thecount + 1;
}
}
Standard_Integer Interface_IntList::Length () const
{
return thecount;
}
Standard_Boolean Interface_IntList::IsRedefined (const Standard_Integer num) const
{
Standard_Integer n = (num == 0 ? thenum : num);
if (!NbEntities() || n == 0) return Standard_False;
if (theents->Value(n) < 0) return Standard_True;
return Standard_False;
}
Standard_Integer Interface_IntList::Value (const Standard_Integer num) const
{
if (thenum == 0) return 0;
if (num <= 0 || num > thecount) return 0;
if (thecount == 0) return 0;
if (therank <= 0) return theents->Value(thenum);
Standard_Integer val = therefs->Value (therank+num);
if (val < 0) return -val;
return val;
}
Standard_Boolean Interface_IntList::Remove (const Standard_Integer num)
{
return Standard_False; // not yet implemented
}
void Interface_IntList::Clear ()
{
if (thenbr == 0) return; // deja clear
Standard_Integer i,low,up;
low = theents->Lower(); up = theents->Upper();
for (i = low; i <= up; i ++) theents->SetValue (i,0);
thenbr = 0;
if (therefs.IsNull()) return;
low = therefs->Lower(); up = therefs->Upper();
for (i = low; i <= up; i ++) therefs->SetValue (i,0);
}
void Interface_IntList::AdjustSize (const Standard_Integer margin)
{
Standard_Integer i, up = theents->Upper();
if (up > thenbe) {
Handle(TColStd_HArray1OfInteger) ents = new TColStd_HArray1OfInteger (0,thenbe); ents->Init(0);
for (i = 1; i <= thenbe; i ++) ents->SetValue (i,theents->Value(i));
theents = ents;
}
if (thenbr == 0) Reservate (margin);
else {
up = therefs->Upper();
if (up >= thenbr && up <= thenbr + margin) return;
Handle(TColStd_HArray1OfInteger) refs = new TColStd_HArray1OfInteger (0,thenbr+margin); refs->Init(0);
for (i = 1; i <= thenbr; i ++) refs->SetValue (i,therefs->Value(i));
therefs = refs;
}
}

View File

@@ -0,0 +1,27 @@
-- File: Interface_IntVal.cdl
-- Created: Wed Sep 3 15:25:38 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class IntVal from Interface inherits TShared from MMgt
---Purpose : An Integer through a Handle (i.e. managed as TShared)
uses Integer
is
Create returns mutable IntVal;
Value (me) returns Integer;
CValue (me : mutable) returns Integer;
---C++ : return &
fields
theval : Integer;
end IntVal;

View File

@@ -0,0 +1,7 @@
#include <Interface_IntVal.ixx>
Interface_IntVal::Interface_IntVal () { theval = 0; }
Standard_Integer Interface_IntVal::Value () const { return theval; }
Standard_Integer& Interface_IntVal::CValue () { return theval; }

View File

@@ -0,0 +1,440 @@
-- File: InterfaceModel.cdl
-- Created: Mon Feb 3 11:27:05 1992 -- --
-- Author:Christian CAILLET <cky@phobox>
-- Modified : David Carbonel Mon 4 january 1999
-- Add of DENumber function. no. and of PrintToLog
--
--
---Copyright: Matra Datavision 1992
deferred class InterfaceModel from Interface inherits TShared
---Purpose : Defines an (Indexed) Set of data corresponding to a complete
-- Transfer by a File Interface, i.e. File Header and Transient
-- Entities (Objects) contained in a File. Contained Entities are
-- identified in the Model by unique and consecutive Numbers.
--
-- In addition, a Model can attach to each entity, a specific
-- Label according to the norm (e.g. Name for VDA, #ident for
-- Step ...), intended to be output on a string or a stream
-- (remark : labels are not obliged to be unique)
--
-- InterfaceModel itself is not Transient, it is intended to
-- work on a set of Transient Data. The services offered are
-- basic Listing and Identification operations on Transient
-- Entities, storage of Error Reports, Copying.
--
-- Moreovere, it is possible to define and use templates. These
-- are empty Models, from which copies can be obtained in order
-- to be filled with effective data. This allows to record
-- standard definitions for headers, avoiding to recreate them
-- for each sendings, and assuring customisation of produced
-- files for a given site.
-- A template is attached to a name. It is possible to define a
-- template from another one (get it, edit it then record it
-- under another name).
--
-- See also Graph, ShareTool, CheckTool for more
uses Transient, IndexedMapOfTransient,
DataMapOfIntegerTransient from TColStd,
HAsciiString from TCollection,
HSequenceOfHAsciiString from TColStd,
Messenger from Message,
ReportEntity, Check, CheckIterator,
EntityIterator, GeneralLib, Protocol, GTool,
DataState
raises OutOfRange, NoSuchObject, InterfaceMismatch
is
Initialize;
---Purpose : Defines empty InterfaceModel, ready to be filled
Destroy (me : mutable);
---Purpose : Clears the list of entities (service WhenDelete)
---C++ : alias ~
SetProtocol (me : mutable; proto : Protocol from Interface);
---Purpose : Sets a Protocol for this Model
-- It is also set by a call to AddWithRefs with Protocol
-- It is used for : DumpHeader (as required), ClearEntities ...
Protocol (me) returns Protocol from Interface is virtual;
---Purpose : Returns the Protocol which has been set by SetProtocol, or
-- AddWithRefs with Protocol
SetGTool (me : mutable; gtool : GTool from Interface);
---Purpose : Sets a GTool for this model, which already defines a Protocol
GTool (me) returns GTool;
---Purpose : Returns the GTool, set by SetProtocol or by SetGTool
DispatchStatus (me : mutable) returns Boolean;
---Purpose : Returns the Dispatch Status, either for get or set
-- A Model which is produced from Dispatch may share entities
-- with the original (according to the Protocol), hence these
-- non-copied entities should not be deleted
---C++ : return &
Clear (me : mutable) is virtual;
---Purpose : Erases contained data; used when a Model is copied to others :
-- the new copied ones begin from clear
-- Clear calls specific method ClearHeader (see below)
ClearEntities (me : mutable) is virtual;
---Purpose : Clears the entities; uses the general service WhenDelete, in
-- addition to the standard Memory Manager; can be redefined
ClearLabels (me : mutable) is deferred;
---Purpose : Erases informations about labels, if any : specific to each
-- norm
ClearHeader (me : mutable) is deferred;
---Purpose : Clears Model's header : specific to each norm
-- -- Unitary Accesses to Entities -- --
NbEntities (me) returns Integer;
---Purpose : Returns count of contained Entities
Contains (me; anentity : Transient) returns Boolean;
---Purpose : Returns True if a Model contains an Entity (for a ReportEntity,
-- looks for the ReportEntity itself AND its Concerned Entity)
Number (me; anentity : Transient) returns Integer;
---Purpose : Returns the Number of an Entity in the Model if it contains it.
-- Else returns 0. For a ReportEntity, looks at Concerned Entity.
-- DENumber (me; anentity : Transient) returns Integer;
---Purpose : Returns the Directory entry Number of an Entity in
-- the Model if it contains it. Else returns 0. For a
-- ReportEntity, looks at Concerned Entity.
Value (me; num : Integer) returns mutable Transient raises OutOfRange;
---Purpose : Returns an Entity identified by its number in the Model
-- Each sub-class of InterfaceModel can define its own method
-- Entity to return its specific class of Entity (e.g. for VDA,
-- VDAModel returns a VDAEntity), working by calling Value
-- Remark : For a Reported Entity, (Erroneous, Corrected, Unknown), this
-- method returns this Reported Entity.
-- See ReportEntity for other questions.
---C++ : return const &
NbTypes (me; ent : Transient) returns Integer;
---Purpose : Returns the count of DISTINCT types under which an entity may
-- be processed. Defined by the Protocol, which gives default as
-- 1 (dynamic Type).
Type (me; ent : Transient; num : Integer = 1) returns Type;
---Purpose : Returns a type, given its rank : defined by the Protocol
-- (by default, the first one)
TypeName (me; ent : Transient; complete : Boolean = Standard_True)
returns CString;
---Purpose : Returns the type name of an entity, from the list of types
-- (one or more ...)
-- <complete> True (D) gives the complete type, else packages are
-- removed
-- WARNING : buffered, to be immediately copied or printed
ClassName (myclass; typnam : CString) returns CString;
---Purpose : From a CDL Type Name, returns the Class part (package dropped)
-- WARNING : buffered, to be immediately copied or printed
-- -- Report Entities (for syntactic concerns) -- --
EntityState (me; num : Integer) returns DataState raises OutOfRange;
---Purpose : Returns the State of an entity, given its number
IsReportEntity (me; num : Integer; semantic : Boolean = Standard_False)
returns Boolean raises OutOfRange;
---Purpose : Returns True if <num> identifies a ReportEntity in the Model
-- Hence, ReportEntity can be called.
--
-- By default, queries main report, if <semantic> is True, it
-- queries report for semantic check
--
-- Remember that a Report Entity can be defined for an Unknown
-- Entity, or a Corrected or Erroneous (at read time) Entity.
-- The ReportEntity is defined before call to method AddEntity.
ReportEntity (me; num : Integer; semantic : Boolean = Standard_False)
returns mutable ReportEntity
---Purpose : Returns a ReportEntity identified by its number in the Model,
-- or a Null Handle If <num> does not identify a ReportEntity.
--
-- By default, queries main report, if <semantic> is True, it
-- queries report for semantic check
raises OutOfRange;
-- Error if <num> is out of range
IsErrorEntity (me; num : Integer) returns Boolean raises OutOfRange;
---Purpose : Returns True if <num> identifies an Error Entity : in this
-- case, a ReportEntity brings Fail Messages and possibly an
-- "undefined" Content, see IsRedefinedEntity
IsRedefinedContent (me; num : Integer) returns Boolean raises OutOfRange;
---Purpose : Returns True if <num> identifies an Entity which content is
-- redefined through a ReportEntity (i.e. with literal data only)
-- This happens when an entity is syntactically erroneous in the
-- way that its basic content remains empty.
-- For more details (such as content itself), see ReportEntity
ClearReportEntity (me : mutable; num : Integer) returns Boolean
---Purpose : Removes the ReportEntity attached to Entity <num>. Returns
-- True if done, False if no ReportEntity was attached to <num>.
-- Warning : the caller must assume that this clearing is meaningfull
raises OutOfRange;
-- Error if <num> is out of range
SetReportEntity (me : mutable; num : Integer; rep : mutable ReportEntity)
returns Boolean
---Purpose : Sets or Replaces a ReportEntity for the Entity <num>. Returns
-- True if Report is replaced, False if it has been replaced
-- Warning : the caller must assume that this setting is meaningfull
raises OutOfRange, InterfaceMismatch;
-- Error if <num> is out of range, or if concerned Entity is
-- not equal to Value(num)
AddReportEntity (me : mutable; rep : mutable ReportEntity;
semantic : Boolean = Standard_False) returns Boolean;
---Purpose : Adds a ReportEntity as such. Returns False if the concerned
-- entity is not recorded in the Model
-- Else, adds it into, either the main report list or the
-- list for semantic checks, then returns True
IsUnknownEntity (me; num : Integer) returns Boolean raises OutOfRange;
---Purpose : Returns True if <num> identifies an Unknown Entity : in this
-- case, a ReportEntity with no Check Messages designates it.
-- -- Checks (semantic & syntactic) -- --
FillSemanticChecks (me : mutable; checks : CheckIterator;
clear : Boolean = Standard_True);
---Purpose : Fills the list of semantic checks.
-- This list is computed (by CheckTool). Hence, it can be stored
-- in the model for later queries
-- <clear> True (D) : new list replaces
-- <clear> False : new list is cumulated
HasSemanticChecks (me) returns Boolean;
---Purpose : Returns True if semantic checks have been filled
Check (me; num : Integer; syntactic : Boolean) returns Check;
---Purpose : Returns the check attached to an entity, designated by its
-- Number. 0 for global check
-- <semantic> True : recorded semantic check
-- <semantic> False : recorded syntactic check (see ReportEntity)
-- If no check is recorded for <num>, returns an empty Check
---C++ : return const &
-- -- Editions -- --
Reservate (me : mutable; nbent : Integer) is virtual;
---Purpose : Does a reservation for the List of Entities (for optimized
-- storage management). If it is not called, storage management
-- can be less efficient. <nbent> is the expected count of
-- Entities to store
AddEntity (me : mutable; anentity : mutable Transient)
---Purpose : Internal method for adding an Entity. Used by file reading
-- (defined by each Interface) and Transfer tools. It adds the
-- entity required to be added, not its refs : see AddWithRefs.
-- If <anentity> is a ReportEntity, it is added to the list of
-- Reports, its Concerned Entity (Erroneous or Corrected, else
-- Unknown) is added to the list of Entities.
-- That is, the ReportEntity must be created before Adding
raises InterfaceMismatch is virtual;
-- Error if anentity already recorded
AddWithRefs (me : mutable; anent : mutable Transient; proto : Protocol;
level : Integer = 0; listall : Boolean = Standard_False);
---Purpose : Adds to the Model, an Entity with all its References, as they
-- are defined by General Services FillShared and ListImplied.
-- Process is recursive (any sub-levels) if <level> = 0 (Default)
-- Else, adds sub-entities until the required sub-level.
-- Especially, if <level> = 1, adds immediate subs and that's all
--
-- If <listall> is False (Default), an entity (<anentity> itself
-- or one of its subs at any level) which is already recorded in
-- the Model is not analysed, only the newly added ones are.
-- If <listall> is True, all items are analysed (this allows to
-- ensure the consistency of an adding made by steps)
AddWithRefs (me : mutable; anent : mutable Transient;
level : Integer = 0; listall : Boolean = Standard_False)
---Purpose : Same as above, but works with the Protocol of the Model
raises InterfaceMismatch;
-- Error if no Protocol is defined in the Model
AddWithRefs (me : mutable; anent : mutable Transient; lib : GeneralLib;
level : Integer = 0; listall : Boolean = Standard_False);
---Purpose : Same as above, but works with an already created GeneralLib
ReplaceEntity (me : mutable; nument : Integer; anent : mutable Transient);
---Purpose : Replace Entity with Number=nument on other entity - "anent"
ReverseOrders (me : mutable; after : Integer = 0);
---Purpose : Reverses the Numbers of the Entities, between <after> and the
-- total count of Entities. Thus, the entities :
-- 1,2 ... after, after+1 ... nb-1, nb become numbered as :
-- 1,2 ... after, nb, nb-1 ... after+1
-- By default (after = 0) the whole list of Entities is reversed
ChangeOrder (me : mutable; oldnum, newnum : Integer; count : Integer = 1)
---Purpose : Changes the Numbers of some Entities : <oldnum> is moved to
-- <newnum>, same for <count> entities. Thus :
-- 1,2 ... newnum-1 newnum ... oldnum .. oldnum+count oldnum+count+1 .. gives
-- 1,2 ... newnum-1 oldnum .. oldnum+count newnum ... oldnum+count+1
-- (can be seen as a circular permutation)
raises OutOfRange;
-- Error if one of <oldnum,newnum, and + count> is out of range,
-- or if <count> is greater than Abs(newnum-oldnum)
GetFromTransfer (me : mutable; aniter : EntityIterator)
---Purpose : Gets contents from an EntityIterator, prepared by a
-- Transfer tool (e.g TransferCopy). Starts from clear
raises InterfaceMismatch;
-- Error if InterfaceEntities to get are not free
GetFromAnother (me : mutable; other : InterfaceModel) is deferred;
---Purpose : Gets header (data specific of a defined Interface) from
-- another InterfaceModel; called from TransferCopy
NewEmptyModel (me) returns mutable InterfaceModel is deferred;
---Purpose : Returns a New Empty Model, same type as <me> (whatever its
-- Type); called to Copy parts a Model into other ones, then
-- followed by a call to GetFromAnother (Header) then filling
-- with specified Entities, themselves copied
-- -- Categories -- --
SetCategoryNumber (me : mutable; num : Integer; val : Integer)
returns Boolean;
---Purpose : Records a category number for an entity number
-- Returns True when done, False if <num> is out of range
CategoryNumber (me; num : Integer) returns Integer;
---Purpose : Returns the recorded category number for a given entity number
-- 0 if none was defined for this entity
-- -- Global Queries -- --
FillIterator (me; iter : in out EntityIterator);
---Purpose : Allows an EntityIterator to get a list of Entities
Entities (me) returns EntityIterator;
---Purpose : Returns the list of all Entities, as an Iterator on Entities
-- (the Entities themselves, not the Reports)
Reports (me; semantic : Boolean = Standard_False) returns EntityIterator;
---Purpose : Returns the list of all ReportEntities, i.e. data about
-- Entities read with Error or Warning informations
-- (each item has to be casted to Report Entity then it can be
-- queried for Concerned Entity, Content, Check ...)
-- By default, returns the main reports, is <semantic> is True it
-- returns the list for sematic checks
---See Also : classes ReportEntity (for contents) and CheckTool
Redefineds (me) returns EntityIterator;
---Purpose : Returns the list of ReportEntities which redefine data
-- (generally, if concerned entity is "Error", a literal content
-- is added to it : this is a "redefined entity"
GlobalCheck (me; syntactic : Boolean = Standard_True) returns Check;
---Purpose : Returns the GlobalCheck, which memorizes messages global to
-- the file (not specific to an Entity), especially Header
---C++ : return const &
SetGlobalCheck (me : mutable; ach : Check);
---Purpose : Allows to modify GlobalCheck, after getting then completing it
-- Remark : it is SYNTACTIC check. Semantics, see FillChecks
VerifyCheck (me; ach : in out Check) is virtual;
---Purpose : Minimum Semantic Global Check on data in model (header)
-- Can only check basic Data. See also GlobalCheck from Protocol
-- for a check which takes the Graph into account
-- Default does nothing, can be redefined
DumpHeader (me; S : Messenger from Message; level : Integer = 0) is deferred;
---Purpose : Dumps Header in a short, easy to read, form, onto a Stream
-- <level> allows to print more or less parts of the header,
-- if necessary. 0 for basic print
Print (me; ent : Transient; s : Messenger from Message; mode : Integer = 0);
---Purpose : Prints identification of a given entity in <me>, in order to
-- be printed in a list or phrase
-- <mode> < 0 : prints only its number
-- <mode> = 1 : just calls PrintLabel
-- <mode> = 0 (D) : prints its number plus '/' plus PrintLabel
-- If <ent> == <me>, simply prints "Global"
-- If <ent> is unknown, prints "??/its type"
PrintLabel (me; ent : Transient; S : Messenger from Message) is deferred;
---Purpose : Prints label specific to each norm, for a given entity.
-- Must only print label itself, in order to be included in a
-- phrase. Can call the result of StringLabel, but not obliged.
PrintToLog (me; ent : Transient; S : Messenger from Message) is virtual;
---Purpose : Prints label specific to each norm in log format, for
-- a given entity.
-- By default, just calls PrintLabel, can be redefined
StringLabel (me; ent : Transient) returns HAsciiString from TCollection
is deferred;
---Purpose : Returns a string with the label attached to a given entity.
-- Warning : While this string may be edited on the spot, if it is a read
-- field, the returned value must be copied before.
NextNumberForLabel (me; label : CString;
lastnum : Integer = 0; exact : Boolean = Standard_True)
returns Integer is virtual;
---Purpose : Searches a label which matches with one entity.
-- Begins from <lastnum>+1 (default:1) and scans the entities
-- until <NbEntities>. For the first which matches <label>,
-- this method returns its Number. Returns 0 if nothing found
-- Can be called recursively (labels are not specified as unique)
-- <exact> : if True (default), exact match is required
-- else, checks the END of entity label
--
-- This method is virtual, hence it can be redefined for a more
-- efficient search (if exact is true).
-- -- Templates -- --
HasTemplate (myclass; name : CString) returns Boolean;
---Purpose : Returns true if a template is attached to a given name
Template (myclass; name : CString) returns mutable InterfaceModel;
---Purpose : Returns the template model attached to a name, or a Null Handle
SetTemplate (myclass; name : CString; model : mutable InterfaceModel)
returns Boolean;
---Purpose : Records a new template model with a name. If the name was
-- already recorded, the corresponding template is replaced by
-- the new one. Then, WARNING : test HasTemplate to avoid
-- surprises
ListTemplates (myclass) returns HSequenceOfHAsciiString;
---Purpose : Returns the complete list of names attached to template models
fields
theentities : IndexedMapOfTransient;
thereports : DataMapOfIntegerTransient from TColStd; -- EntityNumber -> ReportEntity
therepch : DataMapOfIntegerTransient from TColStd; -- for semantic checks
thecheckstx : Check; -- it is GlobalCheck (Syntactic)
thechecksem : Check; -- it is GlobalCheck (Semantic)
haschecksem : Boolean; -- are semantic checks recorded
isdispatch : Boolean; -- is <me> produced for dispatch ?
thecategory : HAsciiString;
thegtool : GTool;
-- theprotocol : Protocol;
end InterfaceModel;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
-- File: Interface_JaggedArray.cdl
-- Created: Tue May 30 13:43:39 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
generic class JaggedArray from Interface
(TheKey as TShared)
inherits TShared
---Purpose : This class allows to define an HArray1 Of HArray1 ...
-- which is not possible with the actual system of
-- genericity supported by CasCade
uses Array1OfTransient
is
Create (low, up : Integer) returns mutable JaggedArray;
Lower (me) returns Integer;
Upper (me) returns Integer;
Length (me) returns Integer;
SetValue (me : mutable; num : Integer; val : any TheKey);
Value (me; num : Integer) returns any TheKey;
-- C++ : return const & (NO , DownCast required)
-- ChangeValue (me : mutable; num : Integer) returns any TheKey;
-- C++ : return & (NO , DownCast required !)
fields
thelist : Array1OfTransient;
end JaggedArray;

View File

@@ -0,0 +1,26 @@
//#include <Interface_JaggedArray.ixx>
Interface_JaggedArray::Interface_JaggedArray
(const Standard_Integer low, const Standard_Integer up)
: thelist (low,up) { Handle(Standard_Transient) nulo; thelist.Init(nulo); }
Standard_Integer Interface_JaggedArray::Lower () const
{ return thelist.Lower(); }
Standard_Integer Interface_JaggedArray::Upper () const
{ return thelist.Upper(); }
Standard_Integer Interface_JaggedArray::Length () const
{ return thelist.Length(); }
void Interface_JaggedArray::SetValue
(const Standard_Integer num, const Handle(TheKey)& val)
{ thelist.SetValue(num,val); }
Handle(TheKey) Interface_JaggedArray::Value
(const Standard_Integer num) const
{ return Handle(TheKey)::DownCast(thelist.Value(num)); }
// Handle(TheKey)& Interface_JaggedArray::ChangeValue
// (const Standard_Integer num)
// { return thelist.ChangeValue(num); }

View File

@@ -0,0 +1,117 @@
-- File: Interface_LineBuffer.cdl
-- Created: Thu Apr 15 10:08:17 1993
-- Author: Christian CAILLET
-- <cky@bravox>
---Copyright: Matra Datavision 1993
class LineBuffer from Interface
---Purpose : Simple Management of a Line Buffer, to be used by Interface
-- File Writers.
-- While a String is suitable to do that, this class ensures an
-- optimised Memory Management, because this is a hard point of
-- File Writing.
uses Integer, Boolean, Character, CString,
AsciiString from TCollection, HAsciiString from TCollection
raises OutOfRange
is
Create (size : Integer = 10) returns LineBuffer;
---Purpose : Creates a LineBuffer with an absolute maximum size
-- (Default value is only to satisfy compiler requirement)
SetMax (me : in out; max : Integer)
---Purpose : Changes Maximum allowed size of Buffer.
-- If <max> is Zero, Maximum size is set to the initial size.
raises OutOfRange is static;
-- Error if <max> is greater than <size> given at Creation time.
SetInitial (me : in out; initial : Integer)
---Purpose : Sets an Initial reservation for Blank characters
-- (this reservation is counted in the size of the current Line)
raises OutOfRange is static;
-- Error if <initial> is greater than current Maximum size
SetKeep (me : in out) is static;
---Purpose : Sets a Keep Status at current Length. It means that at next
-- Move, the new line will begin by characters between Keep + 1
-- and current Length
CanGet (me : in out; more : Integer) returns Boolean is static;
---Purpose : Returns True if there is room enough to add <more> characters
-- Else, it is required to Dump the Buffer before refilling it
-- <more> is recorded to manage SetKeep status
Content (me) returns CString is static;
---Purpose : Returns the Content of the LineBuffer
-- was C++ : return const
Length (me) returns Integer is static;
---Purpose : Returns the Length of the LineBuffer
Clear (me : in out) is static;
---Purpose : Clears completely the LineBuffer
FreezeInitial (me : in out) is static;
---Purpose : Inhibits effect of SetInitial until the next Move (i.e. Keep)
-- Then Prepare will not insert initial blanks, but further ones
-- will. This allows to cancel initial blanks on an internal Split
-- A call to SetInitial has no effect on this until Move
Prepare (me : in out) is static private;
---Purpose : Prepares Move : Inserts Initial Blanks if required, and
-- determines if SetKeep can be supported (it cannot be if Length
-- + Next String to get (see CanGet) overpass Max Size)
Keep (me : in out) is static private;
---Purpose : Keeps characters from SetKeep. If SetKeep is Zero, equivalent
-- to Clear
Move (me : in out; str : in out AsciiString from TCollection) is static;
---Purpose : Fills a AsciiString <str> with the Content of the Line Buffer,
-- then Clears the LineBuffer
Move (me : in out; str : mutable HAsciiString from TCollection) is static;
---Purpose : Same as above, but <str> is known through a Handle
Moved (me : in out) returns mutable HAsciiString from TCollection;
---Purpose : Same as above, but generates the HAsciiString
Add (me : in out; text : CString)
---Purpose : Adds a text as a CString. Its Length is evaluated from the
-- text (by C function strlen)
raises OutOfRange is static;
-- Error if there remains no room enough
Add (me : in out; text : CString; lntext : Integer)
---Purpose : Adds a text as a CString. Its length is given as <lntext>
raises OutOfRange is static;
-- Error if there remains no room enough
Add (me : in out; text : AsciiString from TCollection)
---Purpose : Adds a text as a AsciiString from TCollection
raises OutOfRange is static;
-- Error if there remains no room enough
Add (me : in out; text : Character)
---Purpose : Adds a text made of only ONE Character
raises OutOfRange is static;
-- Error if there remains no room enough
fields
theline : AsciiString from TCollection;
themax : Integer;
theinit : Integer;
thekeep : Integer;
theget : Integer;
thelen : Integer;
thefriz : Integer;
thekept : Character;
end LineBuffer;

View File

@@ -0,0 +1,149 @@
#include <Interface_LineBuffer.ixx>
#include <Standard_OutOfRange.hxx>
// LineBuffer, c est une String avec une Longueur reservee fixe au depart
// et une longueur effective <thelen>. theline(thelen+1) vaut '\0'
Interface_LineBuffer::Interface_LineBuffer (const Standard_Integer size)
: theline (size+1,' ')
{
theline.SetValue(1,'\0');
themax = size; theinit = thelen = theget = thekeep = thefriz = 0;
}
void Interface_LineBuffer::SetMax (const Standard_Integer max)
{
if (max > theline.Length()) Standard_OutOfRange::Raise
("Interface LineBuffer : SetMax");
if (max <= 0) themax = theline.Length();
else themax = max;
}
void Interface_LineBuffer::SetInitial (const Standard_Integer initial)
{
if (thefriz > 0) return;
if (initial >= themax) Standard_OutOfRange::Raise
("Interface LineBuffer : SetInitial");
if (initial <= 0) theinit = 0;
else theinit = initial;
}
void Interface_LineBuffer::SetKeep ()
{ thekeep = -thelen; }
Standard_Boolean Interface_LineBuffer::CanGet (const Standard_Integer more)
{
theget = more;
if ((thelen + theinit + more) <= themax) return Standard_True;
if (thekeep < 0) thekeep = -thekeep;
return Standard_False;
}
Standard_CString Interface_LineBuffer::Content () const
{ return theline.ToCString(); }
Standard_Integer Interface_LineBuffer::Length () const
{ return thelen + theinit; } // +theinit : longueur vraie avec blancs
void Interface_LineBuffer::FreezeInitial ()
{ thefriz = theinit+1; theinit = 0; }
void Interface_LineBuffer::Clear ()
{
theget = thekeep = thelen = thefriz = 0;
theline.SetValue(1,'\0');
}
// .... RESULTATS ....
void Interface_LineBuffer::Prepare ()
{
// ATTENTION aux blanx initiaux
if (theinit > 0) {
Standard_Integer i; // svv Jan11 2000 : porting on DEC
// pdn Protection
if( (thelen +theinit) > themax)
return;
for (i = thelen + 1; i > 0; i --) {
theline.SetValue(i + theinit, theline.Value(i));
}
for (i = 1; i <= theinit; i ++) theline.SetValue(i,' ');
}
// GERER KEEP : est-il jouable ? sinon, annuler. sioui, noter la jointure
if (thekeep > 0) thekeep += (theinit+1); // theinit, et +1 car Keep INCLUS
if (thekeep > 0)
{ if ((thelen + theget + theinit - thekeep) >= themax) thekeep = 0; }
if (thekeep > 0)
{ thekept = theline.Value(thekeep); theline.SetValue(thekeep,'\0'); }
}
void Interface_LineBuffer::Keep ()
{
// Si Keep, sauver de thekeep + 1 a thelen (+1 pour 0 final)
if (thekeep > 0) {
theline.SetValue(1,thekept);
for (Standard_Integer i = thekeep+1; i <= thelen+theinit+1; i ++) {
theline.SetValue(i-thekeep+1, theline.Value(i));
}
thelen = thelen+theinit-thekeep+1;
}
else Clear();
theget = thekeep = 0;
if (thefriz > 0) { theinit = thefriz - 1; thefriz = 0; }
}
void Interface_LineBuffer::Move (TCollection_AsciiString& str)
{
Prepare();
str.AssignCat(theline.ToCString());
Keep();
}
void Interface_LineBuffer::Move (const Handle(TCollection_HAsciiString)& str)
{
Prepare();
str->AssignCat(theline.ToCString());
Keep();
}
Handle(TCollection_HAsciiString) Interface_LineBuffer::Moved ()
{
Prepare();
Handle(TCollection_HAsciiString) R =
new TCollection_HAsciiString(theline.ToCString());
Keep();
return R;
}
// .... AJOUTS ....
void Interface_LineBuffer::Add (const Standard_CString text)
{ Add (text,strlen(text)); }
void Interface_LineBuffer::Add
(const Standard_CString text, const Standard_Integer lntext)
{
Standard_Integer lnt =
(lntext > (themax-thelen-theinit) ? (themax-thelen-theinit) : lntext);
for (Standard_Integer i = 1; i <= lnt; i ++)
theline.SetValue (thelen+i, text[i-1]);
thelen += lnt;
theline.SetValue (thelen+1, '\0');
}
void Interface_LineBuffer::Add (const TCollection_AsciiString& text)
{ Add ( text.ToCString() , text.Length() ); }
void Interface_LineBuffer::Add (const Standard_Character text)
{
theline.SetValue (thelen+1,text);
thelen ++;
theline.SetValue (thelen+1,'\0');
}

215
src/Interface/Interface_MSG.cdl Executable file
View File

@@ -0,0 +1,215 @@
-- File: Interface_MSG.cdl
-- Created: Wed Mar 8 16:27:29 1995
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1995
class MSG from Interface
---Purpose : This class gives a set of functions to manage and use a list
-- of translated messages (messagery)
--
-- Keys are strings, their corresponding (i.e. translated) items
-- are strings, managed by a dictionary (a global one).
--
-- If the dictionary is not set, or if a key is not recorded,
-- the key is returned as item, and it is possible to :
-- - trace or not this fail, record or not it for further trace
--
-- It is also possible to suspend the translation (keys are then
-- always returned as items)
--
-- This class also provides a file format for loading :
-- It is made of couples of lines, the first one begins by '@'
-- the following is the key, the second one is the message
-- Lines which are empty or which begin by '@@' are skipped
uses Character, CString , OStream, IStream
raises DomainError
is
Create (key : CString) returns MSG;
---Purpose : A MSG is created to write a "functional code" in conjunction
-- with operator () attached to Value
-- Then, to have a translated message, write in C++ :
--
-- Interface_MSG("...mykey...") which returns a CString
-- See also some help which follow
Create (key : CString; i1 : Integer) returns MSG;
---Purpose : Translates a message which contains one integer variable
-- It is just a help which avoid the following :
-- char mess[100]; sprintf(mess,Interface_MSG("code"),ival);
-- then AddFail(mess);
-- replaced by AddFail (Interface_MSG("code",ival));
--
-- The basic message is intended to be in C-sprintf format,
-- with one %d form in it
Create (key : CString; i1,i2 : Integer) returns MSG;
---Purpose : Translates a message which contains two integer variables
-- As for one integer, it is just a writing help
--
-- The basic message is intended to be in C-sprintf format
-- with two %d forms in it
Create (key : CString; r1 : Real; intervals : Integer = -1) returns MSG;
---Purpose : Translates a message which contains one real variable
-- <intervals> if set, commands the variable to be rounded to an
-- interval (see below, method Intervals)
-- As for one integer, it is just a writing help
--
-- The basic message is intended to be in C-sprintf format
-- with one %f form (or equivalent : %e etc) in it
Create (key : CString; str : CString) returns MSG;
---Purpose : Translates a message which contains one string variable
-- As for one integer, it is just a writing help
--
-- The basic message is intended to be in C-sprintf format
-- with one %s form in it
Create (key : CString; ival : Integer; str : CString) returns MSG;
---Purpose : Translates a message which contains one integer and one
-- string variables
-- As for one integer, it is just a writing help
-- Used for instance to say "Param n0.<ival> i.e. <str> is not.."
--
-- The basic message is intended to be in C-sprintf format
-- with one %d then one %s forms in it
Destroy (me : in out);
---Purpose : Optimised destructor (applies for additional forms of Create)
---C++ : alias ~
Value (me) returns CString is static;
---Purpose : Returns the translated message, in a functional form with
-- operator ()
-- was C++ : return const
---C++ : alias "operator Standard_CString() const;"
Read (myclass; S : in out IStream) returns Integer;
---Purpose : Reads a list of messages from a stream, returns read count
-- 0 means empty file, -1 means error
Read (myclass; file : CString) returns Integer;
---Purpose : Reads a list of messages from a file defined by its name
Write (myclass; S : in out OStream; rootkey : CString = "") returns Integer;
---Purpose : Writes the list of messages recorded to be translated, to a
-- stream. Writes all the list (Default) or only keys which begin
-- by <rootkey>. Returns the count of written messages
IsKey (myclass; mess : CString) returns Boolean;
---Purpose : Returns True if a given message is surely a key
-- (according to the form adopted for keys)
-- (before activating messages, answer is false)
Translated (myclass; key : CString) returns CString
---Purpose : Returns the item recorded for a key.
-- Returns the key itself if :
-- - it is not recorded (then, the trace system is activated)
-- - MSG has been required to be hung on
raises DomainError;
-- Raises an exception if not found and if <raising> mode is True
Record (myclass; key : CString; item : CString)
---Purpose : Fills the dictionary with a couple (key-item)
-- If a key is already recorded, it is possible to :
-- - keep the last definition, and activate the trace system
raises DomainError;
-- - or raise an exception
SetTrace (myclass; toprint, torecord : Boolean);
---Purpose : Sets the trace system to work when activated, as follow :
-- - if <toprint> is True, print immediately on standard output
-- - if <torecord> is True, record it for further print
SetMode (myclass; running, raising : Boolean);
---Purpose : Sets the main modes for MSG :
-- - if <running> is True, translation works normally
-- - if <running> is False, translated item equate keys
-- - if <raising> is True, errors (from Record or Translate)
-- cause MSG to raise an exception
-- - if <raising> is False, MSG runs without exception, then
-- see also Trace Modes above
PrintTrace (myclass; S : in out OStream);
---Purpose : Prints the recorded errors (without title; can be empty, this
-- is the normally expected case)
-- some helps : printing rounded floating values
Intervalled (myclass; val : Real; order : Integer = 3;
upper : Boolean = Standard_False)
returns Real;
---Purpose : Returns an "intervalled" value from a starting real <val> :
-- i.e. a value which is rounded on an interval limit
-- Interval limits are defined to be in a coarsely "geometric"
-- progression (two successive intervals are inside a limit ratio)
--
-- <order> gives the count of desired intervals in a range <1-10>
-- <upper> False, returns the first lower interval (D)
-- <upper> True, returns the first upper interval
-- Values of Intervals according <order> :
-- 0,1 : 1 10 100 ...
-- 2 : 1 3 10 30 100 ...
-- 3(D): 1 2 5 10 20 50 100 ...
-- 4 : 1 2 3 6 10 20 30 60 100 ...
-- 6 : 1 1.5 2 3 5 7 10 15 20 ...
-- 10 : 1 1.2 1.5 2 2.5 3 4 5 6 8 10 12 15 20 25 ...
-- coding/decoding dates with strings --
TDate (myclass; text : CString; yy,mm,dd,hh,mn,ss : Integer;
format : CString = "");
---Purpose : Codes a date as a text, from its numeric value (-> seconds) :
-- YYYY-MM-DD:HH-MN-SS fixed format, completed by leading zeros
-- Another format can be provided, as follows :
-- C:%d ... C like format, preceeded by C:
-- S:... format to call system (not yet implemented)
NDate (myclass; text : CString; yy,mm,dd,hh,mn,ss : out Integer) returns Boolean;
---Purpose : Decodes a date to numeric integer values
-- Returns True if OK, False if text does not fit with required
-- format. Incomplete forms are allowed (for instance, for only
-- YYYY-MM-DD, hour is zero)
CDate (myclass; text1, text2 : CString) returns Integer;
---Purpose : Returns a value about comparison of two dates
-- 0 : equal. <0 text1 anterior. >0 text1 posterior
Blanks (myclass; val : Integer; max : Integer) returns CString;
---Purpose : Returns a blank string, of length between 0 and <max>, to fill
-- the printing of a numeric value <val>, i.e. :
-- If val < 10 , max-1 blanks
-- If val between 10 and 99, max-2 blanks ... etc...
Blanks (myclass; val : CString; max : Integer) returns CString;
---Purpose : Returns a blank string, to complete a given string <val> up to
-- <max> characters :
-- If strlen(val) is 0, max blanks
-- If strlen(val) is 5, max-5 blanks etc...
Blanks (myclass; count : Integer) returns CString;
---Purpose : Returns a blank string of <count> blanks (mini 0, maxi 76)
Print (myclass; S : in out OStream;
val : CString; max : Integer; just : Integer = -1);
---Purpose : Prints a String on an Output Stream, as follows :
-- Accompagned with blanks, to give up to <max> charis at all,
-- justified according just :
-- -1 (D) : left 0 : center 1 : right
-- Maximum 76 characters
fields
thekey : CString;
theval : PCharacter; -- only if translation is done
-- thecont : Character[30]; -- for a short local definition
end MSG;

457
src/Interface/Interface_MSG.cxx Executable file
View File

@@ -0,0 +1,457 @@
#include <Standard_Stream.hxx>
#include <Interface_MSG.ixx>
#include <TCollection_HAsciiString.hxx>
#include <Dico_DictionaryOfTransient.hxx>
#include <Dico_DictionaryOfInteger.hxx>
#include <Dico_IteratorOfDictionaryOfInteger.hxx>
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
#include <OSD_Process.hxx>
#include <Quantity_Date.hxx>
#include <Standard_DomainError.hxx>
#include <stdio.h>
static Handle(Dico_DictionaryOfTransient) thedic;
static Handle(Dico_DictionaryOfInteger) thelist;
static Handle(TColStd_HSequenceOfHAsciiString) thedup;
static Standard_Boolean theprint = Standard_True;
static Standard_Boolean therec = Standard_False;
static Standard_Boolean therun = Standard_False;
static Standard_Boolean theraise = Standard_False;
static char blank[] =
" ";
static Standard_Integer maxblank = strlen(blank);
Interface_MSG::Interface_MSG (const Standard_CString key)
: thekey (key) , theval (NULL)
{
}
Interface_MSG::Interface_MSG
(const Standard_CString key, const Standard_Integer i1)
: thekey (key) , theval (NULL)
{
char mess[300];
sprintf (mess, Interface_MSG::Translated(thekey), i1);
theval = new char (strlen (mess)+1 );
strcpy (theval,mess);
}
Interface_MSG::Interface_MSG
(const Standard_CString key, const Standard_Integer i1, const Standard_Integer i2)
: thekey (key) , theval (NULL)
{
char mess[300];
sprintf (mess, Interface_MSG::Translated(thekey), i1,i2);
theval = new char (strlen (mess)+1 );
strcpy (theval,mess);
}
Interface_MSG::Interface_MSG
(const Standard_CString key, const Standard_Real r1, const Standard_Integer intervals)
: thekey (key) , theval (NULL)
{
char mess[300];
sprintf (mess, Interface_MSG::Translated(thekey),
(intervals < 0 ? r1 : Interface_MSG::Intervalled(r1,intervals)) );
theval = new char (strlen (mess)+1 );
strcpy (theval,mess);
}
Interface_MSG::Interface_MSG
(const Standard_CString key, const Standard_CString str)
: thekey (key) , theval (NULL)
{
char mess[300];
sprintf (mess, Interface_MSG::Translated(thekey), str);
theval = new char (strlen (mess)+1 );
strcpy (theval,mess);
}
Interface_MSG::Interface_MSG
(const Standard_CString key,
const Standard_Integer val, const Standard_CString str)
: thekey (key) , theval (NULL)
{
char mess[300];
sprintf (mess, Interface_MSG::Translated(thekey), val, str);
theval = new char (strlen (mess)+1 );
strcpy (theval,mess);
}
Standard_CString Interface_MSG::Value () const
{ return (theval ? theval : Interface_MSG::Translated(thekey));
}
void Interface_MSG::Destroy ()
{
if (theval) {
delete [] theval;
theval = NULL;
}
}
Interface_MSG::operator Standard_CString () const
{
return Value();
}
// ########### Lecture Ecriture Fichier ##########
Standard_Integer Interface_MSG::Read (Standard_IStream& S)
{
Standard_Integer i,nb = 0;
char buf[200], key[200];
buf[0] = '\0';
while (S.getline (buf,200)) {
if (buf[0] == '@' && buf[1] == '@') continue;
if (buf[0] == '\0') continue;
if (buf[0] == '@') {
nb ++;
for (i = 1; i <= 200; i ++) {
key[i-1] = buf[i];
if (buf[i] == '\0') break;
}
}
else Record (key,buf);
buf[0] = '\0';
}
return nb;
}
Standard_Integer Interface_MSG::Read (const Standard_CString file)
{
ifstream S(file);
if (!S) return -1;
return Read (S);
}
Standard_Integer Interface_MSG::Write
(Standard_OStream& S, const Standard_CString rootkey)
{
Standard_Integer nb = 0;
if (thedic.IsNull()) return nb;
if (rootkey[0] != '\0') S<<"@@ ROOT:"<<rootkey<<endl;
Dico_IteratorOfDictionaryOfTransient iter (thedic,rootkey);
for (iter.Start(); iter.More(); iter.Next()) {
S<<"@"<<iter.Name()<<"\n";
Handle(TCollection_HAsciiString) str =
Handle(TCollection_HAsciiString)::DownCast(iter.Value());
if (str.IsNull()) continue;
nb ++;
S<<str->ToCString()<<"\n";
}
S<<flush;
return nb;
}
// ########### EXPLOITATION ##########
Standard_Boolean Interface_MSG::IsKey (const Standard_CString key)
{
return (key[0] == '^');
}
Standard_CString Interface_MSG::Translated (const Standard_CString key)
{
if (!therun) return key;
if (!thedic.IsNull()) {
Handle(TCollection_HAsciiString) str;
if (thedic->GetItem(key,str)) return str->ToCString();
}
if (theprint) cout<<" ** Interface_MSG:Translate ?? "<<key<<" **"<<endl;
if (therec) {
Standard_Boolean deja;
if (thelist.IsNull()) thelist = new Dico_DictionaryOfInteger;
Standard_Integer& nb = thelist->NewItem (key,deja);
if (!deja) nb = 0; nb ++;
}
if (theraise) Standard_DomainError::Raise ("Interface_MSG : Translate");
return key;
}
void Interface_MSG::Record
(const Standard_CString key, const Standard_CString item)
{
if (thedic.IsNull()) thedic = new Dico_DictionaryOfTransient;
Standard_Boolean deja;
Handle(TCollection_HAsciiString) dup;
Handle(Standard_Transient)& res = thedic->NewItem (key,deja);
Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString (item);
res = str;
if (!deja) return;
if (theprint) cout<<" ** Interface_MSG:Record ?? "<<key<<" ** "<<item<<" **"<<endl;
if (therec) {
if (thedup.IsNull()) thedup = new TColStd_HSequenceOfHAsciiString();
dup = new TCollection_HAsciiString(key);
thedup->Append(dup);
dup = new TCollection_HAsciiString(item);
thedup->Append(dup);
}
if (theraise) Standard_DomainError::Raise ("Interface_MSG : Record");
}
void Interface_MSG::SetTrace
(const Standard_Boolean toprint, const Standard_Boolean torecord)
{
theprint = toprint;
therec = torecord;
}
void Interface_MSG::SetMode (const Standard_Boolean running,
const Standard_Boolean raising)
{
therun = running; theraise = raising;
}
void Interface_MSG::PrintTrace (Standard_OStream& S)
{
Handle(TCollection_HAsciiString) dup;
Standard_Integer i, nb = 0;
if (!thedup.IsNull()) nb = thedup->Length()/2;
for (i = 1; i <= nb; i ++) {
dup = thedup->Value(2*i-1);
S<<"** DUP:"<<dup->ToCString();
dup = thedup->Value(2*i);
S<<" ** "<<dup->ToCString()<<endl;
}
if (thelist.IsNull()) return;
Dico_IteratorOfDictionaryOfInteger iter (thelist);
for (iter.Start(); iter.More(); iter.Next()) {
S<<"** MSG(NB="<<iter.Value()<<"): "<<iter.Name()<<endl;
}
}
// ########### ARRONDIS DE FLOTTANTS ############
Standard_Real Interface_MSG::Intervalled
(const Standard_Real val,
const Standard_Integer order, const Standard_Boolean upper)
{
Standard_Real vl = (val > 0. ? val : -val);
Standard_Real bl = 1., bu = 1.;
if (vl >= 1.) {
bu = 10.;
for (Standard_Integer i = 0; i < 200; i ++) {
if (vl < bu) break;
bl = bu; bu *= 10.;
}
} else {
bl = 0.1;
for (Standard_Integer i = 0; i < 200; i ++) {
if (vl >= bl) break;
bu = bl; bl /= 10.;
}
if (vl == 0.) return 0.;
}
Standard_Real rst = vl/bl;
if (order <= 1) rst = (upper ? 10. : 1.);
else if (order == 2) {
if (rst <= 3.) rst = (upper ? 3. : 1.);
else rst = (upper ? 10. : 3.);
} else if (order == 3) {
if (rst <= 2.) rst = (upper ? 2. : 1.);
else if (rst <= 5.) rst = (upper ? 5. : 2.);
else rst = (upper ? 10. : 5.);
} else if (order == 4) {
if (rst <= 2.) rst = (upper ? 2. : 1.);
else if (rst <= 3.) rst = (upper ? 3. : 2.);
else if (rst <= 6.) rst = (upper ? 6. : 3.);
else rst = (upper ? 10. : 6.);
}
else if (order <= 6) {
if (rst <= 1.5) rst = (upper ? 1.5 : 1. );
else if (rst <= 2. ) rst = (upper ? 2. : 1.5);
else if (rst <= 3. ) rst = (upper ? 3. : 2. );
else if (rst <= 5. ) rst = (upper ? 5. : 3. );
else if (rst <= 7. ) rst = (upper ? 7. : 5. );
else rst = (upper ? 10. : 7. );
}
else { // n a de sens que jusqu a 10 ...
if (rst <= 1.2) rst = (upper ? 1.2 : 1. );
else if (rst <= 1.5) rst = (upper ? 1.5 : 1.2);
else if (rst <= 2. ) rst = (upper ? 2. : 1.5);
else if (rst <= 2.5) rst = (upper ? 2.5 : 2. );
else if (rst <= 3. ) rst = (upper ? 3. : 2.5);
else if (rst <= 4. ) rst = (upper ? 4. : 3. );
else if (rst <= 5. ) rst = (upper ? 5. : 4. );
else if (rst <= 6. ) rst = (upper ? 6. : 5. );
else if (rst <= 8. ) rst = (upper ? 8. : 6. );
else rst = (upper ? 10. : 8. );
}
return ((val < 0.) ? -(bl*rst) : (bl*rst) );
}
// ########### DATES ############
void Interface_MSG::TDate (const Standard_CString text,
const Standard_Integer yy,
const Standard_Integer mm,
const Standard_Integer dd,
const Standard_Integer hh,
const Standard_Integer mn,
const Standard_Integer ss,
const Standard_CString format)
{
// valeurs nulles : en tete (avec au moins une non nulle, la derniere)
// -> completees avec les valeurs actuelle (system date)
// tout nul on laisse
//svv #2 Standard_Integer y1 , m1 , d1 , h1 , n1 , s1;
Standard_Integer y2 = yy, m2 = mm, d2 = dd, h2 = hh, n2 = mn, s2 = ss;
if (yy == 0 && ss != 0) {
// completion
OSD_Process pourdate;
Quantity_Date ladate = pourdate.SystemDate ();
if ( yy == 0) {
y2 = ladate.Year();
if ( mm == 0) {
m2 = ladate.Month();
if (dd == 0) {
d2 = ladate.Day();
if (hh == 0) {
h2 = ladate.Hour();
if (mn == 0) {
n2 = ladate.Minute();
s2 = ladate.Second();
}
}
}
}
}
}
char *pText=(char *)text;
if (!format || format[0] == '\0')
sprintf(pText,"%4.4d-%2.2d-%2.2d:%2.2d-%2.2d-%2.2d",y2,m2,d2,h2,n2,s2);
else if ((format[0] == 'c' || format[0] == 'C') && format[1] == ':')
sprintf (pText,&format[2],y2,m2,d2,h2,n2,s2);
}
Standard_Boolean Interface_MSG::NDate (const Standard_CString text,
Standard_Integer& yy,
Standard_Integer& mm,
Standard_Integer& dd,
Standard_Integer& hh,
Standard_Integer& mn,
Standard_Integer& ss)
{
Standard_Integer i ,num = 1;
for (i = 0; text[i] != '\0'; i ++) {
char val = text[i];
if (val >= 48 && val <= 57) {
if ( (num & 1) == 0) num ++;
if (num == 1) yy = yy*10 + (val-48);
if (num == 3) mm = mm*10 + (val-48);
if (num == 5) dd = dd*10 + (val-48);
if (num == 7) hh = hh*10 + (val-48);
if (num == 9) mn = mn*10 + (val-48);
if (num == 11) ss = ss*10 + (val-48);
}
else if ( (num & 1) != 0) num ++;
}
return (num > 0);
}
Standard_Integer Interface_MSG::CDate (const Standard_CString text1,
const Standard_CString text2)
{
Standard_Integer i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,j1=0,j2=0,j3=0,j4=0,j5=0,j6=0;
if (!NDate (text1,i1,i2,i3,i4,i5,i6)) return 0;
if (!NDate (text2,j1,j2,j3,j4,j5,j6)) return 0;
if (i1 < j1) return -1;
if (i1 > j1) return 1;
if (i2 < j2) return -1;
if (i2 > j2) return 1;
if (i3 < j3) return -1;
if (i3 > j3) return 1;
if (i4 < j4) return -1;
if (i4 > j4) return 1;
if (i5 < j5) return -1;
if (i5 > j5) return 1;
if (i6 < j6) return -1;
if (i6 > j6) return 1;
return 0;
}
Standard_CString Interface_MSG::Blanks (const Standard_Integer val,
const Standard_Integer max)
{
Standard_Integer count;
if (val < 0) return Interface_MSG::Blanks (-val,max-1);
if (val < 10) count = 9;
else if (val < 100) count = 8;
else if (val < 1000) count = 7;
else if (val < 10000) count = 6;
else if (val < 100000) count = 5;
else if (val < 1000000) count = 4;
else if (val < 10000000) count = 3;
else if (val < 100000000) count = 2;
else if (val < 1000000000) count = 1;
else count = 0;
count = count + max - 10;
if (count < 0) count = 0;
return &blank [maxblank - count];
}
Standard_CString Interface_MSG::Blanks (const Standard_CString val,
const Standard_Integer max)
{
Standard_Integer lng = strlen(val);
if (lng > maxblank || lng > max) return "";
return &blank [maxblank - max + lng];
}
Standard_CString Interface_MSG::Blanks
(const Standard_Integer count)
{
if (count <= 0) return "";
if (count >= maxblank) return blank;
return &blank [maxblank-count];
}
void Interface_MSG::Print (Standard_OStream& S, const Standard_CString val,
const Standard_Integer max,
const Standard_Integer just)
{
if (max > maxblank) { Print(S,val,maxblank,just); return; }
Standard_Integer lng = strlen (val);
if (lng > max) { S << val; return; }
Standard_Integer m1 = (max-lng) /2;
Standard_Integer m2 = max-lng - m1;
if (just < 0) S<<val<<&blank[maxblank-m1-m2];
else if (just == 0) S<<&blank[maxblank-m1]<<val<<&blank[maxblank-m2];
else S<<&blank[maxblank-m1-m2]<<val;
}

View File

@@ -0,0 +1,12 @@
// File: Interface_Macros.hxx
// Created: Mon Nov 22 17:25:42 1999
// Author: data exchange team
// <det@kinox>
#ifndef Interface_Macros_HeaderFile
#define Interface_Macros_HeaderFile
#include <MoniTool_Macros.hxx>
#endif

View File

@@ -0,0 +1,24 @@
-- File: Interface_MapAsciiStringHasher.cdl
-- Created: Tue May 6 10:31:46 2003
-- Author: Galina KULIKOVA
-- <gka@zamox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2003
class MapAsciiStringHasher from Interface
---Purpose:
uses
AsciiString from TCollection
is
HashCode(myclass; K : AsciiString from TCollection ; Upper : Integer) returns Integer;
IsEqual(myclass; K1, K2 : AsciiString from TCollection) returns Boolean;
end MapAsciiStringHasher;

View File

@@ -0,0 +1,25 @@
#include <Interface_MapAsciiStringHasher.ixx>
#include <TCollection_AsciiString.hxx>
//=======================================================================
//function : HashCode
//purpose :
//=======================================================================
Standard_Integer Interface_MapAsciiStringHasher::HashCode(const TCollection_AsciiString& K,
const Standard_Integer Upper)
{
return ::HashCode(K.ToCString(),Upper);
}
//=======================================================================
//function : IsEqual
//purpose :
//=======================================================================
Standard_Boolean Interface_MapAsciiStringHasher::IsEqual(const TCollection_AsciiString& K1,
const TCollection_AsciiString& K2)
{
if(!K1.Length() || !K2.Length()) return Standard_False;
return K1.IsEqual(K2);
}

View File

@@ -0,0 +1,70 @@
-- File: Interface_ParamList.cdl
-- Created: Mon Jan 21 11:04:57 2008
-- Author: Galina KULIKOVA
-- <gka@YADREX>
---Copyright: Open CSCADE 2008
class ParamList from Interface inherits TShared from MMgt
---Purpose:
uses
FileParameter from Interface,VectorOfFileParameter from Interface
raises RangeError from Standard,
OutOfRange from Standard,
OutOfMemory from Standard
is
Create( theIncrement : Integer = 256) returns ParamList from Interface;
---Purpose: Creates an vector with size of memmory blok equal to theIncrement
Length (me) returns Integer from Standard;
---Purpose: Returns the number of elements of <me>.
--
---C++: inline
Lower (me) returns Integer from Standard;
---Purpose: Returns the lower bound.
-- Warning
--Client programs of the Array1 class must be independent of the first item range.--
---C++: inline
Upper (me) returns Integer from Standard;
---Purpose: Returns the upper bound.
-- Warning
--Client programs of the Array1 class must be independent of the first item range.--
---C++: inline
SetValue (me : mutable; Index: Integer from Standard; Value: FileParameter from Interface)
---Purpose: Assigns the value <Value> to the <Index>-th item of this array.
raises OutOfRange from Standard;
Value (me; Index:Integer from Standard) returns FileParameter from Interface
---Purpose: Return the value of the <Index>th element of the
-- array.
---C++: alias operator ()
---C++: return const &
raises OutOfRange from Standard;
ChangeValue (me: mutable; Index:Integer from Standard) returns FileParameter from Interface
---Purpose: return the value of the <Index>th element of the
-- array.
--
---C++: alias operator ()
---C++: return &
raises OutOfRange from Standard;
Clear(me: mutable);
fields
myVector : VectorOfFileParameter;
end ParamList;

View File

@@ -0,0 +1,62 @@
// File: Interface_ParamList.cxx
// Created: 21.01.08 11:24
// Author: Galina KULIKOVA
// Copyright: OpenCASCADE 2008
#include <Interface_ParamList.ixx>
//=======================================================================
//function : Interface_ParamList
//purpose :
//=======================================================================
Interface_ParamList::Interface_ParamList(const Standard_Integer theIncrement) :
myVector (theIncrement)
{
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
void Interface_ParamList::SetValue(const Standard_Integer theIndex,const Interface_FileParameter& theValue)
{
Standard_Integer ind = theIndex-1;
myVector.SetValue(ind,theValue);
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const Interface_FileParameter& Interface_ParamList::Value(const Standard_Integer theIndex) const
{
Standard_Integer ind = theIndex-1;
return myVector.Value(ind);
}
//=======================================================================
//function : ChangeValue
//purpose :
//=======================================================================
Interface_FileParameter& Interface_ParamList::ChangeValue(const Standard_Integer theIndex)
{
Standard_Integer ind = theIndex-1;
if(ind >= myVector.Length())
{
Interface_FileParameter aFP;
myVector.SetValue(ind,aFP);
}
return myVector.ChangeValue(ind);
}
void Interface_ParamList::Clear()
{
myVector.Clear();
}

View File

@@ -0,0 +1,17 @@
inline Standard_Integer Interface_ParamList::Length() const
{
return myVector.Length();
}
inline Standard_Integer Interface_ParamList::Lower() const
{
return 1;
}
inline Standard_Integer Interface_ParamList::Upper() const
{
return (myVector.Length());
}

View File

@@ -0,0 +1,81 @@
-- File: ParamSet.cdl
-- Created: Thu Oct 29 19:03:55 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class ParamSet from Interface inherits TShared
---Purpose : Defines an ordered set of FileParameters, in a way to be
-- efficient as in memory requirement or in speed
uses CString, ParamList, FileParameter, ParamType
raises OutOfRange
is
Create (nres : Integer; nst : Integer = 1) returns mutable ParamSet;
---Purpose : Creates an empty ParamSet, beginning at number "nst" and of
-- initial reservation "nres" : the "nres" first parameters
-- which follow "ndeb" (included) will be put in an Array
-- (a ParamList). The remainders are set in Next(s) ParamSet(s)
Append (me : mutable; val : CString; lnval : Integer; typ : ParamType;
nument : Integer)
returns Integer is static;
---Purpose : Adds a parameter defined as its Value (CString and length) and
-- Type. Optionnal EntityNumber (for FileReaderData) can be given
-- Allows a better memory management than Appending a
-- complete FileParameter
-- If <lnval> < 0, <val> is assumed to be managed elsewhere : its
-- adress is stored as such. Else, <val> is copied in a locally
-- (quickly) managed Page of Characters
-- Returns new count of recorded Parameters
Append (me : mutable; FP : FileParameter) returns Integer is static;
---Purpose : Adds a parameter at the end of the ParamSet (transparent
-- about reservation and "Next")
-- Returns new count of recorded Parameters
NbParams (me) returns Integer is static;
---Purpose : Returns the total count of parameters (including nexts)
Param (me; num : Integer) returns FileParameter
---Purpose : Returns a parameter identified by its number
raises OutOfRange is static;
-- Error if num < 1 or num > NbParams
---C++ : return const &
ChangeParam (me : mutable; num : Integer) returns FileParameter
---Purpose : Same as above, but in order to be modified on place
raises OutOfRange is static;
-- Error if num < 1 or num > NbParams
---C++ : return &
SetParam (me : mutable; num : Integer; FP : FileParameter)
raises OutOfRange is static;
---Purpose : Changes a parameter identified by its number
Params (me; num,nb : Integer) returns ParamList
raises OutOfRange is static;
---Purpose : Builds and returns the sub-list correspinding to parameters,
-- from "num" included, with count "nb"
-- If <num> and <nb> are zero, returns the whole list
Destroy (me : mutable) is static;
---Purpose : Destructor (waiting for transparent memory management)
---C++ : alias ~
fields
theval : PCharacter;
thelnval : Integer;
thelnres : Integer;
thenbpar : Integer;
themxpar : Integer;
thelist : ParamList;
thenext : ParamSet;
end ParamSet;

View File

@@ -0,0 +1,141 @@
//szv#4 S4163
#include <Interface_ParamSet.ixx>
Interface_ParamSet::Interface_ParamSet (const Standard_Integer nres, const Standard_Integer )//nst)
{
thelist = new Interface_ParamList;// (nst,nst+nres+2);
themxpar = nres;
thenbpar = 0;
thelnval = 0;
thelnres = 100; // *20; // 10 caracteres par Param (\0 inclus) : raisonnable
theval = new char[thelnres]; //szv#4:S4163:12Mar99 `thelnres+1` chars was wrong
}
// Append(CString) : Gestion des caracteres selon <lnval>
// Si lnval < 0, ParamSet passif, memoire geree de l exterieur, ParamSet
// se contente de s y referer
// Sinon, recopie dans une page locale
Standard_Integer Interface_ParamSet::Append (const Standard_CString val, const Standard_Integer lnval,
const Interface_ParamType typ, const Standard_Integer nument)
{
// Ici, gestion locale de String
thenbpar ++;
if (thenbpar > themxpar) {
thenext = new Interface_ParamSet (themxpar,1);
return (thenbpar + thenext->Append(val,lnval,typ,nument));
}
else if (lnval < 0) {
// .. Gestion externe des caracteres ..
Interface_FileParameter& FP = thelist->ChangeValue(thenbpar);
FP.Init(val,typ);
if (nument != 0) FP.SetEntityNumber(nument);
}
else {
// .. Gestion locale des caracteres ..
Standard_Integer i;
if (thelnval + lnval + 1 > thelnres) {
// Reservation de caracteres insuffisante : d abord augmenter
Standard_Integer newres = thelnres*2 + lnval ;
char* newval = new char[newres];
for (i = 0; i < thelnval; i++)
newval[i] = theval[i]; //szv#4:S4163:12Mar99 `<= thelnres` was wrong
// et cepatou : il faut realigner les Params deja enregistres sur
// l ancienne reservation de caracteres ...
//Standard_Integer delta = (Standard_Integer) (newval - theval);
// difference a appliquer
char* poldVal = &theval[0];
char* pnewVal= &newval[0];
for (i = 1; i < thenbpar; i ++) {
Interface_FileParameter& OFP = thelist->ChangeValue(i);
Interface_ParamType otyp = OFP.ParamType();
char* oval = (char*)OFP.CValue();
Standard_Integer delta = (Standard_Integer) (oval - poldVal);
//if (oval < theval || oval >= (theval+thelnres))
// continue; //hors reserve //szv#4:S4163:12Mar99 `oval >` was wrong
Standard_Integer onum = OFP.EntityNumber();
OFP.Init(pnewVal+delta,otyp); // et voila; on remet dans la boite
if (onum != 0) OFP.SetEntityNumber(onum);
}
// Enteriner la nouvelle reservation
delete [] theval;
theval = newval;
thelnres = newres;
}
// Enregistrer ce parametre
for (i = 0; i < lnval; i ++) theval[thelnval + i] = val[i];
theval[thelnval+lnval] = '\0';
Interface_FileParameter& FP = thelist->ChangeValue(thenbpar);
FP.Init(&theval[thelnval],typ);
if (nument != 0) FP.SetEntityNumber(nument);
thelnval += (lnval+1);
}
return thenbpar;
}
Standard_Integer Interface_ParamSet::Append (const Interface_FileParameter& FP)
{
// Ici, FP tout pret : pas de gestion memoire sur String (dommage)
thenbpar ++;
if (thenbpar > themxpar) {
thenext = new Interface_ParamSet (themxpar,1);
return thenbpar + thenext->Append(FP);
}
thelist->SetValue(thenbpar,FP);
return thenbpar;
}
Standard_Integer Interface_ParamSet::NbParams () const
{ return thenbpar; }
const Interface_FileParameter& Interface_ParamSet::Param (const Standard_Integer num) const
{
if (num > themxpar) return thenext->Param(num - themxpar);
else return thelist->Value(num);
}
Interface_FileParameter& Interface_ParamSet::ChangeParam (const Standard_Integer num)
{
if (num > themxpar) return thenext->ChangeParam(num - themxpar);
else return thelist->ChangeValue(num);
}
void Interface_ParamSet::SetParam (const Standard_Integer num, const Interface_FileParameter& FP)
{
if (num > themxpar) thenext->SetParam(num - themxpar, FP);
else thelist->SetValue(num,FP);
}
Handle(Interface_ParamList) Interface_ParamSet::Params (const Standard_Integer num,
const Standard_Integer nb) const
{
Standard_Integer i, n0 = num-1, nbp = nb;
if (num > themxpar)
return thenext->Params (num-themxpar,nb);
if (num == 0 && nb == 0) {
n0 = 0; nbp = thenbpar;
if (thenbpar <= themxpar)
return thelist; // et zou
}
Handle(Interface_ParamList) list = new Interface_ParamList;
if (nb == 0)
return list;
for (i = 1; i <= nbp; i ++) list->SetValue(i,Param(n0+i));
return list;
}
void Interface_ParamSet::Destroy ()
{
// if (!thenext.IsNull()) thenext->Destroy();
thenext.Nullify();
// Destruction "manuelle" (gestion memoire directe)
if (theval) delete [] theval;
theval = NULL;
thelist->Clear();
thelist.Nullify();
}

View File

@@ -0,0 +1,99 @@
-- File: Interface_Protocol.cdl
-- Created: Tue Feb 2 11:35:43 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
deferred class Protocol from Interface inherits TShared
---Purpose : General description of Interface Protocols. A Protocol defines
-- a set of Entity types. This class provides also the notion of
-- Active Protocol, as a working context, defined once then
-- exploited by various Tools and Libraries.
--
-- It also gives control of type definitions. By default, types
-- are provided by CDL, but specific implementations, or topics
-- like multi-typing, may involve another way
uses InterfaceModel, Check, Graph
raises InterfaceError
is
-- -- Management of Active Protocol -- --
Active (myclass) returns Protocol;
---Purpose : Returns the Active Protocol, if defined (else, returns a
-- Null Handle, which means "no defined active protocol")
SetActive (myclass; aprotocol : Protocol);
---Purpose : Sets a given Protocol to be the Active one (for the users of
-- Active, see just above). Applies to every sub-type of Protocol
ClearActive (myclass);
---Purpose : Erases the Active Protocol (hence it becomes undefined)
-- -- General Definition (complies with Template) -- --
NbResources (me) returns Integer is deferred;
---Purpose : Returns count of Protocol used as Resources (level one)
Resource (me; num : Integer) returns Protocol is deferred;
---Purpose : Returns a Resource, given its rank (between 1 and NbResources)
CaseNumber (me; obj : any Transient) returns Integer is virtual;
---Purpose : Returns a unique positive CaseNumber for each Recognized
-- Object. By default, recognition is based on Type(1)
-- By default, calls the following one which is deferred.
IsDynamicType (me; obj : any Transient) returns Boolean is virtual;
---Purpose : Returns True if type of <obj> is that defined from CDL
-- This is the default but it may change according implementation
NbTypes (me; obj : any Transient) returns Integer is virtual;
---Purpose : Returns the count of DISTINCT types under which an entity may
-- be processed. Each one is candidate to be recognized by
-- TypeNumber, <obj> is then processed according it
-- By default, returns 1 (the DynamicType)
Type (me; obj : any Transient; nt : Integer = 1) returns Type;
---Purpose : Returns a type under which <obj> can be recognized and
-- processed, according its rank in its definition list (see
-- NbTypes).
-- By default, returns DynamicType
TypeNumber (me; atype : any Type) returns Integer is deferred;
---Purpose : Returns a unique positive CaseNumber for each Recognized Type,
-- Returns Zero for "<type> not recognized"
GlobalCheck (me; G : Graph; ach : in out Check)
returns Boolean is virtual;
---Purpose : Evaluates a Global Check for a model (with its Graph)
-- Returns True when done, False if data in model do not apply
--
-- Very specific of each norm, i.e. of each protocol : the
-- uppest level Protocol assumes it, it can call GlobalCheck of
-- its ressources only if it is necessary
--
-- Default does nothing, can be redefined
-- -- General Services (defined at Norm level) -- --
NewModel (me) returns mutable InterfaceModel is deferred;
---Purpose : Creates an empty Model of the considered Norm
IsSuitableModel (me; model : InterfaceModel) returns Boolean is deferred;
---Purpose : Returns True if <model> is a Model of the considered Norm
UnknownEntity (me) returns mutable Transient is deferred;
---Purpose : Creates a new Unknown Entity for the considered Norm
IsUnknownEntity (me; ent : Transient) returns Boolean is deferred;
---Purpose : Returns True if <ent> is an Unknown Entity for the Norm, i.e.
-- same Type as them created by method UnknownEntity
-- (for an Entity out of the Norm, answer can be unpredicable)
end Protocol;

View File

@@ -0,0 +1,109 @@
#include <Interface_Protocol.ixx>
// Gestion du Protocol actif : tres simple, une variable statique
static Handle(Interface_Protocol)& theactive()
{
static Handle(Interface_Protocol) theact;
return theact;
}
//=======================================================================
//function : Active
//purpose :
//=======================================================================
Handle(Interface_Protocol) Interface_Protocol::Active ()
{
return theactive();
}
//=======================================================================
//function : SetActive
//purpose :
//=======================================================================
void Interface_Protocol::SetActive(const Handle(Interface_Protocol)& aprotocol)
{
theactive() = aprotocol;
}
//=======================================================================
//function : ClearActive
//purpose :
//=======================================================================
void Interface_Protocol::ClearActive ()
{
theactive().Nullify();
}
// === Typage (formules fournies par defaut)
//=======================================================================
//function : CaseNumber
//purpose :
//=======================================================================
Standard_Integer Interface_Protocol::CaseNumber
(const Handle(Standard_Transient)& obj) const
{
if (obj.IsNull()) return 0;
return TypeNumber(Type(obj));
}
//=======================================================================
//function : IsDynamicType
//purpose :
//=======================================================================
Standard_Boolean Interface_Protocol::IsDynamicType
(const Handle(Standard_Transient)& /*obj*/) const
{
return Standard_True;
}
//=======================================================================
//function : NbTypes
//purpose :
//=======================================================================
Standard_Integer Interface_Protocol::NbTypes
(const Handle(Standard_Transient)& /*obj*/) const
{
return 1;
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
Handle(Standard_Type) Interface_Protocol::Type
(const Handle(Standard_Transient)& obj,
const Standard_Integer /*nt*/) const
{
if (obj.IsNull()) return STANDARD_TYPE(Standard_Transient);
return obj->DynamicType();
}
//=======================================================================
//function : GlobalCheck
//purpose :
//=======================================================================
Standard_Boolean Interface_Protocol::GlobalCheck(const Interface_Graph& /*graph*/,
Handle(Interface_Check)& /*ach*/) const
{
return Standard_True;
}

View File

@@ -0,0 +1,57 @@
-- File: Interface_ReaderModule.cdl
-- Created: Thu Feb 4 18:06:48 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
deferred class ReaderModule from Interface inherits TShared
---Purpose : Defines unitary operations required to read an Entity from a
-- File (see FileReaderData, FileReaderTool), under control of
-- a FileReaderTool. The initial creation is performed by a
-- GeneralModule (set in GeneralLib). Then, which remains is
-- Loading data from the FileReaderData to the Entity
--
-- To work, a GeneralModule has formerly recognized the Type read
-- from FileReaderData as a positive Case Number, then the
-- ReaderModule reads it according to this Case Number
uses Transient, FileReaderData, Check
raises DomainError
is
CaseNum (me; data : FileReaderData; num : Integer) returns Integer
is deferred;
---Purpose : Translates the type of record <num> in <data> to a positive
-- Case Number. If Recognition fails, must return 0
Read (me; casenum : Integer; data : FileReaderData; num : Integer;
ach : in out Check; ent : mutable Transient)
---Purpose : Performs the effective loading from <data>, record <num>,
-- to the Entity <ent> formerly created
-- In case of Error or Warning, fills <ach> with messages
-- Remark that the Case Number comes from translating a record
raises DomainError is deferred;
-- Can raise any exception, while it is preferable to prevent
-- them and fill the Check
NewRead (me; casenum : Integer; data : FileReaderData; num : Integer;
ach : in out Check; ent : out mutable Transient) returns Boolean
---Purpose : Specific operator (create+read) defaulted to do nothing.
-- It can be redefined when it is not possible to work in two
-- steps (NewVoid then Read). This occurs when no default
-- constructor is defined : hence the result <ent> must be
-- created with an effective definition from the reader.
-- Remark : if NewRead is defined, Copy has nothing to do.
--
-- Returns True if it has produced something, false else.
-- If nothing was produced, <ach> should be filled : it will be
-- treated as "Unrecognized case" by reader tool.
raises DomainError is virtual;
-- Can raise any exception, while it is preferable to prevent
-- them and fill the Check
end ReaderModule;

View File

@@ -0,0 +1,11 @@
#include <Interface_ReaderModule.ixx>
Standard_Boolean Interface_ReaderModule::NewRead(const Standard_Integer,
const Handle(Interface_FileReaderData)&,
const Standard_Integer,
Handle(Interface_Check)&,
Handle(Standard_Transient)& ) const
{
return Standard_False;
}

View File

@@ -0,0 +1,70 @@
-- File: Recognizer.cdl
-- Created: Mon Feb 3 16:31:47 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
deferred generic class Recognizer from Interface
(TheKey as any;
TheResul as Transient)
inherits Transient
---Purpose : Defines a correspondance between an object to be recognized,
-- of type (Kind) TheKey, and a result of the recognition. There
-- can be no correspondance. When an object is recognized, the
-- returned result is empty : a Recognizer is not aimed to make
-- a transfer but to initiate it by giving a correspondant
--
-- A Recognizer can be compound, that is, in addition to its own
-- Eval method if this one has failed, it can ask another
-- Recognizer to work, and so on : See method Add
raises NoSuchObject
is
Initialize;
---Purpose : Assumes that no result has yet been recognized
Evaluate (me : mutable; akey : TheKey; res : out mutable TheResul)
returns Boolean;
---Purpose : Evaluates if recognition has a result, returns it if yes
-- In case of success, Returns True and puts result in "res"
-- In case of Failure, simply Returns False
-- Works by calling deferred method Eval, and in case of failure,
-- looks for Added Recognizers to work
Result (me) returns mutable TheResul raises NoSuchObject;
---Purpose : Returns result of last recognition (call of Evaluate)
Add (me : mutable; reco : mutable Recognizer);
---Purpose : Adds a new Recognizer to the Compound, at the end
-- Several calls to Add work by adding in the order of calls :
-- Hence, when Eval has failed to recognize, Evaluate will call
-- Evaluate from the first added Recognizer if there is one,
-- and to the second if there is still no result, and so on
SetOK (me : mutable; aresult : mutable TheResul) is protected;
---Purpose : Records the result of the recognition. Called by specific
-- method Eval to record a result : after calling it, Eval has
-- finished and can return
SetKO (me : mutable) is protected;
---Purpose : Records that recognition gives no result
Eval (me : mutable; akey : TheKey) is deferred protected;
---Purpose : THIS METHOD DEFINES THE RECOGNITION PROTOCOL, it is proper to
-- each precise type of Recognizer
-- For a suitable type of akey, it calls SetOK(result) where
-- result is an empty result of appropriate type, then returns
fields
theres : TheResul; -- storing result of last evaluation
hasnext : Boolean;
thenext : Recognizer; -- managing compound definition
end Recognizer;

View File

@@ -0,0 +1,48 @@
//#include <Interface_Recognizer.ixx>
#include <Standard_NoSuchObject.hxx>
// ATTENTION : TransRecognizer a exactement le meme code ...
// Mais produit un Transient au lieu d un Persistent
// Principe : a un objet de depart (cle), un Recognizer tente d'associer un
// resultat. La classe Recognizer offre le mecanisme general gerant cela
// Chaque classe particuliere (une fois definie l'instanciation) doit fournir
// une methode specifique Eval, qui opere la correspondance
// Eval considere l'objet par tous moyens appropries, et en cas de succes,
// appelle SetOK(result) puis sort (return)
// en cas d'echec, suite au retour d'Eval, Recognizer sait que SetOK n'a pas
// ete appele
Interface_Recognizer::Interface_Recognizer ()
{ hasnext = Standard_False; }
//thekey.Nullify(); inutile, fait par le constructeur ...
Standard_Boolean Interface_Recognizer::Evaluate
(const TheKey& akey, Handle(TheResul)& res)
{
theres.Nullify();
Eval(akey);
if (!theres.IsNull()) {
res = theres;
return Standard_True;
}
else if (hasnext) return thenext->Evaluate(akey,res);
return Standard_False;
}
Handle(TheResul) Interface_Recognizer::Result () const
{
if (!theres.IsNull()) return theres;
if (hasnext) return thenext->Result();
Standard_NoSuchObject::Raise ("Recognizer evaluation has failed");
return theres; // pour calmer le compilateur
}
void Interface_Recognizer::Add (const Handle(Interface_Recognizer)& reco)
{ thenext = reco; hasnext = Standard_True; }
void Interface_Recognizer::SetOK (const Handle(TheResul)& aresult)
{ theres = aresult; }
void Interface_Recognizer::SetKO ()
{ theres.Nullify(); }

View File

@@ -0,0 +1,94 @@
-- File: Interface_ReportEntity.cdl
-- Created: Fri Feb 5 16:35:30 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
class ReportEntity from Interface inherits TShared
---Purpose : A ReportEntity is produced to aknowledge and memorize the
-- binding between a Check and an Entity. The Check can bring
-- Fails (+ Warnings if any), or only Warnings. If it is empty,
-- the Report Entity is for an Unknown Entity.
--
-- The ReportEntity brings : the Concerned Entity, the
-- Check, and if the Entity is empty (Fails due to Read
-- Errors, hence the Entity could not be loaded), a Content.
-- The Content is itself an Transient Object, but remains in a
-- literal form : it is an "Unknown Entity". If the Concerned
-- Entity is itself Unknown, Concerned and Content are equal.
--
-- According to the Check, if it brings Fail messages,
-- the ReportEntity is an "Error Entity", the Concerned Entity is
-- an "Erroneous Entity". Else it is a "Correction Entity", the
-- Concerned Entity is a "Corrected Entity". With no Check
-- message and if Concerened and Content are equal, it reports
-- for an "Unknown Entity".
--
-- Each norm must produce its own type of Unknown Entity, but can
-- use the class UndefinedContent to brings parameters : it is
-- enough for most of information and avoids to redefine them,
-- only the specific part remains to be defined for each norm.
uses Check, Transient
is
Create (unknown : mutable Transient) returns mutable ReportEntity;
---Purpose : Creates a ReportEntity for an Unknown Entity : Check is empty,
-- and Concerned equates Content (i.e. the Unknown Entity)
Create (acheck : Check; concerned : mutable Transient)
returns mutable ReportEntity;
---Purpose : Creates a ReportEntity with its features :
-- - <acheck> is the Check to be memorised
-- - <concerned> is the Entity to which the Check is bound
-- Later, a Content can be set : it is required for an Error
SetContent (me : mutable; content : mutable Transient);
---Purpose : Sets a Content : it brings non interpreted data which belong
-- to the Concerned Entity. It can be empty then loaded later.
-- Remark that for an Unknown Entity, Content is set by Create.
Check (me) returns Check;
---Purpose : Returns the stored Check
---C++ : return const &
CCheck (me : mutable) returns Check;
---Purpose : Returns the stored Check in order to change it
---C++ : return &
Concerned (me) returns mutable Transient;
---Purpose : Returns the stored Concerned Entity. It equates the Content
-- in the case of an Unknown Entity
HasContent (me) returns Boolean;
---Purpose : Returns True if a Content is stored (it can equate Concerned)
HasNewContent (me) returns Boolean;
---Purpose : Returns True if a Content is stored AND differs from Concerned
-- (i.e. redefines content) : used when Concerned could not be
-- loaded
Content (me) returns mutable Transient;
---Purpose : Returns the stored Content, or a Null Handle
-- Remark that it must be an "Unknown Entity" suitable for
-- the norm of the containing Model
IsError (me) returns Boolean;
---Purpose : Returns True for an Error Entity, i.e. if the Check
-- brings at least one Fail message
IsUnknown (me) returns Boolean;
---Purpose : Returns True for an Unknown Entity, i,e. if the Check
-- is empty and Concerned equates Content
fields
thecheck : Check;
theconcerned : Transient;
thecontent : Transient;
end ReportEntity;

View File

@@ -0,0 +1,131 @@
#include <Interface_ReportEntity.ixx>
//=======================================================================
//function : Interface_ReportEntity
//purpose :
//=======================================================================
Interface_ReportEntity::Interface_ReportEntity
(const Handle(Standard_Transient)& unknown)
{
theconcerned = unknown;
thecontent = unknown;
}
//=======================================================================
//function : Interface_ReportEntity
//purpose :
//=======================================================================
Interface_ReportEntity::Interface_ReportEntity
(const Handle(Interface_Check)& acheck,
const Handle(Standard_Transient)& concerned)
: thecheck(acheck)
{
theconcerned = concerned;
thecheck->SetEntity(concerned);
}
//=======================================================================
//function : SetContent
//purpose :
//=======================================================================
void Interface_ReportEntity::SetContent(const Handle(Standard_Transient)& content)
{
thecontent = content;
}
// .... CONSULTATION ....
//=======================================================================
//function : Check
//purpose :
//=======================================================================
const Handle(Interface_Check)& Interface_ReportEntity::Check () const
{
return thecheck;
}
//=======================================================================
//function : CCheck
//purpose :
//=======================================================================
Handle(Interface_Check)& Interface_ReportEntity::CCheck ()
{
return thecheck;
}
//=======================================================================
//function : Concerned
//purpose :
//=======================================================================
Handle(Standard_Transient) Interface_ReportEntity::Concerned () const
{
return theconcerned;
}
//=======================================================================
//function : HasContent
//purpose :
//=======================================================================
Standard_Boolean Interface_ReportEntity::HasContent () const
{
return (!thecontent.IsNull());
}
//=======================================================================
//function : HasNewContent
//purpose :
//=======================================================================
Standard_Boolean Interface_ReportEntity::HasNewContent () const
{
return (!thecontent.IsNull() && thecontent != theconcerned);
}
//=======================================================================
//function : Content
//purpose :
//=======================================================================
Handle(Standard_Transient) Interface_ReportEntity::Content () const
{
return thecontent;
}
//=======================================================================
//function : IsError
//purpose :
//=======================================================================
Standard_Boolean Interface_ReportEntity::IsError () const
{
return (thecheck->NbFails() > 0);
}
//=======================================================================
//function : IsUnknown
//purpose :
//=======================================================================
Standard_Boolean Interface_ReportEntity::IsUnknown () const
{
return ((thecheck->NbFails() == 0) && (thecheck->NbWarnings() == 0)
&& (theconcerned == thecontent));
}

184
src/Interface/Interface_STAT.cdl Executable file
View File

@@ -0,0 +1,184 @@
-- File: Interface_STAT.cdl
-- Created: Thu Feb 15 16:45:14 1996
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1996
class STAT from Interface
---Purpose : This class manages statistics to be queried asynchronously.
-- Way of use :
-- An operator describes a STAT form then fills it according to
-- its progression. This produces a state of advancement of the
-- process. This state can then be queried asynchronously :
-- typically it is summarised as a percentage. There are also
-- an identification of the current state, and informations on
-- processed volume.
--
-- A STAT form can be described once for all (as static).
-- It describes the stream of the process (see later), in terms
-- of phases, cycles, steps, with estimated weights. But it
-- brings no current data.
--
-- One STAT at a time is active for filling and querying. It is
-- used to control phasing, weighting ... Specific data for
-- execution are given when running on active STAT : counts of
-- items ... Data for query are then recorded and can be accessed
-- at any time, asynchronously.
--
-- A STAT is organised as follows :
-- - it can be split into PHASES (by default, there is none, and
-- all process takes place in one "default" phase)
-- - each phase is identified by a name and is attached a weight
-- -> the sum of the weights is used to compute relative weights
-- - for each phase, or for the unique default phase if none :
-- -- the process works on a list of ITEMS
-- -- by default, all the items are processed in once
-- -- but this list can be split into CYCLES, each one takes
-- a sub-list : the weight of each cycle is related to its
-- count of items
-- -- a cycle can be split into STEPS, by default there are none
-- then one "default step" is considered
-- -- each step is attached a weight
-- -> the sum of the weights of steps is used to compute relative
-- weights of the steps in each cycle
-- -> all the cycles of a phase have the same organisation
--
-- Hence, when defining the STAT form, the phases have to be
-- described. If no weight is precisely known, give 1. for all...
-- No phase description will give only one "default" phase
-- For each phase, a typical cycle can be described by its steps.
-- Here too, for no weight precisely known, give 1. for all...
--
-- For executing, activate a STAT to begin count. Give counts of
-- items and cycles for the first phase (for the unique default
-- one if no phasing is described)
-- Else, give count of items and cycles for each new phase.
-- Class methods allow also to set next cycle (given count of
-- items), next step in cycle (if more then one), next item in
-- step.
uses Integer, Real, HSequenceOfInteger, HSequenceOfReal,
CString, HAsciiString, HSequenceOfAsciiString
is
-- -- Description of a STAT form -- --
Create (title : CString = "") returns STAT;
---Purpose : Creates a STAT form. At start, one default phase is defined,
-- with one default step. Then, it suffises to start with a
-- count of items (and cycles if several) then record items,
-- to have a queryable report.
Create (other : STAT) returns STAT;
---Purpose : used when starting
Internals (me; tit : out HAsciiString; total : out Real;
phn : out HSequenceOfAsciiString; phw : out HSequenceOfReal;
phdeb, phfin : out HSequenceOfInteger;
stw : out HSequenceOfReal);
---Purpose : Returns fields in once, without copying them, used for copy
-- when starting
AddPhase (me : in out; weight : Real; name : CString = "");
---Purpose : Adds a new phase to the description.
-- The first one after Create replaces the default unique one
AddStep (me : in out; weight : Real = 1);
---Purpose : Adds a new step for the last added phase, the default unique
-- one if no AddPhase has already been added
-- Warning : AddStep before the first AddPhase are cancelled
Description (me; nbphases : out Integer; total : out Real; title : out CString);
---Purpose : Returns global description (cumulated weights of all phases,
-- count of phases,1 for default, and title)
Phase (me; num : Integer;n0step, nbstep : out Integer; weight : out Real; name : out CString);
---Purpose : Returns description of a phase, given its rank
-- (n0 for first step, count of steps, default gives one;
-- weight, name)
Step (me; num : Integer) returns Real;
---Purpose : Returns weight of a Step, related to the cumul given for the
-- phase.
-- <num> is given by <n0step> + i, i between 1 and <nbsteps>
-- (default gives n0step < 0 then weight is one)
-- -- Running : Filling -- --
Start (me; items : Integer; cycles : Integer = 1);
---Purpose : Starts a STAT on its first phase (or its default one)
-- <items> gives the total count of items, <cycles> the count of
-- cycles
-- If <cycles> is more than one, the first Cycle must then be
-- started by NextCycle (NextStep/NextItem are ignored).
-- If it is one, NextItem/NextStep can then be called
StartCount (myclass; items : Integer; title : CString = "");
---Purpose : Starts a default STAT, with no phase, no step, ready to just
-- count items.
-- <items> gives the total count of items
-- Hence, NextItem is available to directly count
NextPhase (myclass; items : Integer; cycles : Integer = 1);
---Purpose : Commands to resume the preceeding phase and start a new one
-- <items> and <cycles> as for Start, but for this new phase
-- Ignored if count of phases is already passed
-- If <cycles> is more than one, the first Cycle must then be
-- started by NextCycle (NextStep/NextItem are ignored).
-- If it is one, NextItem/NextStep can then be called
SetPhase (myclass; items : Integer; cycles : Integer = 1);
---Purpose : Changes the parameters of the phase to start
-- To be used before first counting (i.e. just after NextPhase)
-- Can be used by an operator which has to reajust counts on run
NextCycle (myclass; items : Integer);
---Purpose : Commands to resume the preceeding cycle and start a new one,
-- with a count of items
-- Ignored if count of cycles is already passed
-- Then, first step is started (or default one)
-- NextItem can be called for the first step, or NextStep to pass
-- to the next one
NextStep (myclass);
---Purpose : Commands to resume the preceeding step of the cycle
-- Ignored if count of steps is already passed
-- NextItem can be called for this step, NextStep passes to next
NextItem (myclass; nbitems : Integer = 1);
---Purpose : Commands to add an item in the current step of the current
-- cycle of the current phase
-- By default, one item per call, can be overpassed
-- Ignored if count of items of this cycle is already passed
End (myclass);
---Purpose : Commands to declare the process ended (hence, advancement is
-- forced to 100 %)
-- -- Running : Querying -- --
Where (myclass; phase : Boolean = Standard_True) returns CString;
---Purpose : Returns an identification of the STAT :
-- <phase> True (D) : the name of the current phase
-- <phase> False : the title of the current STAT
Percent (myclass; phase : Boolean = Standard_False) returns Integer;
---Purpose : Returns the advancement as a percentage :
-- <phase> True : inside the current phase
-- <phase> False (D) : relative to the whole process
fields -- used for description, not for running
thetitle : HAsciiString;
thetotal : Real;
thephnam : HSequenceOfAsciiString;
thephw : HSequenceOfReal;
thephdeb : HSequenceOfInteger; -- nums of steps of each phase
thephfin : HSequenceOfInteger;
thestw : HSequenceOfReal;
end STAT;

225
src/Interface/Interface_STAT.cxx Executable file
View File

@@ -0,0 +1,225 @@
#include <Interface_STAT.ixx>
#include <TCollection_AsciiString.hxx>
static Interface_STAT statvoid("");
static Interface_STAT statact ("");
static Standard_CString voidname = "";
Interface_STAT::Interface_STAT (const Standard_CString title)
{
thetitle = new TCollection_HAsciiString(title);
thetotal = 1.;
}
Interface_STAT::Interface_STAT (const Interface_STAT& other)
{ other.Internals (thetitle,thetotal, thephnam,thephw, thephdeb,thephfin, thestw); }
void Interface_STAT::Internals
(Handle(TCollection_HAsciiString)& tit, Standard_Real& total,
Handle(TColStd_HSequenceOfAsciiString)& phn,
Handle(TColStd_HSequenceOfReal)& phw,
Handle(TColStd_HSequenceOfInteger)& phdeb,
Handle(TColStd_HSequenceOfInteger)& phfin,
Handle(TColStd_HSequenceOfReal)& stw) const
{
tit = thetitle; total = thetotal; phn = thephnam; phw = thephw;
phdeb = thephdeb; phfin = thephfin; stw = thestw;
}
void Interface_STAT::AddPhase
(const Standard_Real weight, const Standard_CString name)
{
if (thephw.IsNull()) {
// 1re fois : vider les steps deja notees
thetotal = 0.;
thephnam = new TColStd_HSequenceOfAsciiString();
thephw = new TColStd_HSequenceOfReal();
thephdeb = new TColStd_HSequenceOfInteger();
thephfin = new TColStd_HSequenceOfInteger();
thestw = new TColStd_HSequenceOfReal();
}
thetotal += weight;
thephnam->Append (TCollection_AsciiString (name));
thephw->Append (weight);
thephdeb->Append (thestw->Length()+1);
thephfin->Append (0);
thestw->Append (0.);
}
void Interface_STAT::AddStep (const Standard_Real weight)
{
if (thephdeb.IsNull()) {
// 1re fois : pour default phase, au moins creer receptacle des steps
thephdeb = new TColStd_HSequenceOfInteger();
thephfin = new TColStd_HSequenceOfInteger();
thestw = new TColStd_HSequenceOfReal();
thephdeb->Append (thestw->Length()+1);
thephfin->Append (1);
thestw->Append (0.);
}
// A present, ajouter cette etape
Standard_Integer n0 = thephdeb->Value (thephdeb->Length());
// Ceci donne dans thestw le numero du cumul des etapes
thestw->ChangeValue (n0) += weight;
thestw->Append (weight); // on ajoute cette etape
thephfin->ChangeValue (thephfin->Length()) ++;
}
void Interface_STAT::Description
(Standard_Integer& nbphases,
Standard_Real& total, Standard_CString& title) const
{
nbphases = (thephw.IsNull() ? 1 : thephw->Length());
total = thetotal;
title = thetitle->ToCString();
}
void Interface_STAT::Phase
(const Standard_Integer num,
Standard_Integer& n0step, Standard_Integer& nbstep,
Standard_Real& weight, Standard_CString& name) const
{
if (thephdeb.IsNull()) {
// Pas de phase, pas d etape ... donc une seule ...
n0step = -1; nbstep = 1; weight = 1.; name = voidname;
}
if (thephw.IsNull()) {
// Pas de phase mais des etapes
weight = 1.; name = voidname;
} else if (num < 1 || num > thephdeb->Length()) return;
else {
// Phase
weight = thephw->Value(num); name = thephnam->Value(num).ToCString();
n0step = thephdeb->Value(num);
nbstep = thephfin->Value(num);
}
// Voyons pour cette phase
}
Standard_Real Interface_STAT::Step (const Standard_Integer num) const
{
if (thestw.IsNull()) return 1.;
if (num < 1 || num > thestw->Length()) return 1.;
return thestw->Value(num);
}
// ############### COMPTAGE ################
// Le comptage se fait sur la base suivante :
// TOTAL : total des poids des phases par rapport auquel calculer
// PHASES : poids des phases passees et poids de la phase en cours
// Ces poids sont a ramener au TOTAL
// PHASE COURANTE : nb d items et nb de cycles declares
// Nb d items deja passes (cycle complet)
// CYCLE COURANT : nb d items de ce cycle, total des poids des etapes
// Poids des etapes deja passees, de l etape en cours, n0 etape en cours
// ETAPE COURANTE : nb d items deja passes
static struct zestat {
Standard_CString itle, name;
Standard_Real otal, // total des poids des phases
oldph, // poids des phases deja passes
phw, // poids de la phase en cours
otph, // poids des etapes de la phase en cours (cycle en cours)
oldst, // poids des etapes deja passees (cycle en cours)
stw; // poids etape en cours
Standard_Integer nbph, // total nb de phases
numph, // n0 phase en cours
n0, n1, // n0 et nb etapes dans phase en cours
nbitp, // nb items total phase
nbcyc, // nb cycles total phase
olditp, // nb items deja passes (cycles passes) / phase
numcyc, // n0 cycle en cours / phase
nbitc, // nb items cycle en cours
numst, // n0 etape en cours / cycle
numitem; // nb items deja passes / etape courante
} stat;
void Interface_STAT::Start
(const Standard_Integer items, const Standard_Integer cycles) const
{
statact = *this;
statact.Description (stat.nbph,stat.otal,stat.itle);
stat.oldph = stat.phw = 0.; stat.numph = 0;
NextPhase (items,cycles);
}
void Interface_STAT::StartCount
(const Standard_Integer items, const Standard_CString name)
{
Interface_STAT statcount(name);
statcount.Start (items);
}
void Interface_STAT::NextPhase
(const Standard_Integer items, const Standard_Integer cycles)
{
// On cumule la phase precedente au total, on efface les donnees "locales"
stat.numcyc = stat.numst = stat.olditp = 0; stat.oldst = stat.stw = 0.;
if (stat.numph >= stat.nbph) { End(); return; }
stat.numph ++; stat.oldph += stat.phw; // cumule sur cette phase
stat.nbitp = items; stat.nbcyc = cycles;
statact.Phase(stat.numph, stat.n0,stat.n1,stat.phw,stat.name);
stat.otph = (stat.n1 > 1 ? statact.Step (stat.n0) : 1.);
// si un seul cycle, on le demarre; sinon, attendre NextCycle
stat.nbitc = 0;
if (cycles == 1) NextCycle (items);
}
void Interface_STAT::SetPhase
(const Standard_Integer items, const Standard_Integer cycles)
{ stat.nbitp = items; stat.nbcyc = cycles; }
void Interface_STAT::NextCycle (const Standard_Integer items)
{
// cumul de ce cycle sur les cycles deja passes, raz etapes
stat.numcyc ++; stat.olditp += stat.nbitc;
// if (stat.olditem > stat.nbitp) return;
stat.numst = 1;
stat.oldst = 0.;
stat.stw = (stat.n1 > 1 ? statact.Step(stat.n0 + 1) : stat.otph);
stat.nbitc = items; stat.numitem = 0;
}
void Interface_STAT::NextStep ()
{
if (stat.numst >= stat.n1) return;
stat.numst ++; stat.oldst += stat.stw;
stat.numitem = 0;
stat.stw = statact.Step (stat.n0 + stat.numst);
}
void Interface_STAT::NextItem (const Standard_Integer nbitems)
{ stat.numitem += nbitems; }
void Interface_STAT::End ()
{ stat.oldph = stat.otal; stat.phw = stat.stw = 0.; stat.itle = stat.name = voidname; }
// ########### QUERY ############
Standard_CString Interface_STAT::Where (const Standard_Boolean phase)
{ return (phase ? stat.name : stat.itle); }
Standard_Integer Interface_STAT::Percent (const Standard_Boolean phase)
{
if (stat.numitem > stat.nbitc) stat.numitem = stat.nbitc;
// on compte les items deja passes
Standard_Real enphase =
stat.olditp * stat.otph + // cycles complets passes
stat.nbitc * stat.oldst + // cycle courant, etapes completes passees
stat.numitem * stat.stw; // etape courante
// proportion pour cette phase
Standard_Real prophase = enphase / (stat.nbitp * stat.otph);
Standard_Integer res = Standard_Integer (prophase*100.);
if (phase) return res;
// voila pour cette phase
// comptage dans les phases
Standard_Real encours = (stat.oldph + stat.phw * prophase) / stat.otal;
res = Standard_Integer (encours * 100.);
return res;
}

View File

@@ -0,0 +1,76 @@
-- File: Interface_ShareFlags.cdl
-- Created: Mon Apr 5 19:31:50 1993
-- Author: Christian CAILLET
-- <cky@sdsun2>
---Copyright: Matra Datavision 1993
class ShareFlags from Interface
---Purpose : This class only says for each Entity of a Model, if it is
-- Shared or not by one or more other(s) of this Model
-- It uses the General Service "Shared".
uses HSequenceOfTransient from TColStd,
BitMap, InterfaceModel, EntityIterator,
GeneralLib, Protocol from Interface, GTool, Graph
raises DomainError, OutOfRange
is
Create (amodel : InterfaceModel; lib : GeneralLib) returns ShareFlags;
---Purpose : Creates a ShareFlags from a Model and builds required data
-- (flags) by calling the General Service Library given as
-- argument <lib>
Create (amodel : InterfaceModel; gtool : GTool from Interface)
returns ShareFlags;
---Purpose : Same as above, but GeneralLib is detained by a GTool
Create (amodel : InterfaceModel; protocol : Protocol from Interface)
returns ShareFlags;
---Purpose : Same as above, but GeneralLib is defined through a Protocol
Create (amodel : InterfaceModel) returns ShareFlags;
---Purpose : Same as above, but works with the GTool of the Model
Create (agraph : Graph) returns ShareFlags;
---Purpose : Creates a ShareFlags by querying informations from a Graph
-- (remark that Graph also has a method IsShared)
Evaluate (me : in out; lib : GeneralLib; gtool : GTool) is static private;
---Purpose : Computes flags at Creation time
--
-- Normally, gtool suffices. But if a Graph is created from a
-- GeneralLib directly, it cannot be used
-- If <gtool> is defined, it has priority
Model (me) returns InterfaceModel;
---Purpose : Returns the Model used for the evaluation
IsShared (me; ent : Transient) returns Boolean
---Purpose : Returns True if <ent> is Shared by one or more other
-- Entity(ies) of the Model
raises DomainError;
-- Error if <ent> does not come from the Model
RootEntities (me) returns EntityIterator;
---Purpose : Returns the Entities which are not Shared (see their flags)
NbRoots (me) returns Integer;
---Purpose : Returns the count of root entities
Root (me; num : Integer = 1) returns any Transient
---Purpose : Returns a root entity according its rank in the list of roots
-- By default, it returns the first one
raises OutOfRange;
-- Error if <num> if not between 1 and <NbRoots>
fields
themodel : InterfaceModel;
theflags : BitMap;
theroots : HSequenceOfTransient from TColStd;
end ShareFlags;

View File

@@ -0,0 +1,124 @@
#include <Interface_ShareFlags.ixx>
#include <Interface_GeneralModule.hxx>
#include <Interface_ReportEntity.hxx>
#include <Interface_IntList.hxx>
#include <Standard_DomainError.hxx>
Interface_ShareFlags::Interface_ShareFlags
(const Handle(Interface_InterfaceModel)& amodel,
const Interface_GeneralLib& lib)
: theflags (amodel->NbEntities())
{
Handle(Interface_GTool) gtool; // null
themodel = amodel;
Evaluate(lib,gtool);
}
Interface_ShareFlags::Interface_ShareFlags
(const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_GTool)& gtool)
: theflags (amodel->NbEntities())
{
themodel = amodel;
Evaluate(gtool->Lib(),gtool);
}
Interface_ShareFlags::Interface_ShareFlags
(const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_Protocol)& protocol)
: theflags (amodel->NbEntities())
{
Handle(Interface_GTool) gtool; // null
themodel = amodel;
Evaluate(Interface_GeneralLib(protocol),gtool);
}
Interface_ShareFlags::Interface_ShareFlags
(const Handle(Interface_InterfaceModel)& amodel)
: theflags (amodel->NbEntities())
{
Handle(Interface_GTool) gtool = themodel->GTool();
gtool->Reservate(amodel->NbEntities());
themodel = amodel;
Evaluate (gtool->Lib(),gtool);
}
Interface_ShareFlags::Interface_ShareFlags (const Interface_Graph& agraph)
: theflags (agraph.Model()->NbEntities())
{
themodel = agraph.Model();
Standard_Integer nb = themodel->NbEntities();
if (nb == 0) return;
theroots = new TColStd_HSequenceOfTransient();
for (Standard_Integer i = 1; i <= nb; i ++) {
// Resultat obtenu depuis le Graph
Interface_IntList list = agraph.SharingNums(i);
if (list.Length() > 0) theflags.SetTrue(i);
else theroots->Append (themodel->Value(i));
}
}
void Interface_ShareFlags::Evaluate
(const Interface_GeneralLib& lib, const Handle(Interface_GTool)& gtool)
{
Standard_Boolean patool = gtool.IsNull();
Standard_Integer nb = themodel->NbEntities();
if (nb == 0) return;
theroots = new TColStd_HSequenceOfTransient();
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= nb; i ++) {
// ATTENTION : Si Entite non chargee donc illisible, basculer sur son
// "Contenu" equivalent
Handle(Standard_Transient) ent = themodel->Value(i);
if (themodel->IsRedefinedContent(i)) ent = themodel->ReportEntity(i)->Content();
// Resultat obtenu via GeneralLib
Interface_EntityIterator iter;
Handle(Interface_GeneralModule) module;
Standard_Integer CN;
if (patool) {
if (lib.Select(ent,module,CN)) module->FillShared(themodel,CN,ent,iter);
} else {
if (gtool->Select(ent,module,CN)) module->FillShared(themodel,CN,ent,iter);
}
// Entites partagees par <ent> : reste a noter chacune comme "Shared"
for (iter.Start(); iter.More(); iter.Next()) {
Standard_Integer num = themodel->Number(iter.Value());
theflags.SetTrue(num); // Et Voila
}
}
for (i = 1; i <= nb; i ++) {
if (!theflags.Value(i)) theroots->Append (themodel->Value(i));
}
}
Handle(Interface_InterfaceModel) Interface_ShareFlags::Model () const
{ return themodel; }
Standard_Boolean Interface_ShareFlags::IsShared
(const Handle(Standard_Transient)& ent) const
{
Standard_Integer num = themodel->Number(ent);
if (num == 0 || num > themodel->NbEntities()) Standard_DomainError::Raise
("Interface ShareFlags : IsShared");
return theflags.Value(num);
}
Interface_EntityIterator Interface_ShareFlags::RootEntities () const
{
Interface_EntityIterator iter (theroots);
return iter;
}
Standard_Integer Interface_ShareFlags::NbRoots () const
{ return (theroots.IsNull() ? 0 : theroots->Length()); }
Handle(Standard_Transient) Interface_ShareFlags::Root
(const Standard_Integer num) const
{ return theroots->Value(num); }

View File

@@ -0,0 +1,103 @@
-- File: Interface_ShareTool.cdl
-- Created: Tue Feb 2 16:04:36 1993
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1993
class ShareTool from Interface
---Purpose : Builds the Graph of Dependancies, from the General Service
-- "Shared" -> builds for each Entity of a Model, the Shared and
-- Sharing Lists, and gives access to them.
-- Allows to complete with Implied References (which are not
-- regarded as Shared Entities, but are nevertheless Referenced),
-- this can be usefull for Reference Checking
uses Type, Transient,
Graph, HGraph, InterfaceModel, EntityIterator,
Messenger from Message,
Protocol from Interface, GeneralLib, GTool
raises DomainError, InterfaceError
is
Create (amodel : InterfaceModel; lib : GeneralLib) returns ShareTool;
---Purpose : Creates a ShareTool from a Model and builds all required data,
-- by calling the General Service Library and Modules
-- (GeneralLib given as an argument)
Create (amodel : InterfaceModel; gtool : GTool from Interface)
returns ShareTool;
---Purpose : Same a above, but GeneralLib is detained by a GTool
Create (amodel : InterfaceModel; protocol : Protocol from Interface)
returns ShareTool;
---Purpose : Same a above, but GeneralLib is defined through a Protocol
-- Protocol is used to build the working library
Create (amodel : InterfaceModel) returns ShareTool;
---Purpose : Same as above, but works with the GTool of the Model
Create (agraph : Graph) returns ShareTool;
---Purpose : Creates a ShareTool from an already defined Graph
-- Remark that the data of the Graph are copied
Create (ahgraph : HGraph) returns ShareTool;
AddImplied (me : in out; gtool : GTool from Interface);
---Purpose : Completes the Graph by Adding Implied References. Hence, they
-- are considered as Sharing References in all the other queries
Model (me) returns InterfaceModel;
---Purpose : Returns the Model used for Creation (directly or for Graph)
Graph (me) returns Graph;
---Purpose : Returns the data used by the ShareTool to work
-- Can then be used directly (read only)
---C++ : return const &
RootEntities (me) returns EntityIterator;
---Purpose : Returns the Entities which are not Shared (their Sharing List
-- is empty) in the Model
IsShared (me; ent : Transient) returns Boolean;
---Purpose : Returns True if <ent> is Shared by other Entities in the Model
Shareds (me; ent : Transient) returns EntityIterator;
---Purpose : Returns the List of Entities Shared by a given Entity <ent>
Sharings (me; ent : Transient) returns EntityIterator;
---Purpose : Returns the List of Entities Sharing a given Entity <ent>
NbTypedSharings (me; ent : Transient; atype : any Type) returns Integer;
---Purpose : Returns the count of Sharing Entities of an Entity, which
-- are Kind of a given Type
TypedSharing (me; ent : Transient; atype : any Type) returns Transient
---Purpose : Returns the Sharing Entity of an Entity, which is Kind of a
-- given Type. Allows to access a Sharing Entity of a given type
-- when there is one and only one (current case)
raises InterfaceError;
-- Error if count of Typed Sharings is zero or more then one
All (me; ent : Transient; rootlast : Boolean = Standard_True)
returns EntityIterator;
---Purpose : Returns the complete list of entities shared by <ent> at any
-- level, including <ent> itself
-- If <ent> is the Model, considers the concatenation of
-- AllShared for each root
-- If <rootlast> is True (D), the list starts with lower level
-- entities and ends by the root. Else, the root is first and
-- the lower level entities are at end
Print (me; iter : EntityIterator; S : Messenger from Message);
---Purpose : Utility method which Prints the content of an iterator
-- (by their Numbers)
fields
theHGraph : HGraph;
end ShareTool;

View File

@@ -0,0 +1,190 @@
#include <Interface_ShareTool.ixx>
#include <Interface_InterfaceError.hxx>
#include <Interface_IntList.hxx>
#include <Interface_GeneralModule.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Message_Messenger.hxx>
Interface_ShareTool::Interface_ShareTool (const Handle(Interface_InterfaceModel)& amodel,
const Interface_GeneralLib& lib)
{
theHGraph = new Interface_HGraph(amodel,lib);
}
Interface_ShareTool::Interface_ShareTool (const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_GTool)& gtool)
{
theHGraph = new Interface_HGraph(amodel,gtool);
}
Interface_ShareTool::Interface_ShareTool (const Handle(Interface_InterfaceModel)& amodel,
const Handle(Interface_Protocol)& protocol)
{
theHGraph = new Interface_HGraph(amodel,protocol);
}
Interface_ShareTool::Interface_ShareTool (const Handle(Interface_InterfaceModel)& amodel)
{
theHGraph = new Interface_HGraph(amodel);
}
Interface_ShareTool::Interface_ShareTool (const Interface_Graph& agraph)
{
theHGraph = new Interface_HGraph(agraph);
}
Interface_ShareTool::Interface_ShareTool (const Handle(Interface_HGraph)& ahgraph)
: theHGraph(ahgraph)
{}
// Ajout des "Implied" sur toutes les Entites du Graphe
void Interface_ShareTool::AddImplied (const Handle(Interface_GTool)& gtool)
{
Interface_Graph& thegraph = theHGraph->CGraph();
Standard_Integer nb = thegraph.Size();
Standard_Boolean yena = Standard_False;
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) ent = thegraph.Entity(i);
if (ent.IsNull()) continue;
Handle(Interface_GeneralModule) module; Standard_Integer CN;
if (gtool->Select(ent,module,CN)) {
Interface_EntityIterator iter;
module->ListImpliedCase(CN,ent,iter);
if (iter.NbEntities() == 0) continue;
yena = Standard_True;
thegraph.SetShare(ent);
for (iter.Start(); iter.More(); iter.Next())
thegraph.AddShared(ent,iter.Value());
}
}
if (yena) thegraph.EvalSharings();
}
Handle(Interface_InterfaceModel) Interface_ShareTool::Model () const
{ return theHGraph->Graph().Model(); }
const Interface_Graph& Interface_ShareTool::Graph () const
{ return theHGraph->Graph(); }
Interface_EntityIterator Interface_ShareTool::RootEntities () const
{ return theHGraph->Graph().RootEntities(); }
Standard_Boolean Interface_ShareTool::IsShared
(const Handle(Standard_Transient)& ent) const
{
const Interface_Graph& thegraph = theHGraph->Graph();
Interface_IntList list =
thegraph.SharingNums (thegraph.EntityNumber(ent));
return (list.Length() > 0);
}
Interface_EntityIterator Interface_ShareTool::Shareds
(const Handle(Standard_Transient)& ent) const
{ return theHGraph->Graph().Shareds(ent); }
Interface_EntityIterator Interface_ShareTool::Sharings
(const Handle(Standard_Transient)& ent) const
{ return theHGraph->Graph().Sharings(ent); }
Standard_Integer Interface_ShareTool::NbTypedSharings
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Type)& atype) const
{
Interface_Graph& thegraph = theHGraph->CGraph();
Interface_IntList list =
thegraph.SharingNums (thegraph.EntityNumber(ent));
Standard_Integer result = 0;
Standard_Integer n = list.Length();
for (Standard_Integer i = 1; i <= n; i ++) {
Handle(Standard_Transient) entsh = thegraph.Entity(list.Value(i));
if (entsh.IsNull()) continue;
if (entsh->IsKind(atype)) result ++;
}
return result;
}
Handle(Standard_Transient) Interface_ShareTool::TypedSharing
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Type)& atype) const
{
Interface_Graph& thegraph = theHGraph->CGraph();
Interface_IntList list =
thegraph.SharingNums (thegraph.EntityNumber(ent));
Handle(Standard_Transient) entresult;
Standard_Integer result = 0;
Standard_Integer n = list.Length();
for (Standard_Integer i = 1; i <= n; i ++) {
Handle(Standard_Transient) entsh = thegraph.Entity(list.Value(i));
if (entsh.IsNull()) continue;
if (entsh->IsKind(atype)) {
entresult = entsh;
result ++;
if (result > 1) Interface_InterfaceError::Raise
("Interface ShareTool : TypedSharing, more than one found");
}
}
if (result == 0) Interface_InterfaceError::Raise
("Interface ShareTool : TypedSharing, not found");
return entresult;
}
Interface_EntityIterator Interface_ShareTool::All
(const Handle(Standard_Transient)& ent, const Standard_Boolean rootlast) const
{
Handle(Interface_InterfaceModel) model = Model();
Interface_EntityIterator list;
Standard_Integer i, n0 = 0, nb = model->NbEntities();
Handle(TColStd_HArray1OfInteger) fl = new TColStd_HArray1OfInteger (0,nb);
fl->Init(0);
if (ent == model) {
// On passe les racines en revue (l ordre de base est conserve)
Interface_EntityIterator roots = RootEntities();
for (roots.Start(); roots.More(); roots.Next()) {
Interface_EntityIterator subl = All(roots.Value(),rootlast);
for (subl.Start(); subl.More(); subl.Next()) {
Standard_Integer nm = model->Number(subl.Value());
if (fl->Value(nm) > 0) continue;
n0 ++; fl->SetValue(nm,n0);
}
}
// Attention, y a t il des oublis ?
for (i = 1; i <= nb; i ++)
if (fl->Value(i) == 0) { n0 ++; fl->SetValue(i,n0); }
} else {
Handle(TColStd_HSequenceOfTransient) sq = new TColStd_HSequenceOfTransient();
sq->Append(ent);
// processus de type file
for (i = 1; i <= sq->Length(); i ++) { // Length croit
Handle(Standard_Transient) en = sq->Value(i);
Standard_Integer num = model->Number(en);
if (fl->Value(num) != 0) continue; // deja vu
n0 ++; fl->SetValue (num,n0);
Interface_EntityIterator sh = Shareds(en);
sq->Append (sh.Content());
}
}
// Reste a constituer la liste, retourner si necessaire
Handle(TColStd_HArray1OfInteger) ord = new TColStd_HArray1OfInteger (0,nb);
ord->Init(0);
for (i = 1; i <= nb; i ++) { n0 = fl->Value(i); ord->SetValue (n0,i); }
if (rootlast && ent != model) for (i = 1; i <= nb; i ++)
{ if (ord->Value(i) != 0) list.AddItem (model->Value(ord->Value(i))); }
else for (i = nb; i > 0; i --)
{ if (ord->Value(i) != 0) list.AddItem (model->Value(ord->Value(i))); }
return list;
}
void Interface_ShareTool::Print
(const Interface_EntityIterator& iter, const Handle(Message_Messenger)& S) const
{
S << " Nb.Entities : " << iter.NbEntities() << " : ";
for (iter.Start(); iter.More(); iter.Next()) {
Handle(Standard_Transient) ent = iter.Value();
S << " n0/id:"; Model()->Print(ent,S);
}
S<<endl;
}

View File

@@ -0,0 +1,26 @@
-- File: Interface_SignLabel.cdl
-- Created: Wed May 20 18:28:59 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class SignLabel from Interface inherits SignText from MoniTool
---Purpose : Signature to give the Label from the Model
uses Transient, AsciiString from TCollection
is
Create returns mutable SignLabel;
Name (me) returns CString;
---Purpose : Returns "Entity Label"
Text (me; ent : any Transient; context : any Transient)
returns AsciiString from TCollection;
---Purpose : Considers context as an InterfaceModel and returns the Label
-- computed by it
end SignLabel;

View File

@@ -0,0 +1,22 @@
#include <Interface_SignLabel.ixx>
#include <Interface_InterfaceModel.hxx>
#include <TCollection_HAsciiString.hxx>
Interface_SignLabel::Interface_SignLabel () { }
Standard_CString Interface_SignLabel::Name () const
{ return "Entity Label"; }
TCollection_AsciiString Interface_SignLabel::Text
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Transient)& context) const
{
TCollection_AsciiString atext;
Handle(Interface_InterfaceModel) model =
Handle(Interface_InterfaceModel)::DownCast(context);
if (ent.IsNull() || model.IsNull()) return atext;
Handle(TCollection_HAsciiString) lab = model->StringLabel (ent);
if (!lab.IsNull()) atext = lab->String();
return atext;
}

View File

@@ -0,0 +1,38 @@
-- File: Interface_SignType.cdl
-- Created: Wed Feb 4 12:40:40 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
deferred class SignType from Interface inherits SignText from MoniTool
---Purpose : Provides the basic service to get a type name, according
-- to a norm
-- It can be used for other classes (general signatures ...)
uses CString, Transient, AsciiString, InterfaceModel
is
-- Name (me) returns CString is deferred; already in SignText
---Purpose : Returns an identification of the Signature (a word), given at
-- initialization time
Text (me; ent : any Transient; context : any Transient)
returns AsciiString from TCollection;
---Purpose : Specialised to consider context as an InterfaceModel
Value (me; ent : any Transient; model : InterfaceModel)
returns CString is deferred;
---Purpose : Returns the Signature for a Transient object. It is specific
-- of each sub-class of Signature. For a Null Handle, it should
-- provide ""
-- It can work with the model which contains the entity
ClassName (myclass; typnam : CString) returns CString;
---Purpose : From a CDL Type Name, returns the Class part (package dropped)
-- WARNING : buffered, to be immediately copied or printed
end SignType;

View File

@@ -0,0 +1,23 @@
#include <Interface_SignType.ixx>
TCollection_AsciiString Interface_SignType::Text
(const Handle(Standard_Transient)& ent,
const Handle(Standard_Transient)& context) const
{
TCollection_AsciiString atext;
Handle(Interface_InterfaceModel) model =
Handle(Interface_InterfaceModel)::DownCast(context);
if (ent.IsNull() || model.IsNull()) return atext;
atext.AssignCat (Value(ent,model));
return atext;
}
Standard_CString Interface_SignType::ClassName
(const Standard_CString typnam)
{
char* tn =(char*) typnam;
for (int i = 0; tn[i] != '\0'; i ++) {
if (tn[i] == '_') return &tn[i+1];
}
return tn;
}

View File

@@ -0,0 +1,279 @@
-- File: Interface_Static.cdl
-- Created: Fri Dec 8 08:36:26 1995
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1995
class Static from Interface inherits TypedValue from Interface
---Purpose : This class gives a way to manage meaningfull static variables,
-- used as "global" parameters in various procedures.
--
-- A Static brings a specification (its type, constraints if any)
-- and a value. Its basic form is a string, it can be specified
-- as integer or real or enumerative string, and queried as such.
-- Its string content, which is a Handle(HAsciiString) can be
-- shared by other data structures, hence gives a direct on line
-- access to its value.
--
-- All this description is inherited from TypedValue
--
-- A Static can be given an initial value, it can be filled from,
-- either a set of Resources (an applicative feature which
-- accesses and manages parameter files), or environment or
-- internal definition : these define families of Static.
-- In addition, it supports a status for reinitialisation : an
-- initialisation procedure can ask if the value of the Static
-- has changed from its last call, in this case does something
-- then marks the Status "uptodate", else it does nothing.
--
-- Statics are named and recorded then accessed in an alphabetic
-- dictionary
uses CString, Type from Standard,
Messenger from Message,
AsciiString from TCollection, HAsciiString from TCollection,
HSequenceOfAsciiString from TColStd, HArray1OfAsciiString from TColStd,
HSequenceOfHAsciiString from TColStd,
DictionaryOfInteger from Dico,
ParamType from Interface , StaticSatisfies from Interface
raises InterfaceError
is
Create (family, name : CString;
type : ParamType from Interface = Interface_ParamText;
init : CString = "") returns mutable Static
---Purpose : Creates and records a Static, with a family and a name
-- family can report to a name of ressource or to a system or
-- internal definition. The name must be unique.
--
-- type gives the type of the parameter, default is free text
-- Also available : Integer, Real, Enum, Entity (i.e. Object)
-- More precise specifications, titles, can be given to the
-- Static once created
--
-- init gives an initial value. If it is not given, the Static
-- begin as "not set", its value is empty
raises InterfaceError;
-- Error if <name> is already recorded, or <type> not supported
-- See also class method Init
Create (family, name : CString; other : Static) returns mutable Static;
---Purpose : Creates a new Static with same definition as another one
-- (value is copied, except for Entity : it remains null)
PrintStatic (me; S : Messenger from Message);
---Purpose : Writes the properties of a
-- parameter in the diagnostic file. These include:
-- - Name
-- - Family,
-- - Wildcard (if it has one)
-- - Current status (empty string if it was updated or
-- if it is the original one)
-- - Value
Family (me) returns CString;
---Purpose : Returns the family. It can be : a resource name for applis,
-- an internal name between : $e (environment variables),
-- $l (other, purely local)
SetWild (me : mutable; wildcard : Static);
---Purpose : Sets a "wild-card" static : its value will be considered
-- if <me> is not properly set. (reset by set a null one)
Wild (me) returns Static;
---Purpose : Returns the wildcard static, which can be (is most often) null
-- -- Update Status -- --
SetUptodate (me : mutable);
---Purpose : Records a Static has "uptodate", i.e. its value has been taken
-- into account by a reinitialisation procedure
-- This flag is reset at each successful SetValue
UpdatedStatus (me) returns Boolean;
---Purpose : Returns the status "uptodate"
-- --
-- -- Class methods : dictionary of statics -- --
-- --
Init (myclass; family, name : CString;
type : ParamType from Interface;
init : CString = "") returns Boolean;
---Purpose : Declares a new Static (by calling its constructor)
-- If this name is already taken, does nothing and returns False
-- Else, creates it and returns True
-- For additional definitions, get the Static then edit it
Init (myclass; family, name : CString;
type : Character;
init : CString = "") returns Boolean;
---Purpose : As Init with ParamType, but type is given as a character
-- This allows a simpler call
-- Types : 'i' Integer, 'r' Real, 't' Text, 'e' Enum, 'o' Object
-- '=' for same definition as, <init> gives the initial Static
-- Returns False if <type> does not match this list
Static (myclass; name : CString) returns mutable Static;
---Purpose : Returns a Static from its name. Null Handle if not present
IsPresent (myclass; name : CString) returns Boolean;
---Purpose : Returns True if a Static named <name> is present, False else
CDef (myclass; name : CString; part : CString) returns CString;
---Purpose : Returns a part of the definition of a Static, as a CString
-- The part is designated by its name, as a CString
-- If the required value is not a string, it is converted to a
-- CString then returned
-- If <name> is not present, or <part> not defined for <name>,
-- this function returns an empty string
--
-- Allowed parts for CDef :
-- family : the family
-- type : the type ("integer","real","text","enum")
-- label : the label
-- satis : satisfy function name if any
-- rmin : minimum real value
-- rmax : maximum real value
-- imin : minimum integer value
-- imax : maximum integer value
-- enum nn (nn : value of an integer) : enum value for nn
-- unit : unit definition for a real
IDef (myclass; name : CString; part : CString) returns Integer;
---Purpose : Returns a part of the definition of a Static, as an Integer
-- The part is designated by its name, as a CString
-- If the required value is not a string, returns zero
-- For a Boolean, 0 for false, 1 for true
-- If <name> is not present, or <part> not defined for <name>,
-- this function returns zero
--
-- Allowed parts for IDef :
-- imin, imax : minimum or maximum integer value
-- estart : starting number for enum
-- ecount : count of enum values (starting from estart)
-- ematch : exact match status
-- eval val : case determined from a string
-- Querying and Setting --
-- (must useful ones; for other, see methods of instance above)
IsSet (myclass; name : CString; proper : Boolean = Standard_True)
returns Boolean;
---Purpose : Returns True if <name> is present AND set
-- <proper> True (D) : considers this item only
-- <proper> False : if not set and attached to a wild-card,
-- considers this wild-card
CVal (myclass; name : CString) returns CString;
---Purpose : Returns the value of the
-- parameter identified by the string name.
-- If the specified parameter does not exist, an empty
-- string is returned.
-- Example
-- Interface_Static::CVal("write.step.schema");
-- which could return:
-- "AP214"
IVal (myclass; name : CString) returns Integer;
---Purpose : Returns the integer value of
-- the translation parameter identified by the string name.
-- Returns the value 0 if the parameter does not exist.
-- Example
-- Interface_Static::IVal("write.step.schema");
-- which could return: 3
RVal (myclass; name : CString) returns Real;
---Purpose : Returns the value of a static
-- translation parameter identified by the string name.
-- Returns the value 0.0 if the parameter does not exist.
SetCVal (myclass; name : CString; val : CString) returns Boolean;
---Purpose : Modifies the value of the
-- parameter identified by name. The modification is specified
-- by the string val. false is returned if the parameter does not exist.
-- Example
-- Interface_Static::SetCVal
-- ("write.step.schema","AP203")
-- This syntax specifies a switch from the default STEP 214 mode to STEP 203 mode.
SetIVal (myclass; name : CString; val : Integer) returns Boolean;
---Purpose : Modifies the value of the
-- parameter identified by name. The modification is specified
-- by the integer value val. false is returned if the
-- parameter does not exist.
-- Example
-- Interface_Static::SetIVal
-- ("write.step.schema", 3)
-- This syntax specifies a switch from the default STEP 214 mode to STEP 203 mode.S
SetRVal (myclass; name : CString; val : Real) returns Boolean;
---Purpose : Modifies the value of a
-- translation parameter. false is returned if the
-- parameter does not exist. The modification is specified
-- by the real number value val.
Update (myclass; name : CString) returns Boolean;
---Purpose : Sets a Static to be "uptodate"
-- Returns False if <name> is not present
-- This status can be used by a reinitialisation procedure to
-- rerun if a value has been changed
IsUpdated (myclass; name : CString) returns Boolean;
---Purpose : Returns the status "uptodate" from a Static
-- Returns False if <name> is not present
Items (myclass; mode : Integer = 0; criter : CString = "") returns HSequenceOfHAsciiString;
---Purpose : Returns a list of names of statics :
-- <mode> = 0 (D) : criter is for family
-- <mode> = 1 : criter is regexp on names, takes final items
-- (ignore wild cards)
-- <mode> = 2 : idem but take only wilded, not final items
-- <mode> = 3 : idem, take all items matching criter
-- idem + 100 : takes only non-updated items
-- idem + 200 : takes only updated items
-- criter empty (D) : returns all names
-- else returns names which match the given criter
-- Remark : families beginning by '$' are not listed by criter ""
-- they are listed only by criter "$"
--
-- This allows for instance to set new values after having loaded
-- or reloaded a resource, then to update them as required
-- A special class method : initialisation of standard statics
Standards (myclass);
---Purpose : Initializes all standard static parameters, which can be used
-- by every function. statics specific of a norm or a function
-- must be defined around it
fields
thefamily : AsciiString;
thename : AsciiString;
thelabel : AsciiString;
thetype : ParamType from Interface;
theotyp : Type from Standard; -- for object
thewild : Static;
thelims : Integer; -- status for integer/enum/real limits
theintlow : Integer;
theintup : Integer;
therealow : Real;
therealup : Real;
theunidef : AsciiString;
theenums : HArray1OfAsciiString from TColStd;
theeadds : DictionaryOfInteger;
thesatisf : StaticSatisfies;
thesatisn : AsciiString;
theupdate : Boolean;
theival : Integer;
thehval : HAsciiString from TCollection;
theoval : Transient;
end Static;

View File

@@ -0,0 +1,397 @@
#include <Interface_Static.ixx>
#include <Dico_DictionaryOfInteger.hxx>
#include <Dico_DictionaryOfTransient.hxx>
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
#include <Dico_IteratorOfDictionaryOfInteger.hxx>
#include <OSD_Path.hxx>
#include <stdio.h>
static char defmess[30];
// Fonctions Satisfies offertes en standard ...
//svv #2
//static Standard_Boolean StaticPath(const Handle(TCollection_HAsciiString)& val)
//{
// OSD_Path apath;
// return apath.IsValid (TCollection_AsciiString(val->ToCString()));
//}
Interface_Static::Interface_Static
(const Standard_CString family, const Standard_CString name,
const Interface_ParamType type, const Standard_CString init)
: Interface_TypedValue (name,type,init) ,
thefamily (family) ,
theupdate (Standard_True) { }
Interface_Static::Interface_Static
(const Standard_CString family, const Standard_CString name,
const Handle(Interface_Static)& other)
: Interface_TypedValue (name, other->Type(), "") ,
thefamily (family) ,
theupdate (Standard_True)
{
switch (Type()) {
case Interface_ParamInteger : {
Standard_Integer lim;
if (other->IntegerLimit (Standard_True ,lim)) SetIntegerLimit (Standard_True ,lim);
if (other->IntegerLimit (Standard_False,lim)) SetIntegerLimit (Standard_False,lim);
}
break;
case Interface_ParamReal : {
Standard_Real lim;
if (other->RealLimit (Standard_True ,lim)) SetRealLimit (Standard_True ,lim);
if (other->RealLimit (Standard_False,lim)) SetRealLimit (Standard_False,lim);
SetUnitDef (other->UnitDef());
}
break;
case Interface_ParamEnum : {
Standard_Boolean match; Standard_Integer e0,e1,i;
other->EnumDef (e0,e1,match);
StartEnum (e0,match);
// if (e1 >= e0) theenums = new TColStd_HArray1OfAsciiString(e0,e1);
for (i = e0; i <= e1; i ++)
AddEnum (other->EnumVal(i));
}
break;
case Interface_ParamIdent :
SetObjectType (other->ObjectType());
break;
default : break;
}
if (other->IsSetValue()) SetCStringValue (other->CStringValue());
}
// ## Print ##
void Interface_Static::PrintStatic (const Handle(Message_Messenger)& S) const
{
S<<"--- Static Value : "<<Name()<<" Family:"<<Family();
Print (S);
if (!thewild.IsNull())
S<<" -- Attached to wild-card : "<<thewild->Name()<<endl;
S<<"--- Actual status : "<<(theupdate ? "" : "original")<<" Value : ";
if (thesatisf) S<<" -- Specific Function for Satisfies : "<<thesatisn.ToCString()<<endl;
}
// ######### COMPLEMENTS ##########
Standard_CString Interface_Static::Family () const
{
return thefamily.ToCString();
}
Handle(Interface_Static) Interface_Static::Wild () const
{
return thewild;
}
void Interface_Static::SetWild (const Handle(Interface_Static)& wild)
{
thewild = wild;
}
// ######### UPDATE ##########
void Interface_Static::SetUptodate ()
{
theupdate = Standard_True;
}
Standard_Boolean Interface_Static::UpdatedStatus () const
{
return theupdate;
}
// #######################################################################
// ######### DICTIONNAIRE DES STATICS (static sur Static) ##########
Standard_Boolean Interface_Static::Init
(const Standard_CString family, const Standard_CString name,
const Interface_ParamType type, const Standard_CString init)
{
if (name[0] == '\0') return Standard_False;
if (MoniTool_TypedValue::Stats()->HasItem(name)) return Standard_False;
Handle(Interface_Static) item;
if (type == Interface_ParamMisc) {
Handle(Interface_Static) other = Interface_Static::Static(init);
if (other.IsNull()) return Standard_False;
item = new Interface_Static (family,name,other);
}
else item = new Interface_Static (family,name,type,init);
MoniTool_TypedValue::Stats()->SetItem (name,item);
return Standard_True;
}
Standard_Boolean Interface_Static::Init
(const Standard_CString family, const Standard_CString name,
const Standard_Character type, const Standard_CString init)
{
Interface_ParamType epyt;
switch (type) {
case 'e' : epyt = Interface_ParamEnum; break;
case 'i' : epyt = Interface_ParamInteger; break;
case 'o' : epyt = Interface_ParamIdent; break;
case 'p' : epyt = Interface_ParamText; break;
case 'r' : epyt = Interface_ParamReal; break;
case 't' : epyt = Interface_ParamText; break;
case '=' : epyt = Interface_ParamMisc; break;
case '&' : {
Handle(Interface_Static) unstat = Interface_Static::Static(name);
if (unstat.IsNull()) return Standard_False;
// Editions : init donne un petit texte d edition, en 2 termes "cmd var" :
// imin <ival> imax <ival> rmin <rval> rmax <rval> unit <def>
// enum <from> ematch <from> eval <cval>
Standard_Integer i,iblc = 0;
for (i = 0; init[i] != '\0'; i ++) if (init[i] == ' ') iblc = i+1;
// Reconnaissance du sous-cas et aiguillage
if (init[0] == 'i' && init[2] == 'i')
unstat->SetIntegerLimit (Standard_False,atoi(&init[iblc]));
else if (init[0] == 'i' && init[2] == 'a')
unstat->SetIntegerLimit (Standard_True ,atoi(&init[iblc]));
else if (init[0] == 'r' && init[2] == 'i')
unstat->SetRealLimit (Standard_False,atof(&init[iblc]));
else if (init[0] == 'r' && init[2] == 'a')
unstat->SetRealLimit (Standard_True ,atof(&init[iblc]));
else if (init[0] == 'u')
unstat->SetUnitDef (&init[iblc]);
else if (init[0] == 'e' && init[1] == 'm')
unstat->StartEnum (atoi(&init[iblc]),Standard_True);
else if (init[0] == 'e' && init[1] == 'n')
unstat->StartEnum (atoi(&init[iblc]),Standard_False);
else if (init[0] == 'e' && init[1] == 'v')
unstat->AddEnum (&init[iblc]);
else return Standard_False;
return Standard_True;
}
default : return Standard_False;
}
if (!Interface_Static::Init (family,name,epyt,init)) return Standard_False;
if (type != 'p') return Standard_True;
Handle(Interface_Static) stat = Interface_Static::Static(name);
//NT stat->SetSatisfies (StaticPath,"Path");
if (!stat->Satisfies(stat->HStringValue())) stat->SetCStringValue("");
return Standard_True;
}
Handle(Interface_Static) Interface_Static::Static
(const Standard_CString name)
{
Handle(Interface_Static) result;
MoniTool_TypedValue::Stats()->GetItem (name,result);
return result;
}
Standard_Boolean Interface_Static::IsPresent (const Standard_CString name)
{
return MoniTool_TypedValue::Stats()->HasItem (name);
}
Standard_CString Interface_Static::CDef
(const Standard_CString name, const Standard_CString part)
{
if (!part || part[0] == '\0') return "";
Handle(Interface_Static) stat = Interface_Static::Static(name);
if (stat.IsNull()) return "";
if (part[0] == 'f' && part[1] == 'a') return stat->Family();
if (part[0] == 'l' && part[1] == 'a') return stat->Label();
if (part[0] == 's' && part[1] == 'a') return stat->SatisfiesName();
if (part[0] == 't' && part[1] == 'y') {
Interface_ParamType typ = stat->Type();
if (typ == Interface_ParamInteger) return "integer";
if (typ == Interface_ParamReal) return "real";
if (typ == Interface_ParamText) return "text";
if (typ == Interface_ParamEnum) return "enum";
return "?type?";
}
if (part[0] == 'e') {
Standard_Integer nume = 0;
sscanf (part,"%s %d",defmess,&nume);
return stat->EnumVal(nume);
}
if (part[0] == 'i') {
Standard_Integer ilim;
if (!stat->IntegerLimit((part[2] == 'a'),ilim)) return "";
sprintf(defmess,"%d",ilim); return defmess;
}
if (part[0] == 'r') {
Standard_Real rlim;
if (!stat->RealLimit((part[2] == 'a'),rlim)) return "";
sprintf(defmess,"%f",rlim); return defmess;
}
if (part[0] == 'u') return stat->UnitDef();
return "";
}
Standard_Integer Interface_Static::IDef
(const Standard_CString name, const Standard_CString part)
{
if (!part || part[0] == '\0') return 0;
Handle(Interface_Static) stat = Interface_Static::Static(name);
if (stat.IsNull()) return 0;
if (part[0] == 'i') {
Standard_Integer ilim;
if (!stat->IntegerLimit((part[2] == 'a'),ilim)) return 0;
return ilim;
}
if (part[0] == 'e') {
Standard_Integer startcase,endcase; Standard_Boolean match;
stat->EnumDef (startcase,endcase,match);
if (part[1] == 's') return startcase;
if (part[1] == 'c') return (endcase - startcase + 1);
if (part[1] == 'm') return (match ? 1 : 0);
if (part[1] == 'v') {
char vale[50];
sscanf (part,"%s %s",defmess,vale);
return stat->EnumCase (vale);
}
}
return 0;
}
// ########## VALEUR COURANTE ###########
Standard_Boolean Interface_Static::IsSet
(const Standard_CString name, const Standard_Boolean proper)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) return Standard_False;
if (item->IsSetValue()) return Standard_True;
if (proper) return Standard_False;
item = item->Wild();
return item->IsSetValue();
}
Standard_CString Interface_Static::CVal (const Standard_CString name)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) {
#ifdef DEB
cout << "Warning: Interface_Static::CVal: incorrect parameter " << name << endl;
#endif
return "";
}
return item->CStringValue();
}
Standard_Integer Interface_Static::IVal (const Standard_CString name)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) {
#ifdef DEB
cout << "Warning: Interface_Static::IVal: incorrect parameter " << name << endl;
#endif
return 0;
}
return item->IntegerValue();
}
Standard_Real Interface_Static::RVal (const Standard_CString name)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) {
#ifdef DEB
cout << "Warning: Interface_Static::RVal: incorrect parameter " << name << endl;
#endif
return 0.0;
}
return item->RealValue();
}
Standard_Boolean Interface_Static::SetCVal
(const Standard_CString name, const Standard_CString val)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) return Standard_False;
return item->SetCStringValue(val);
}
Standard_Boolean Interface_Static::SetIVal
(const Standard_CString name, const Standard_Integer val)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) return Standard_False;
if (!item->SetIntegerValue(val)) return Standard_False;
return Standard_True;
}
Standard_Boolean Interface_Static::SetRVal
(const Standard_CString name, const Standard_Real val)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) return Standard_False;
return item->SetRealValue(val);
}
// UPDATE
Standard_Boolean Interface_Static::Update (const Standard_CString name)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) return Standard_False;
item->SetUptodate();
return Standard_True;
}
Standard_Boolean Interface_Static::IsUpdated (const Standard_CString name)
{
Handle(Interface_Static) item = Interface_Static::Static(name);
if (item.IsNull()) return Standard_False;
return item->UpdatedStatus();
}
Handle(TColStd_HSequenceOfHAsciiString) Interface_Static::Items
(const Standard_Integer mode, const Standard_CString criter)
{
Standard_Integer modup = (mode / 100); // 0 any, 1 non-update, 2 update
Handle(TColStd_HSequenceOfHAsciiString) list =
new TColStd_HSequenceOfHAsciiString();
Dico_IteratorOfDictionaryOfTransient iter(MoniTool_TypedValue::Stats());
for (iter.Start(); iter.More(); iter.Next()) {
Handle(Interface_Static) item =
Handle(Interface_Static)::DownCast(iter.Value());
if (item.IsNull()) continue;
Standard_Boolean ok = Standard_True;
if (criter[0] == '$' && criter[1] == '\0') {
if ( (item->Family())[0] != '$') ok = Standard_False;
} else if (criter[0] != '\0') {
if (strcmp(criter, item->Family())) continue;
ok = Standard_True;
} else { // tous ... sauf famille a $
if (item->Family()[0] == '$') continue;
}
if (ok && (modup == 1)) ok = !item->UpdatedStatus();
if (ok && (modup == 2)) ok = item->UpdatedStatus();
if (ok) list->Append (new TCollection_HAsciiString (iter.Name()) );
}
return list;
}

View File

@@ -0,0 +1,8 @@
#ifndef _Interface_StaticSatisfies_HeaderFile
#define _Interface_StaticSatisfies_HeaderFile
#include <Handle_TCollection_HAsciiString.hxx>
typedef Standard_Boolean (*Interface_StaticSatisfies) (const Handle(TCollection_HAsciiString)& val);
#endif

View File

@@ -0,0 +1,107 @@
//#74 rln 10.03.99 S4135: new parameters, values and default values
// gka 10.04.99 S4136: eliminate parameter 'lastpreci'
//S4181 pdn 23.04.99: adding new parameter handling writing of elementary surfaces
#include <Interface_Static.hxx>
#include <Message_MsgFile.hxx>
#include <TCollection_ExtendedString.hxx>
//tatouage de la librairie
#include <Precision.hxx>
#include <stdio.h>
static int deja = 0;
void Interface_Static::Standards ()
{
if (deja) return; deja = 1;
// read precision
//#74 rln 10.03.99 S4135: new values and default value
Interface_Static::Init ("XSTEP","read.precision.mode",'e',"");
Interface_Static::Init ("XSTEP","read.precision.mode",'&',"ematch 0");
Interface_Static::Init ("XSTEP","read.precision.mode",'&',"eval File");
Interface_Static::Init ("XSTEP","read.precision.mode",'&',"eval User");
Interface_Static::SetIVal ("read.precision.mode",0);
Interface_Static::Init ("XSTEP","read.precision.val",'r',"1.e-03");
Interface_Static::Init ("XSTEP","read.maxprecision.mode",'e',"");
Interface_Static::Init ("XSTEP","read.maxprecision.mode",'&',"ematch 0");
Interface_Static::Init ("XSTEP","read.maxprecision.mode",'&',"eval Preferred");
Interface_Static::Init ("XSTEP","read.maxprecision.mode",'&',"eval Forced");
Interface_Static::SetIVal ("read.maxprecision.mode",0);
Interface_Static::Init ("XSTEP","read.maxprecision.val",'r',"1.");
// encode regularity
// negatif ou nul : ne rien faire. positif : on y va
Interface_Static::Init ("XSTEP","read.encoderegularity.angle",'r',"0.01");
// compute surface curves
// 0 : par defaut. 2 : ne garder que le 2D. 3 : ne garder que le 3D
//gka S4054
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", 'e',"");
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", '&',"ematch -3");
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", '&',"eval 3DUse_Forced");
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", '&',"eval 2DUse_Forced");
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", '&',"eval ?");
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", '&',"eval Default");
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", '&',"eval ?");
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", '&',"eval 2DUse_Preferred");
Interface_Static::Init("XSTEP" ,"read.surfacecurve.mode", '&',"eval 3DUse_Preferred");
Interface_Static::SetIVal ("read.surfacecurve.mode",0);
// write precision
Interface_Static::Init ("XSTEP","write.precision.mode",'e',"");
Interface_Static::Init ("XSTEP","write.precision.mode",'&',"ematch -1");
Interface_Static::Init ("XSTEP","write.precision.mode",'&',"eval Min");
Interface_Static::Init ("XSTEP","write.precision.mode",'&',"eval Average");
Interface_Static::Init ("XSTEP","write.precision.mode",'&',"eval Max");
Interface_Static::Init ("XSTEP","write.precision.mode",'&',"eval User");
Interface_Static::SetIVal ("write.precision.mode",0);
Interface_Static::Init ("XSTEP","write.precision.val",'r',"1.e-03");
// Write surface curves
// 0: write (defaut), 1: do not write, 2: write except for analytical surfaces
Interface_Static::Init("XSTEP" ,"write.surfacecurve.mode", 'e',"");
Interface_Static::Init("XSTEP" ,"write.surfacecurve.mode", '&',"ematch 0");
Interface_Static::Init("XSTEP" ,"write.surfacecurve.mode", '&',"eval Off");
Interface_Static::Init("XSTEP" ,"write.surfacecurve.mode", '&',"eval On");
// Interface_Static::Init("XSTEP" ,"write.surfacecurve.mode", '&',"eval NoAnalytic");
Interface_Static::SetIVal ("write.surfacecurve.mode",1);
// lastpreci : pour recuperer la derniere valeur codee (cf XSControl)
// (0 pour dire : pas codee)
//:S4136 Interface_Static::Init("std" ,"lastpreci", 'r',"0.");
// **** MESSAGERIE DE BASE ****
// Chargement "manuel" au cas ou les fichiers, env, etc sont KO
Message_MsgFile::AddMsg ("XSTEP_1","Beginning of IGES file memory loading.");
Message_MsgFile::AddMsg ("XSTEP_2","File opening error");
Message_MsgFile::AddMsg ("XSTEP_3","Reason : No such file or directory");
Message_MsgFile::AddMsg ("XSTEP_4","Reason : Not enough space");
Message_MsgFile::AddMsg ("XSTEP_5","Reason : Permission denied");
Message_MsgFile::AddMsg ("XSTEP_6","Reason : Too many open files");
Message_MsgFile::AddMsg ("XSTEP_7","Reason : Undetermined");
Message_MsgFile::AddMsg ("XSTEP_8","End of loading IGES file to memory (Elapsed time : %s).");
Message_MsgFile::AddMsg ("XSTEP_11","Internal error during the file header reading. The process continues");
Message_MsgFile::AddMsg ("XSTEP_13","Internal error during the reading of the entity %d");
Message_MsgFile::AddMsg ("XSTEP_14","Internal error during the reading of the entity %d (parameter %d)");
Message_MsgFile::AddMsg ("XSTEP_15","Total number of loaded entities : %d.");
Message_MsgFile::AddMsg ("XSTEP_16","Beginning of the model loading");
Message_MsgFile::AddMsg ("XSTEP_17","End of the model loading");
Message_MsgFile::AddMsg ("XSTEP_21","Number of ignored Null Entities : %d");
Message_MsgFile::AddMsg ("XSTEP_22","Entity %s : unknown");
Message_MsgFile::AddMsg ("XSTEP_23","Entity %s, Type %s : recovered");
Message_MsgFile::AddMsg ("XSTEP_24","Report : %d unknown entities");
Message_MsgFile::AddMsg ("XSTEP_25","Number of fail in memory loading : %d.");
Message_MsgFile::AddMsg ("XSTEP_26","Number of warning in memory loading : %d.");
// Chargement du vrai fichier langue
Message_MsgFile::LoadFromEnv ("CSF_XSMessage","XSTEP");
}

View File

@@ -0,0 +1,79 @@
// Macros to help static Handles not to be "constructed" before main run
// In order to avoid it, the Handle to be statically reserved is encapsulated
// in a structure itself designated through a Null Pointer :
// Only the pointer is declared static, and initialized to NULL : then,
// there is no routine to call for static construction
// Remember that the objet designated by a static Handle should not be created
// in the static declaration, but must anyway be created, during main run,
// once before its first use : this is the initialization step.
// This set of macros allows user to simply declare and use "static" Handles.
// It is available once having included this file :
// ***************************************************
// #include <Interface_Statics.hxx>
// Static construction is replaced by using the macro StaticHandle :
// ***************************************************
// Old statement : static Handle(pk_class) object;
// Is replaced by : StaticHandle(pk_class,object);
// which creates a null pointer called 'object_s' and typed 'pk_class_struc'
// For first initialisation and use, several ways are available, all of them
// give an access to the Handle through a reference.
// It is required to initialize the static structure once, the macros Init*
// assume that it is created once and only once, even if they are called
// more than once.
// It is possible : to create the object at initialization time by a macro,
// or to create it after the macro call through its reference :
// ***************************************************
// Old statement (in a routine, not static) :
// if (object.IsNull()) object = new pk_class (..args if any..);
// can be maintained, but preceeded by an initialization :
// InitHandle(pk_class,object); // -> Null Handle
// ***************************************************
// or it can be replaced by a direct formula (creation called only once) :
// InitHandleVoid(pk_class,object); // for a void constructor
// or InitHandleArgs(pk_class,object,(..args..));
// (the arglist between embedded parentheses)
// or InitHandleVal(pk_class,object,val); // i.e. object = val;
// To simply use this pseudo-static object, consider
// either the static variable object_s->H
// ***************************************************
// or take it by the macro (which does not initialize it)
// UseHandle(pk_class,object);
// Declaration of a static Handle : first use for a given type
#define StaticHandle(type,var) static struct type##_struc { Handle(type) H; } *var##_s = NULL
// Another declaration for an already declared type (with StaticHandle)
#define StaticHandleA(type,var) static struct type##_struc *var##_s = NULL
// Using it (IT MUST HAVE BEEN FORMERLY INITIALIZED)
#define UseHandle(type,var) Handle(type)& var = var##_s->H
// Initializing it (as Null Handle)
#define InitHandle(type,var) \
if(!var##_s) { var##_s=new type##_struc; }\
Handle(type)& var = var##_s->H;
// Initializing it and Creating it by a Void Constructor
#define InitHandleVoid(type,var) \
if(!var##_s) { var##_s=new type##_struc; var##_s->H=new type; }\
Handle(type)& var = var##_s->H;
// Initializing it and Creating it by a Constructor with Arguments
// (give them grouped in their parentheses)
#define InitHandleArgs(type,var,args) \
if(!var##_s) { var##_s=new type##_struc; var##_s->H=new type args; }\
Handle(type)& var = var##_s->H;
// Initializing it from an already determined Value
#define InitHandleVal(type,var,value) \
if(!var##_s) { var##_s=new type##_struc; var##_s->H=value; }\
Handle(type)& var = var##_s->H;

View File

@@ -0,0 +1,70 @@
// Interface_Translates.hxx
// This set of macros provides some simple translation formula, i.e.
// from a HSequence to an HArray and reverse
// Include files for the types of HSequence and HArray1 remain to be called
// Other kinds of translations remain to be completely written
// from HSequence to HArray1 : creates the HArray1 if HSequence not empty
// from HArray1 to HSequence : the HSequence must have been already created
// SeqToArray(seq,arr,TColStd_HArray1OfReal) will :
// consider <seq> input HSequence (here, must be TColStd_HSequenceOfReal)
// consider <arr> output HArray1, declared but to be created
// do nothing if <seq> is null or empty; else
// create <arr> as TColStd_HArrayOfReal(1,seq->Length())
// then fill each value of <arr> with the homologous from <seq>
// SeqToArrayFrom(seq,arr,TColStd_HArray1OfReal,lowind) will :
// consider <lowind> as an Integer (variable or constant) which defines
// the desired lower index if different from one
// do the same thing as SeqToArray if <lowind> equates 1
// else fixes lower index of <arr> as <lowind>
// SeqToArrayCast(seq,arr,Interface_HArray1OfHAsciiString,TCollection_HAsciiString) will :
// do as SeqToArray, but array values are Handles to be casted
// (if <seq> does not work with the same type, e.g. Standard_Transient)
// fill array value by the result of DownCast of the type <typent>
// ArrayToSeq(arr,seq) will fill <seq> a sequence with the items of <arr> a
// HArray1. <seq> and <arr> are already created (<seq> can be empty or not)
// Items from <arr> are considered as compatible with items from <seq>
// (no DownCast required for Handles)
#define SeqToArrayFrom(seq,arr,typarr,lowind) \
if (!seq.IsNull()) {\
Standard_Integer numseq, lenseq = seq->Length();\
if (lenseq > 0) {\
arr = new typarr (lowind,lenseq+1-lowind);\
for (numseq = 1; numseq <= lenseq; numseq ++)\
arr->SetValue (numseq+1-lowind, seq->Value(numseq));\
}\
}
#define SeqToArray(seq,arr,typarr) \
if (!seq.IsNull()) {\
Standard_Integer numseq, lenseq = seq->Length();\
if (lenseq > 0) {\
arr = new typarr (1,lenseq);\
for (numseq = 1; numseq <= lenseq; numseq ++)\
arr->SetValue (numseq, seq->Value(numseq));\
}\
}
#define SeqToArrayCast(seq,arr,typarr,typent) \
if (!seq.IsNull()) {\
Standard_Integer numseq, lenseq = seq->Length();\
if (lenseq > 0) {\
arr = new typarr (1,lenseq);\
for (numseq = 1; numseq <= lenseq; numseq ++)\
arr->SetValue (numseq, Handle(typent)::DownCast(seq->Value(numseq)));\
}\
}
#define ArrayToSeq (arr,seq)\
{\
Standard_Integer nument, numlow = arr->Lower() , numup = arr->Upper();\
for (nument = numlow; nument <= numup; nument ++)\
seq->Append(arr->Value(nument));\
}

View File

@@ -0,0 +1,94 @@
-- File: Interface_TypedValue.cdl
-- Created: Mon Feb 23 12:32:29 1998
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1995
class TypedValue from Interface inherits TypedValue from MoniTool
---Purpose : Now strictly equivalent to TypedValue from MoniTool,
-- except for ParamType which remains for compatibility reasons
--
-- This class allows to dynamically manage .. typed values, i.e.
-- values which have an alphanumeric expression, but with
-- controls. Such as "must be an Integer" or "Enumerative Text"
-- etc
--
-- Hence, a TypedValue brings a specification (type + constraints
-- if any) and a value. Its basic form is a string, it can be
-- specified as integer or real or enumerative string, then
-- queried as such.
-- Its string content, which is a Handle(HAsciiString) can be
-- shared by other data structures, hence gives a direct on line
-- access to its value.
uses CString, Type from Standard,
AsciiString from TCollection, HAsciiString from TCollection,
HSequenceOfAsciiString from TColStd, HArray1OfAsciiString from TColStd,
HSequenceOfHAsciiString from TColStd,
DictionaryOfInteger from Dico,
ParamType from Interface , ValueType from MoniTool,
ValueSatisfies from Interface, ValueInterpret from Interface
raises InterfaceError
is
Create (name : CString;
type : ParamType from Interface = Interface_ParamText;
init : CString = "") returns mutable TypedValue;
---Purpose : Creates a TypedValue, with a name
--
-- type gives the type of the parameter, default is free text
-- Also available : Integer, Real, Enum, Entity (i.e. Object)
-- More precise specifications, titles, can be given to the
-- TypedValue once created
--
-- init gives an initial value. If it is not given, the
-- TypedValue begins as "not set", its value is empty
Type (me) returns ParamType from Interface;
---Purpose : Returns the type
-- I.E. calls ValueType then makes correspondance between
-- ParamType from Interface (which remains for compatibility
-- reasons) and ValueType from MoniTool
ParamTypeToValueType (myclass; typ : ParamType from Interface)
returns ValueType from MoniTool;
---Purpose : Correspondance ParamType from Interface to
-- ValueType from MoniTool
ValueTypeToParamType (myclass; typ : ValueType from MoniTool)
returns ParamType from Interface;
---Purpose : Correspondance ParamType from Interface to
-- ValueType from MoniTool
fields
thename : AsciiString;
thedef : AsciiString;
thelabel : AsciiString;
thetype : ParamType from Interface;
theotyp : Type from Standard; -- for object
thelims : Integer; -- status for integer/enum/real limits
themaxlen : Integer;
theintlow : Integer;
theintup : Integer;
therealow : Real;
therealup : Real;
theunidef : AsciiString;
theenums : HArray1OfAsciiString from TColStd;
theeadds : DictionaryOfInteger;
theinterp : ValueInterpret;
thesatisf : ValueSatisfies;
thesatisn : AsciiString;
theival : Integer;
thehval : HAsciiString from TCollection;
theoval : Transient;
end Static;

View File

@@ -0,0 +1,39 @@
#include <Interface_TypedValue.ixx>
#include <Dico_DictionaryOfInteger.hxx>
#include <Dico_IteratorOfDictionaryOfInteger.hxx>
#include <OSD_Path.hxx>
#include <stdio.h>
//static char defmess[30]; svv #2
// Fonctions Satisfies offertes en standard ...
// svv#2
//static Standard_Boolean StaticPath(const Handle(TCollection_HAsciiString)& val)
//{
// OSD_Path apath;
// return apath.IsValid (TCollection_AsciiString(val->ToCString()));
//}
Interface_TypedValue::Interface_TypedValue
(const Standard_CString name,
const Interface_ParamType type, const Standard_CString init)
: MoniTool_TypedValue (name,
Interface_TypedValue::ParamTypeToValueType(type),
init) { }
Interface_ParamType Interface_TypedValue::Type () const
{ return ValueTypeToParamType (ValueType()); }
MoniTool_ValueType Interface_TypedValue::ParamTypeToValueType
(const Interface_ParamType type)
{ return (MoniTool_ValueType) type; } // meme valeurs
Interface_ParamType Interface_TypedValue::ValueTypeToParamType
(const MoniTool_ValueType type)
{ return (Interface_ParamType) type; } // meme valeurs

View File

@@ -0,0 +1,141 @@
-- File: UndefinedContent.cdl
-- Created: Tue Feb 4 13:56:27 1992
-- Author: Christian CAILLET
-- <cky@phobox>
---Copyright: Matra Datavision 1992
class UndefinedContent from Interface inherits TShared
---Purpose : Defines resources for an "Undefined Entity" : such an Entity
-- is used to describe an Entity which complies with the Norm,
-- but of an Unknown Type : hence it is kept under a literal
-- form (avoiding to loose data). UndefinedContent offers a way
-- to store a list of Parameters, as literals or references to
-- other Entities
--
-- Each Interface must provide one "UndefinedEntity", which must
-- have same basic description as all its types of entities :
-- the best way would be double inheritance : on the Entity Root
-- of the Norm and on an general "UndefinedEntity"
--
-- While it is not possible to do so, the UndefinedEntity of each
-- Interface can define its own UndefinedEntity by INCLUDING
-- (in a field) this UndefinedContent
--
-- Hence, for that UndefinedEntity, define a Constructor which
-- creates this UndefinedContent, plus access methods to it
-- (or to its data, calling methods defined here).
--
-- Finally, the Protocols of each norm have to Create and
-- Recognize Unknown Entities of this norm
---See Also : Protocol
uses Transient, HAsciiString from TCollection,
HArray1OfInteger from TColStd, HArray1OfHAsciiString from Interface,
ParamType, EntityList, CopyTool
raises OutOfRange, NoSuchObject, InterfaceMismatch, InterfaceError
is
Create returns mutable UndefinedContent;
---Purpose : Defines an empty UndefinedContent
-- -- Access to Parameters -- --
NbParams (me) returns Integer is static;
---Purpose : Gives count of recorded parameters
NbLiterals (me) returns Integer is static;
---Purpose : Gives count of Literal Parameters
ParamData (me; num : Integer; ptype : out ParamType;
ent : out mutable Transient;
val : out HAsciiString from TCollection)
returns Boolean is static;
---Purpose : Returns data of a Parameter : its type, and the entity if it
-- designates en entity ("ent") or its literal value else ("str")
-- Returned value (Boolean) : True if it is an Entity, False else
ParamType (me; num : Integer) returns ParamType
raises OutOfRange is static;
---Purpose : Returns the ParamType of a Param, given its rank
-- Error if num is not between 1 and NbParams
IsParamEntity (me; num : Integer) returns Boolean
raises OutOfRange is static;
---Purpose : Returns True if a Parameter is recorded as an entity
-- Error if num is not between 1 and NbParams
ParamEntity (me; num : Integer) returns mutable Transient
---Purpose : Returns Entity corresponding to a Param, given its rank
raises InterfaceError, OutOfRange is static;
-- Error if out of range or if Param num does not designate
-- an Entity
ParamValue (me; num : Integer) returns HAsciiString from TCollection
---Purpose : Returns litteral value of a Parameter, given its rank
raises InterfaceError, OutOfRange is static;
-- Error if num is out of range, or if Parameter is not literal
Reservate (me : mutable; nb,nblit : Integer) is static;
---Purpose : Manages reservation for parameters (internal use)
-- (nb : total count of parameters, nblit : count of literals)
AddLiteral (me : mutable; ptype : ParamType;
val : HAsciiString from TCollection) is static;
---Purpose : Adds a literal Parameter to the list
AddEntity (me : mutable; ptype : ParamType; ent : mutable Transient)
is static;
---Purpose : Adds a Parameter which references an Entity
RemoveParam (me : mutable; num : Integer)
---Purpose : Removes a Parameter given its rank
raises OutOfRange is static;
-- Error if num is out of range
SetLiteral (me : mutable; num : Integer; ptype : ParamType;
val : HAsciiString from TCollection)
---Purpose : Sets a new value for the Parameter <num>, to a literal value
-- (if it referenced formerly an Entity, this Entity is removed)
raises OutOfRange is static;
-- Error if num is out of range
SetEntity (me : mutable; num : Integer; ptype : ParamType;
ent : mutable Transient)
---Purpose : Sets a new value for the Parameter <num>, to reference an
-- Entity. To simply change the Entity, see the variant below
raises OutOfRange is static;
-- Error if num is out of range
SetEntity (me : mutable; num : Integer; ent : mutable Transient)
---Purpose : Changes the Entity referenced by the Parameter <num>
-- (with same ParamType)
raises InterfaceError, OutOfRange is static;
-- Error if num is out of range or if <num> is not for an Entity
EntityList (me) returns EntityList is static;
---Purpose : Returns globally the list of param entities. Note that it can
-- be used as shared entity list for the UndefinedEntity
GetFromAnother (me : mutable;
other : UndefinedContent; TC : in out CopyTool)
is static;
---Purpose : Copies contents of undefined entities; deigned to be called by
-- GetFromAnother method from Undefined entity of each Interface
-- (the basic operation is the same regardless the norm)
fields
thenbparams : Integer; -- total count of parameters
thenbstr : Integer; -- count of literal parameters
theparams : HArray1OfInteger from TColStd;
thevalues : HArray1OfHAsciiString from Interface;
theentities : EntityList;
end UndefinedContent;

View File

@@ -0,0 +1,296 @@
#include <Interface_UndefinedContent.ixx>
#include <Interface_InterfaceMismatch.hxx>
#include <Interface_InterfaceError.hxx>
#include <Standard_NoSuchObject.hxx>
#define Content_TypeField 31
#define Content_LocalField 7
#define Content_LocalRef 1
#define Content_LocalShift 5
#define Content_NumberShift 8
// Cette classe donne les services de base pour definir des entites
// Unknown (ceci, a defaut d'un double heritage) : description litterale
Interface_UndefinedContent::Interface_UndefinedContent () // Unknown
{ thenbparams = 0; thenbstr = 0; }
// .... Les Parametres ....
// Les parametres sont organises comme suit (pas de FileParameter) :
// - une liste de descripteurs (tenant sur un entier chacun) en tableau, avec
// la localisation (Entity/literal), le type (ParamType), le rang dans la
// la liste ad hoc (Entity ou literal)
// (5 bits droits pour type; 3 bits pour localisation; restant pouradresse)
// - pour les litteraux, une liste de String (tableau)
// - pour les Entity, une liste d Entites (EntityList)
// L aspect "place memoire" fait preferer des Tableaux a des Sequences, bien
// que ces dernieres soient plus simples a gerer
// En effet, il faut reserver et etendre si necessaire ...
Standard_Integer Interface_UndefinedContent::NbParams () const
{ return thenbparams; }
Standard_Integer Interface_UndefinedContent::NbLiterals () const
{ return thenbstr; }
Standard_Boolean Interface_UndefinedContent::ParamData
(const Standard_Integer num, Interface_ParamType& ptype,
Handle(Standard_Transient)& ent,
Handle(TCollection_HAsciiString)& val) const
{
if (num < 1 || num > thenbparams) Standard_OutOfRange::Raise
("Interface UndefinedContent : ParamData");
Standard_Integer desc = theparams->Value(num);
Standard_Integer local = ((desc >> Content_LocalShift) & Content_LocalField);
ptype = Interface_ParamType (desc & Content_TypeField);
Standard_Integer adr = desc >> Content_NumberShift;
if (local == Content_LocalRef) ent = theentities.Value(adr);
else val = thevalues->Value(adr);
return (local == Content_LocalRef); }
Interface_ParamType Interface_UndefinedContent::ParamType
(const Standard_Integer num) const
{ return Interface_ParamType(theparams->Value(num) & Content_TypeField); }
Standard_Boolean Interface_UndefinedContent::IsParamEntity
(const Standard_Integer num) const
{
return ( ((theparams->Value(num) >> Content_LocalShift) & Content_LocalField)
== Content_LocalRef);
}
Handle(Standard_Transient) Interface_UndefinedContent::ParamEntity
(const Standard_Integer num) const
{
Standard_Integer desc = theparams->Value(num);
if (((desc >> Content_LocalShift) & Content_LocalField) != Content_LocalRef)
Interface_InterfaceError::Raise
("UndefinedContent : Param is not Entity type");
return theentities.Value (desc >> Content_NumberShift);
}
Handle(TCollection_HAsciiString)
Interface_UndefinedContent::ParamValue
(const Standard_Integer num) const
{
Standard_Integer desc = theparams->Value(num);
if (((desc >> Content_LocalShift) & Content_LocalField) != 0)
Interface_InterfaceError::Raise
("UndefinedContent : Param is not literal");
return thevalues->Value (desc >> Content_NumberShift);
}
// .... Remplissage des parametres ....
void Interface_UndefinedContent::Reservate
(const Standard_Integer nb, const Standard_Integer nblit)
{
// Reservation : Si agrandissement, recopier ancien dans nouveau ...
if (nb > thenbparams) { // Reservation en total
if (theparams.IsNull()) theparams =
new TColStd_HArray1OfInteger (1,nb);
else if (nb > theparams->Length()) {
Standard_Integer nbnew = 2*thenbparams; // on reserve un peu large
if (nbnew < nb) nbnew = nb;
Handle(TColStd_HArray1OfInteger) newparams =
new TColStd_HArray1OfInteger (1,nbnew);
for (Standard_Integer i = 1; i <= thenbparams; i ++)
newparams->SetValue(i,theparams->Value(i));
theparams = newparams;
}
}
if (nblit > thenbstr) { // Reservation en Litteraux
if (thevalues.IsNull()) thevalues =
new Interface_HArray1OfHAsciiString (1,nblit);
else if (nblit > thevalues->Length()) {
Standard_Integer nbnew = 2*thenbstr; // on reserve un peu large
if (nbnew < nblit) nbnew = nblit;
Handle(Interface_HArray1OfHAsciiString) newvalues =
new Interface_HArray1OfHAsciiString (1,nbnew);
for (Standard_Integer i = 1; i <= thenbstr; i ++)
newvalues->SetValue(i,thevalues->Value(i));
thevalues = newvalues;
}
}
// Entites : Parametres - Litteraux. En fait, EntityList est dynamique
}
void Interface_UndefinedContent::AddLiteral
(const Interface_ParamType ptype,
const Handle(TCollection_HAsciiString)& val)
{
Reservate (thenbparams+1,thenbstr+1);
Standard_Integer desc = Standard_Integer(ptype);
thenbstr ++;
thenbparams ++;
thevalues->SetValue (thenbstr,val);
desc += (thenbstr << Content_NumberShift);
theparams->SetValue (thenbparams,desc);
}
void Interface_UndefinedContent::AddEntity
(const Interface_ParamType ptype,
const Handle(Standard_Transient)& ent)
{
Reservate (thenbparams+1,0);
Standard_Integer desc = Standard_Integer(ptype);
theentities.Append (ent);
desc += Content_LocalRef << Content_LocalShift; // "C est une Entite"
thenbparams ++; // Rang : thenbparams - thenbstr
desc += ((thenbparams - thenbstr) << Content_NumberShift);
theparams->SetValue (thenbparams,desc);
}
// .... Edition des parametres ....
void Interface_UndefinedContent::RemoveParam (const Standard_Integer num)
{
Standard_Integer desc = theparams->Value(num);
Standard_Integer rang = desc >> Content_NumberShift;
Standard_Integer local = ((desc >> Content_LocalShift) & Content_LocalField);
Standard_Boolean c1ent = (local == Content_LocalRef);
// Supprimer une Entite
if (c1ent) theentities.Remove(rang);
// Supprimer un Literal
else { // thevalues->Remove(rang) mais c est un tableau
for (Standard_Integer i = rang+1; i <= thenbstr; i ++)
thevalues->SetValue(i-1,thevalues->Value(i));
Handle(TCollection_HAsciiString) nulstr;
thevalues->SetValue(thenbstr,nulstr);
thenbstr --;
}
// Supprimer ce parametre de la liste (qui est un tableau)
Standard_Integer np; // svv Jan11 2000 : porting on DEC
for (np = num+1; np <= thenbparams; np ++)
theparams->SetValue(np-1,theparams->Value(np));
theparams->SetValue(thenbparams,0);
thenbparams --;
// Renumeroter, Entite ou Literal, selon
for (np = 1; np <= thenbparams; np ++) {
desc = theparams->Value(np);
if ( ((desc >> Content_LocalShift) & Content_LocalField) == local
&& (desc >> Content_NumberShift) > rang)
theparams->SetValue(np,desc - (1 << Content_NumberShift));
}
}
void Interface_UndefinedContent::SetLiteral
(const Standard_Integer num,
const Interface_ParamType ptype,
const Handle(TCollection_HAsciiString)& val)
{
// On change un parametre. Si deja literal, simple substitution
// Si Entite, supprimer l entite et renumeroter les Parametres "Entite"
Standard_Integer desc = theparams->Value(num);
Standard_Integer rang = desc >> Content_NumberShift;
Standard_Integer local = ((desc >> Content_LocalShift) & Content_LocalField);
Standard_Boolean c1ent = (local == Content_LocalRef);
if (c1ent) {
// Entite : la supprimer et renumeroter les Parametres de type "Entity"
theentities.Remove(rang);
for (Standard_Integer i = 1; i <= thenbparams; i ++) {
desc = theparams->Value(i);
if ( ((desc >> Content_LocalShift) & Content_LocalField) == Content_LocalRef
&& (desc >> Content_NumberShift) > rang)
theparams->SetValue(i , desc - (1 << Content_NumberShift));
}
// Et Preparer arrivee d un Literal supplementaire
Reservate (thenbparams,thenbstr+1);
thenbstr ++;
rang = thenbstr;
}
// Mettre en place la nouvelle valeur et reconstruire le descripteur du Param
thevalues->SetValue(rang,val);
desc = Standard_Integer(ptype) + (rang << Content_NumberShift);
theparams->SetValue(num,desc);
}
void Interface_UndefinedContent::SetEntity
(const Standard_Integer num,
const Interface_ParamType ptype,
const Handle(Standard_Transient)& ent)
{
// On change un Parametre. Si deja Entity, simple substitution
// Si Literal, supprimer sa valeur et renumeroter les parametres Litteraux
Standard_Integer desc = theparams->Value(num);
Standard_Integer rang = desc >> Content_NumberShift;
Standard_Integer local = ((desc >> Content_LocalShift) & Content_LocalField);
Standard_Boolean c1ent = (local == Content_LocalRef);
if (!c1ent) {
// Literal : le supprimer et renumeroter les Parametres de type "Entity"
// (Remove Literal mais dans un tableau)
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = rang+1; i <= thenbstr; i ++)
thevalues->SetValue(i-1,thevalues->Value(i));
Handle(TCollection_HAsciiString) nulstr;
thevalues->SetValue(thenbstr,nulstr);
for (i = 1; i <= thenbparams; i ++) {
desc = theparams->Value(i);
if ( ((desc >> Content_LocalShift) & Content_LocalField) == 0
&& (desc >> Content_NumberShift) > rang)
theparams->SetValue(i , desc - (1 << Content_NumberShift));
}
// Et Preparer arrivee d une Entite supplementaire
thenbstr --;
rang = thenbparams - thenbstr;
// Mettre en place la nouvelle valeur et reconstruire le descripteur du Param
theentities.Append(ent);
}
else theentities.SetValue(rang,ent);
desc = Standard_Integer(ptype) + (Content_LocalRef << Content_LocalShift)
+ (rang << Content_NumberShift);
theparams->SetValue(num,desc);
}
void Interface_UndefinedContent::SetEntity
(const Standard_Integer num,
const Handle(Standard_Transient)& ent)
{
// On change l Entite definie par un Parametre, toutes autres choses egales,
// A CONDITION que ce soit deja un Parametre de type "Entity"
Standard_Integer desc = theparams->Value(num);
Standard_Integer rang = desc >> Content_NumberShift;
Standard_Integer local = ((desc >> Content_LocalShift) & Content_LocalField);
Standard_Boolean c1ent = (local == Content_LocalRef);
if (!c1ent) Interface_InterfaceError::Raise("UndefinedContent : SetEntity");
theentities.SetValue(rang,ent);
}
Interface_EntityList Interface_UndefinedContent::EntityList () const
{ return theentities; }
// toutes les recopies de UndefinedEntity se ressemblent ... Partie commune
void Interface_UndefinedContent::GetFromAnother
(const Handle(Interface_UndefinedContent)& other, Interface_CopyTool& TC)
{
Standard_Integer nb = other->NbParams();
theentities.Clear();
thevalues.Nullify();
theparams.Nullify();
Reservate (nb,other->NbLiterals());
Handle(Standard_Transient) ent;
for (Standard_Integer i = 1; i <= nb; i ++) {
Interface_ParamType ptype;
Handle(TCollection_HAsciiString) val;
if (other->ParamData (i, ptype,ent,val)) {
ent = TC.Transferred(ent);
AddEntity (ptype,ent);
}
else AddLiteral (ptype,val);
}
}

View File

@@ -0,0 +1,8 @@
#ifndef _Interface_ValueInterpret_HeaderFile
#define _Interface_ValueInterpret_HeaderFile
#include <Handle_TCollection_HAsciiString.hxx>
typedef Handle(TCollection_HAsciiString) (*Interface_ValueInterpret) (const Handle(Interface_TypedValue)& typval, const Handle(TCollection_HAsciiString)& val, const Standard_Boolean native);
#endif

View File

@@ -0,0 +1,8 @@
#ifndef _Interface_ValueSatisfies_HeaderFile
#define _Interface_ValueSatisfies_HeaderFile
#include <Handle_TCollection_HAsciiString.hxx>
typedef Standard_Boolean (*Interface_ValueSatisfies) (const Handle(TCollection_HAsciiString)& val);
#endif

View File

@@ -0,0 +1,20 @@
// File: Interface_VectorOfFileParameter.hxx
// Created: 21.01.08 11:24
// Author: Galina KULIKOVA
// Copyright: OpenCASCADE 2008
#ifndef Interface_VectorOfFileParameter_HeaderFile
#define Interface_VectorOfFileParameter_HeaderFile
#include <MMgt_TShared.hxx>
#include <NCollection_Vector.hxx>
#include <Interface_FileParameter.hxx>
/**
* Block of comments describing class Interface_VectorOfFileParameter
*/
typedef NCollection_Vector<Interface_FileParameter> Interface_VectorOfFileParameter;
#endif

View File

@@ -0,0 +1,6 @@
#include <Standard_Version.hxx>
#define XSTEP_PROCESSOR_VERSION "Open CASCADE %s processor "OCC_VERSION_STRING
#define XSTEP_SYSTEM_VERSION "Open CASCADE "OCC_VERSION_STRING
#define XSTEP_Config OCC_VERSION_STRING
#define XSTEP_ULNames OCC_VERSION_STRING