mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
5
src/MoniTool/FILES
Executable file
5
src/MoniTool/FILES
Executable file
@@ -0,0 +1,5 @@
|
||||
MoniTool_ValueInterpret.hxx
|
||||
MoniTool_ValueInterpret.cxx
|
||||
MoniTool_ValueSatisfies.hxx
|
||||
MoniTool_ValueSatisfies.cxx
|
||||
MoniTool_Macros.hxx
|
85
src/MoniTool/MoniTool.cdl
Executable file
85
src/MoniTool/MoniTool.cdl
Executable file
@@ -0,0 +1,85 @@
|
||||
-- File: MoniTool.cdl
|
||||
-- Created: Wed Apr 1 13:54:29 1998
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@heliox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
package MoniTool
|
||||
|
||||
---Purpose: This package provides basic tools to help monitoring of data
|
||||
-- exchange and shapehealing process, such as:
|
||||
-- - attaching messages to objects
|
||||
-- - storing recorded objects with attached messages for further use
|
||||
-- - timers for measuring the performance
|
||||
|
||||
uses Standard, MMgt, TCollection, TColStd, Dico,
|
||||
gp, Geom, Geom2d,
|
||||
TopoDS, TopTools,
|
||||
Message, Dico, OSD
|
||||
|
||||
is
|
||||
|
||||
-- Element, generic Elem, and instance for Transient
|
||||
class DataInfo; -- used in Elem : this one is for Transient
|
||||
deferred class Element;
|
||||
generic class Elem;
|
||||
class TransientElem instantiates Elem
|
||||
(Transient, MapTransientHasher from TColStd, DataInfo);
|
||||
class ElemHasher;
|
||||
|
||||
|
||||
class IntVal;
|
||||
class RealVal;
|
||||
class AttrList;
|
||||
|
||||
class TypedValue;
|
||||
primitive ValueSatisfies;
|
||||
-- (val : HAsciiString) returns Boolean, see Satisfies from TypedValue
|
||||
primitive ValueInterpret;
|
||||
-- (typval : TypedValue; hval : HAsciiString; native : Boolean)
|
||||
-- returns HAsciiString, see Interpret from TypedValue
|
||||
|
||||
class CaseData;
|
||||
|
||||
deferred class SignText;
|
||||
class SignShape;
|
||||
|
||||
class Stat;
|
||||
|
||||
class Option;
|
||||
class Profile;
|
||||
class OptValue;
|
||||
|
||||
|
||||
enumeration ValueType is
|
||||
ValueMisc, ValueInteger, ValueReal, ValueIdent, ValueVoid, ValueText,
|
||||
ValueEnum, ValueLogical, ValueSub, ValueHexa, ValueBinary;
|
||||
|
||||
class DataMapOfShapeTransient instantiates
|
||||
DataMap from TCollection
|
||||
(Shape from TopoDS,
|
||||
Transient from Standard,
|
||||
ShapeMapHasher from TopTools);
|
||||
|
||||
class IndexedDataMapOfShapeTransient instantiates
|
||||
IndexedDataMap from TCollection
|
||||
(Shape from TopoDS,
|
||||
Transient from Standard,
|
||||
ShapeMapHasher from TopTools);
|
||||
|
||||
class SequenceOfElement instantiates
|
||||
Sequence from TCollection (Element);
|
||||
class HSequenceOfElement instantiates
|
||||
HSequence from TCollection (Element,SequenceOfElement);
|
||||
|
||||
-- Timers
|
||||
class Timer;
|
||||
class TimerSentry;
|
||||
class MTHasher;
|
||||
class DataMapOfTimer instantiates DataMap from TCollection
|
||||
(CString from Standard,
|
||||
Timer from MoniTool,
|
||||
MTHasher from MoniTool);
|
||||
|
||||
end MoniTool;
|
120
src/MoniTool/MoniTool_AttrList.cdl
Executable file
120
src/MoniTool/MoniTool_AttrList.cdl
Executable file
@@ -0,0 +1,120 @@
|
||||
-- File: MoniTool_AttrList.cdl
|
||||
-- Created: Fri Nov 4 10:59:26 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@anion>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class AttrList from MoniTool
|
||||
|
||||
---Purpose : a AttrList allows to record a list of attributes as Transients
|
||||
-- which can be edited, changed ...
|
||||
-- Each one is identified by a name
|
||||
|
||||
uses CString, Type, Transient,
|
||||
DictionaryOfTransient from Dico, ValueType from MoniTool
|
||||
|
||||
is
|
||||
|
||||
Create returns AttrList;
|
||||
---Purpose : Creates an AttrList, empty
|
||||
|
||||
Create (other : AttrList) returns AttrList;
|
||||
---Purpose : Creates an AttrList from another one, definitions are shared
|
||||
-- (calls SameAttributes)
|
||||
|
||||
-- -- Attributes
|
||||
|
||||
|
||||
SetAttribute (me : in out; name : CString; val : Transient);
|
||||
---Purpose : Adds an attribute with a given name (replaces the former one
|
||||
-- with the same name if already exists)
|
||||
|
||||
RemoveAttribute (me : in out; name : CString) returns Boolean;
|
||||
---Purpose : Removes an attribute
|
||||
-- Returns True when done, False if this attribute did not exist
|
||||
|
||||
GetAttribute (me; name : CString; type : Type from Standard;
|
||||
val : out mutable Transient) returns Boolean;
|
||||
---Purpose : Returns an attribute from its name, filtered by a type
|
||||
-- If no attribute has this name, or if it is not kind of this
|
||||
-- type, <val> is Null and returned value is False
|
||||
-- Else, it is True
|
||||
|
||||
Attribute (me; name : CString) returns Transient;
|
||||
---Purpose : Returns an attribute from its name. Null Handle if not
|
||||
-- recorded (whatever Transient, Integer, Real ...)
|
||||
-- Integer is recorded as IntVal
|
||||
-- Real is recorded as RealVal
|
||||
-- Text is recorded as HAsciiString
|
||||
|
||||
AttributeType (me; name : CString) returns ValueType from MoniTool;
|
||||
---Purpose : Returns the type of an attribute :
|
||||
-- ValueInt , ValueReal , ValueText (String) , ValueIdent (any)
|
||||
-- or ValueVoid (not recorded)
|
||||
|
||||
|
||||
SetIntegerAttribute (me : in out; name : CString; val : Integer);
|
||||
---Purpose : Adds an integer value for an attribute
|
||||
|
||||
GetIntegerAttribute (me; name : CString; val : out Integer) returns Boolean;
|
||||
---Purpose : Returns an attribute from its name, as integer
|
||||
-- If no attribute has this name, or not an integer,
|
||||
-- <val> is 0 and returned value is False
|
||||
-- Else, it is True
|
||||
|
||||
IntegerAttribute (me; name : CString) returns Integer;
|
||||
---Purpose : Returns an integer attribute from its name. 0 if not recorded
|
||||
|
||||
SetRealAttribute (me : in out; name : CString; val : Real);
|
||||
---Purpose : Adds a real value for an attribute
|
||||
|
||||
GetRealAttribute (me; name : CString; val : out Real) returns Boolean;
|
||||
---Purpose : Returns an attribute from its name, as real
|
||||
-- If no attribute has this name, or not a real
|
||||
-- <val> is 0.0 and returned value is False
|
||||
-- Else, it is True
|
||||
|
||||
RealAttribute (me; name : CString) returns Real;
|
||||
---Purpose : Returns a real attribute from its name. 0.0 if not recorded
|
||||
|
||||
SetStringAttribute (me : in out; name : CString; val : CString);
|
||||
---Purpose : Adds a String value for an attribute
|
||||
|
||||
GetStringAttribute (me; name : CString; val : out CString) returns Boolean;
|
||||
---Purpose : Returns an attribute from its name, as String
|
||||
-- If no attribute has this name, or not a String
|
||||
-- <val> is 0.0 and returned value is False
|
||||
-- Else, it is True
|
||||
|
||||
StringAttribute (me; name : CString) returns CString;
|
||||
---Purpose : Returns a String attribute from its name. "" if not recorded
|
||||
|
||||
AttrList (me) returns DictionaryOfTransient;
|
||||
---Purpose : Returns the exhaustive list of attributes
|
||||
|
||||
SameAttributes (me : in out; other : AttrList);
|
||||
---Purpose : Gets the list of attributes from <other>, as such, i.e.
|
||||
-- not copied : attributes are shared, any attribute edited,
|
||||
-- added, or removed in <other> is also in <me> and vice versa
|
||||
-- The former list of attributes of <me> is dropped
|
||||
|
||||
GetAttributes (me : in out; other : AttrList;
|
||||
fromname : CString = ""; copied : Boolean = Standard_True);
|
||||
---Purpose : Gets the list of attributes from <other>, by copying it
|
||||
-- By default, considers all the attributes from <other>
|
||||
-- If <fromname> is given, considers only the attributes with
|
||||
-- name beginning by <fromname>
|
||||
--
|
||||
-- For each attribute, if <copied> is True (D), its value is also
|
||||
-- copied if it is a basic type (Integer,Real,String), else it
|
||||
-- remains shared between <other> and <me>
|
||||
--
|
||||
-- These new attributes are added to the existing ones in <me>,
|
||||
-- in case of same name, they replace the existing ones
|
||||
|
||||
fields
|
||||
|
||||
theattrib : DictionaryOfTransient;
|
||||
|
||||
end AttrList;
|
191
src/MoniTool/MoniTool_AttrList.cxx
Executable file
191
src/MoniTool/MoniTool_AttrList.cxx
Executable file
@@ -0,0 +1,191 @@
|
||||
#include <MoniTool_AttrList.ixx>
|
||||
#include <MoniTool_IntVal.hxx>
|
||||
#include <MoniTool_RealVal.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
|
||||
|
||||
MoniTool_AttrList::MoniTool_AttrList () { }
|
||||
|
||||
MoniTool_AttrList::MoniTool_AttrList (const MoniTool_AttrList& other)
|
||||
: theattrib (other.AttrList()) { }
|
||||
|
||||
// #### ATTRIBUTES ####
|
||||
|
||||
|
||||
// Integer -> IntVal, Real -> RealVal, CString -> HAsciiString
|
||||
|
||||
void MoniTool_AttrList::SetAttribute
|
||||
(const Standard_CString name, const Handle(Standard_Transient)& val)
|
||||
{
|
||||
if (theattrib.IsNull()) theattrib = new Dico_DictionaryOfTransient;
|
||||
theattrib->SetItem (name,val);
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_AttrList::RemoveAttribute
|
||||
(const Standard_CString name)
|
||||
{
|
||||
if (theattrib.IsNull()) return Standard_False;
|
||||
return theattrib->RemoveItem (name);
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_AttrList::GetAttribute
|
||||
(const Standard_CString name, const Handle(Standard_Type)& type,
|
||||
Handle(Standard_Transient)& val) const
|
||||
{
|
||||
if (theattrib.IsNull()) { val.Nullify(); return Standard_False; }
|
||||
if (!theattrib->GetItem (name,val)) { val.Nullify(); return Standard_False; }
|
||||
if (!val->IsKind(type)) { val.Nullify(); return Standard_False; }
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Handle(Standard_Transient) MoniTool_AttrList::Attribute
|
||||
(const Standard_CString name) const
|
||||
{
|
||||
Handle(Standard_Transient) atr;
|
||||
if (theattrib.IsNull()) return atr;
|
||||
if (!theattrib->GetItem (name,atr)) atr.Nullify();
|
||||
return atr;
|
||||
}
|
||||
|
||||
MoniTool_ValueType MoniTool_AttrList::AttributeType
|
||||
(const Standard_CString name) const
|
||||
{
|
||||
Handle(Standard_Transient) atr = Attribute(name);
|
||||
if (atr.IsNull()) return MoniTool_ValueVoid;
|
||||
if (atr->DynamicType() == STANDARD_TYPE(MoniTool_IntVal))
|
||||
return MoniTool_ValueInteger;
|
||||
if (atr->DynamicType() == STANDARD_TYPE(MoniTool_RealVal))
|
||||
return MoniTool_ValueReal;
|
||||
if (atr->DynamicType() == STANDARD_TYPE(TCollection_HAsciiString))
|
||||
return MoniTool_ValueText;
|
||||
return MoniTool_ValueIdent;
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_AttrList::SetIntegerAttribute
|
||||
(const Standard_CString name, const Standard_Integer val)
|
||||
{
|
||||
Handle(MoniTool_IntVal) ival = new MoniTool_IntVal;
|
||||
ival->CValue() = val;
|
||||
SetAttribute (name, ival);
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_AttrList::GetIntegerAttribute
|
||||
(const Standard_CString name, Standard_Integer& val) const
|
||||
{
|
||||
Handle(MoniTool_IntVal) ival = Handle(MoniTool_IntVal)::DownCast
|
||||
(Attribute(name));
|
||||
if (ival.IsNull()) { val = 0; return Standard_False; }
|
||||
val = ival->Value();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Integer MoniTool_AttrList::IntegerAttribute
|
||||
(const Standard_CString name) const
|
||||
{
|
||||
Handle(MoniTool_IntVal) ival = Handle(MoniTool_IntVal)::DownCast
|
||||
(Attribute(name));
|
||||
if (ival.IsNull()) return 0;
|
||||
return ival->Value();
|
||||
}
|
||||
|
||||
void MoniTool_AttrList::SetRealAttribute
|
||||
(const Standard_CString name, const Standard_Real val)
|
||||
{
|
||||
Handle(MoniTool_RealVal) rval = new MoniTool_RealVal;
|
||||
rval->CValue() = val;
|
||||
SetAttribute (name,rval);
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_AttrList::GetRealAttribute
|
||||
(const Standard_CString name, Standard_Real& val) const
|
||||
{
|
||||
Handle(MoniTool_RealVal) rval = Handle(MoniTool_RealVal)::DownCast
|
||||
(Attribute(name));
|
||||
if (rval.IsNull()) { val = 0.0; return Standard_False; }
|
||||
val = rval->Value();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Real MoniTool_AttrList::RealAttribute (const Standard_CString name) const
|
||||
{
|
||||
Handle(MoniTool_RealVal) rval = Handle(MoniTool_RealVal)::DownCast
|
||||
(Attribute(name));
|
||||
if (rval.IsNull()) return 0;
|
||||
return rval->Value();
|
||||
}
|
||||
|
||||
void MoniTool_AttrList::SetStringAttribute
|
||||
(const Standard_CString name, const Standard_CString val)
|
||||
{
|
||||
Handle(TCollection_HAsciiString) hval = new TCollection_HAsciiString (val);
|
||||
SetAttribute (name,hval);
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_AttrList::GetStringAttribute
|
||||
(const Standard_CString name, Standard_CString& val) const
|
||||
{
|
||||
Handle(TCollection_HAsciiString) hval = Handle(TCollection_HAsciiString)::DownCast
|
||||
(Attribute(name));
|
||||
if (hval.IsNull()) { val = ""; return Standard_False; }
|
||||
val = hval->ToCString();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_CString MoniTool_AttrList::StringAttribute (const Standard_CString name) const
|
||||
{
|
||||
Handle(TCollection_HAsciiString) hval = Handle(TCollection_HAsciiString)::DownCast
|
||||
(Attribute(name));
|
||||
if (hval.IsNull()) return "";
|
||||
return hval->ToCString();
|
||||
}
|
||||
|
||||
Handle(Dico_DictionaryOfTransient) MoniTool_AttrList::AttrList () const
|
||||
{ return theattrib; }
|
||||
|
||||
void MoniTool_AttrList::SameAttributes (const MoniTool_AttrList& other)
|
||||
{ theattrib = other.AttrList(); }
|
||||
|
||||
void MoniTool_AttrList::GetAttributes
|
||||
(const MoniTool_AttrList& other,
|
||||
const Standard_CString fromname, const Standard_Boolean copied)
|
||||
{
|
||||
Handle(Dico_DictionaryOfTransient) list = other.AttrList();
|
||||
if (list.IsNull()) return;
|
||||
if (theattrib.IsNull()) theattrib = new Dico_DictionaryOfTransient;
|
||||
|
||||
for (Dico_IteratorOfDictionaryOfTransient iter (list,fromname);
|
||||
iter.More(); iter.Next()) {
|
||||
TCollection_AsciiString name = iter.Name();
|
||||
Handle(Standard_Transient) atr = iter.Value();
|
||||
Handle(Standard_Transient) newatr = atr;
|
||||
|
||||
// Copy ? according type
|
||||
if (copied) {
|
||||
Handle(MoniTool_IntVal) ival = Handle(MoniTool_IntVal)::DownCast(atr);
|
||||
if (!ival.IsNull()) {
|
||||
Standard_Integer intval = ival->Value();
|
||||
ival = new MoniTool_IntVal;
|
||||
ival->CValue() = intval;
|
||||
newatr = ival;
|
||||
}
|
||||
Handle(MoniTool_RealVal) rval = Handle(MoniTool_RealVal)::DownCast(atr);
|
||||
if (!rval.IsNull()) {
|
||||
Standard_Real realval = rval->Value();
|
||||
rval = new MoniTool_RealVal;
|
||||
rval->CValue() = realval;
|
||||
newatr = rval;
|
||||
}
|
||||
Handle(TCollection_HAsciiString) hval = Handle(TCollection_HAsciiString)::DownCast(atr);
|
||||
if (!hval.IsNull()) {
|
||||
Handle(TCollection_HAsciiString) strval = new TCollection_HAsciiString
|
||||
(hval->ToCString());
|
||||
newatr = strval;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
theattrib->SetItem (name.ToCString(),newatr);
|
||||
|
||||
}
|
||||
}
|
277
src/MoniTool/MoniTool_CaseData.cdl
Executable file
277
src/MoniTool/MoniTool_CaseData.cdl
Executable file
@@ -0,0 +1,277 @@
|
||||
-- File: MoniTool_CaseData.cdl
|
||||
-- Created: Wed Apr 1 14:00:26 1998
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@heliox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class CaseData from MoniTool inherits TShared from MMgt
|
||||
|
||||
---Purpose : This class is intended to record data attached to a case to be
|
||||
-- exploited.
|
||||
-- Cases can be :
|
||||
-- * internal, i.e. for immediate debug
|
||||
-- for instance, on an abnormal exception, fill a CaseData
|
||||
-- in a DB (see class DB) then look at its content by XSDRAW
|
||||
-- * to record abnormal situation, which cause a warning or fail
|
||||
-- message, for instance during a transfer
|
||||
-- This will allow, firstly to build a more comprehensive
|
||||
-- message (with associated data), secondly to help seeing
|
||||
-- "what happened"
|
||||
-- * to record data in order to fix a problem
|
||||
-- If a CASE is well defined and its fix is well known too,
|
||||
-- recording a CaseData which identifies the CASE will allow
|
||||
-- to furstherly call the appropriate fix routine
|
||||
--
|
||||
-- A CaseData is defined by
|
||||
-- * an optional CASE identifier
|
||||
-- If it is defined, this will allow systematic exploitation
|
||||
-- such as calling a fix routine
|
||||
-- * an optional Check Status, Warning or Fail, else it is Info
|
||||
-- * a NAME : it just allows to identify where this CaseData was
|
||||
-- created (help to debug)
|
||||
-- * a LIST OF DATA
|
||||
--
|
||||
-- Each Data has a type (integer, real etc...) and can have a name
|
||||
-- Hence, each data may be identified by :
|
||||
-- * its absolute rank (from 1 to NbData)
|
||||
-- * its name if it has one (exact matching)
|
||||
-- * else, an interpreted identifier, which gives the type and
|
||||
-- the rank in the type (for instance, first integer; etc)
|
||||
-- (See NameRank)
|
||||
|
||||
uses CString, Transient, Type from Standard,
|
||||
AsciiString from TCollection,
|
||||
SequenceOfAsciiString from TColStd,
|
||||
SequenceOfTransient from TColStd, SequenceOfInteger from TColStd,
|
||||
Shape from TopoDS, XY from gp, XYZ from gp,
|
||||
Msg from Message
|
||||
|
||||
is
|
||||
|
||||
Create (caseid : CString = ""; name : CString = "") returns CaseData;
|
||||
---Purpose : Creates a CaseData with a CaseId and a Name
|
||||
-- (by default not defined)
|
||||
|
||||
SetCaseId (me : mutable; caseid : CString);
|
||||
---Purpose : Sets a CaseId
|
||||
|
||||
SetName (me : mutable; name : CString);
|
||||
---Purpose : Sets a Name
|
||||
|
||||
CaseId (me) returns CString;
|
||||
---Purpose : Returns the CaseId
|
||||
|
||||
Name (me) returns CString;
|
||||
---Purpose : Returns the Name
|
||||
|
||||
IsCheck (me) returns Boolean;
|
||||
---Purpose : Tells if <me> is Check (Warning or Fail), else it is Info
|
||||
|
||||
IsWarning (me) returns Boolean;
|
||||
---Purpose : Tells if <me> is Warning
|
||||
|
||||
IsFail (me) returns Boolean;
|
||||
---Purpose : Tells if <me> is Fail
|
||||
|
||||
ResetCheck (me : mutable);
|
||||
---Purpose : Resets Check Status, i.e. sets <me> as Info
|
||||
|
||||
SetWarning (me : mutable);
|
||||
---Purpose : Sets <me> as Warning
|
||||
|
||||
SetFail (me : mutable);
|
||||
---Purpose : Sets <me> as Fail
|
||||
|
||||
-- Setting Data
|
||||
|
||||
SetChange (me : mutable);
|
||||
---Purpose : Sets the next Add... not to add but to change the data item
|
||||
-- designated by its name.
|
||||
-- If next Add... is not called with a name, SetChange is ignored
|
||||
-- Reset by next Add... , whatever <num> is correct or not
|
||||
|
||||
SetReplace (me : mutable; num : Integer);
|
||||
---Purpose : Sets the next Add... not to add but to replace the data item
|
||||
-- <num>, if <num> is between 1 and NbData.
|
||||
-- Reset by next Add... , whatever <num> is correct or not
|
||||
|
||||
AddData (me : mutable; val : Transient; kind : Integer; name : CString = "");
|
||||
---Purpose : Unitary adding a data; rather internal
|
||||
|
||||
AddRaised (me : mutable; name : CString = "");
|
||||
---Purpose : Adds the currently caught exception
|
||||
|
||||
AddShape (me : mutable; sh : Shape from TopoDS; name : CString = "");
|
||||
---Purpose : Adds a Shape (recorded as a HShape)
|
||||
|
||||
AddXYZ (me : mutable; aXYZ : XYZ from gp; name : CString = "");
|
||||
---Purpose : Adds a XYZ
|
||||
|
||||
AddXY (me : mutable; aXY : XY from gp; name : CString = "");
|
||||
---Purpose : Adds a XY
|
||||
|
||||
AddReal (me : mutable; val : Real; name : CString = "");
|
||||
---Purpose : Adds a Real
|
||||
|
||||
AddReals (me : mutable; v1,v2 : Real; name : CString = "");
|
||||
---Purpose : Adds two reals (for instance, two parameters)
|
||||
|
||||
AddCPU (me : mutable; lastCPU : Real; curCPU : Real = 0; name : CString = "");
|
||||
---Purpose : Adds the CPU time between lastCPU and now
|
||||
-- if <curCPU> is given, the CPU amount is curCPU-lastCPU
|
||||
-- else it is currently measured CPU - lastCPU
|
||||
-- lastCPU has been read by call to GetCPU
|
||||
-- See GetCPU to get amount, and LargeCPU to test large amount
|
||||
|
||||
GetCPU (me) returns Real;
|
||||
---Purpose : Returns the current amount of CPU
|
||||
-- This allows to laterly test and record CPU amount
|
||||
-- Its value has to be given to LargeCPU and AddCPU
|
||||
|
||||
LargeCPU (me; maxCPU, lastCPU : Real; curCPU : Real = 0) returns Boolean;
|
||||
---Purpose : Tells if a CPU time amount is large
|
||||
-- <maxCPU> gives the amount over which an amount is large
|
||||
-- <lastCPU> gives the start CPU amount
|
||||
-- if <curCPU> is given, the tested CPU amount is curCPU-lastCPU
|
||||
-- else it is currently measured CPU - lastCPU
|
||||
|
||||
AddGeom (me : mutable; geom : Transient; name : CString = "");
|
||||
---Purpose : Adds a Geometric as a Transient (Curve, Surface ...)
|
||||
|
||||
AddEntity (me : mutable; ent : Transient; name : CString = "");
|
||||
---Purpose : Adds a Transient, as an Entity from an InterfaceModel for
|
||||
-- instance : it will then be printed with the help of a DBPE
|
||||
|
||||
AddText (me : mutable; text : CString; name : CString = "");
|
||||
---Purpose : Adds a Text (as HAsciiString)
|
||||
|
||||
AddInteger(me : mutable; val : Integer; name : CString = "");
|
||||
---Purpose : Adds an Integer
|
||||
|
||||
AddAny (me : mutable; val : Transient; name : CString = "");
|
||||
---Purpose : Adds a Transient, with no more meaning
|
||||
|
||||
RemoveData (me : mutable; num : Integer);
|
||||
---Purpose : Removes a Data from its rank. Does nothing if out of range
|
||||
|
||||
-- Querying Data
|
||||
|
||||
NbData (me) returns Integer;
|
||||
---Purpose : Returns the count of data recorded to a set
|
||||
|
||||
Data (me; nd : Integer) returns Transient;
|
||||
---Purpose : Returns a data item (n0 <nd> in the set <num>)
|
||||
|
||||
GetData (me; nd : Integer; type : Type from Standard; val : out Transient)
|
||||
returns Boolean;
|
||||
---Purpose : Returns a data item, under control of a Type
|
||||
-- If the data item is kind of this type, it is returned in <val>
|
||||
-- and the returned value is True
|
||||
-- Else, <val> is unchanged and the returned value is False
|
||||
|
||||
Kind (me; nd : Integer) returns Integer;
|
||||
---Purpose : Returns the kind of a data :
|
||||
-- KIND TYPE MEANING
|
||||
-- 0 ANY any (not one of the followings)
|
||||
-- 1 EX raised exception
|
||||
-- 2 EN entity
|
||||
-- 3 G geom
|
||||
-- 4 SH shape
|
||||
-- 5 XYZ XYZ
|
||||
-- 6 XY or UV XY
|
||||
-- 7 RR 2 reals
|
||||
-- 8 R 1 real
|
||||
-- 9 CPU CPU (1 real)
|
||||
-- 10 T text
|
||||
-- 11 I integer
|
||||
--
|
||||
-- For NameNum, these codes for TYPE must be given exact
|
||||
-- i.e. SH for a Shape, not S nor SHAPE nor SOLID etc
|
||||
|
||||
Name (me; nd : Integer) returns AsciiString;
|
||||
---Purpose : Returns the name of a data. If it has no name, the string is
|
||||
-- empty (length = 0)
|
||||
---C++ : return const &
|
||||
|
||||
NameNum (me; name : CString) returns Integer;
|
||||
---Purpose : Returns the first suitable data rank for a given name
|
||||
-- Exact maching (exact case, no completion) is required
|
||||
-- Firstly checks the recorded names
|
||||
-- If not found, considers the name as follows :
|
||||
-- Name = "TYPE" : search for the first item with this TYPE
|
||||
-- Name = "TYPE:nn" : search for the nn.th item with this TYPE
|
||||
-- See allowed values in method Kind
|
||||
|
||||
Shape (me; nd : Integer) returns Shape from TopoDS;
|
||||
---Purpose : Returns a data as a shape, Null if not a shape
|
||||
|
||||
XYZ (me; nd : Integer; val : out XYZ from gp) returns Boolean;
|
||||
---Purpose : Returns a data as a XYZ (i.e. Geom_CartesianPoint)
|
||||
-- Returns False if not the good type
|
||||
|
||||
XY (me; nd : Integer; val : out XY from gp) returns Boolean;
|
||||
---Purpose : Returns a data as a XY (i.e. Geom2d_CartesianPoint)
|
||||
-- Returns False if not the good type
|
||||
|
||||
Reals (me; nd : Integer; v1,v2 : out Real) returns Boolean;
|
||||
---Purpose : Returns a couple of reals (stored in Geom2d_CartesianPoint)
|
||||
|
||||
Real (me; nd : Integer; val : out Real) returns Boolean;
|
||||
---Purpose : Returns a real or CPU amount (stored in Geom2d_CartesianPoint)
|
||||
-- (allows an Integer converted to a Real)
|
||||
|
||||
Text (me; nd : Integer; text : out CString) returns Boolean;
|
||||
---Purpose : Returns a text (stored in TCollection_HAsciiString)
|
||||
|
||||
Integer (me; nd : Integer; val : out Integer) returns Boolean;
|
||||
---Purpose : Returns an Integer
|
||||
|
||||
-- Binding with messages and status
|
||||
-- a CaseData may have a default check status according to its code
|
||||
-- it can also have a default attached message
|
||||
|
||||
Msg (me) returns Msg from Message;
|
||||
---Purpose : Returns a Msg from a CaseData : it is build from DefMsg, which
|
||||
-- gives the message code plus the designation of items of the
|
||||
-- CaseData to be added to the Msg
|
||||
-- Empty if no message attached
|
||||
--
|
||||
-- Remains to be implemented
|
||||
|
||||
|
||||
SetDefWarning (myclass; acode : CString);
|
||||
---Purpose : Sets a Code to give a Warning
|
||||
|
||||
SetDefFail (myclass; acode : CString);
|
||||
---Purpose : Sets a Code to give a Fail
|
||||
|
||||
DefCheck (myclass; acode : CString) returns Integer;
|
||||
---Purpose : Returns Check Status for a Code : 0 non/info (default),
|
||||
-- 1 warning, 2 fail
|
||||
--
|
||||
-- Remark : DefCheck is used to set the check status of a
|
||||
-- CaseData when it is attached to a case code, it can be changed
|
||||
-- later (by SetFail, SetWarning, ResetCheck)
|
||||
|
||||
SetDefMsg (myclass; casecode : CString; mesdef : CString);
|
||||
---Purpose : Attaches a message definition to a case code
|
||||
-- This definition includes the message code plus designation of
|
||||
-- items of the CaseData to be added to the message (this part
|
||||
-- not yet implemented)
|
||||
|
||||
DefMsg (myclass; casecode : CString) returns CString;
|
||||
---Purpose : Returns the message definition for a case code
|
||||
-- Empty if no message attached
|
||||
|
||||
fields
|
||||
|
||||
thecheck : Integer;
|
||||
thesubst : Integer;
|
||||
thecase : AsciiString;
|
||||
thename : AsciiString;
|
||||
thedata : SequenceOfTransient;
|
||||
thekind : SequenceOfInteger;
|
||||
thednam : SequenceOfAsciiString;
|
||||
|
||||
end CaseData;
|
421
src/MoniTool/MoniTool_CaseData.cxx
Executable file
421
src/MoniTool/MoniTool_CaseData.cxx
Executable file
@@ -0,0 +1,421 @@
|
||||
#include <MoniTool_CaseData.ixx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TopoDS_HShape.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <Geom2d_CartesianPoint.hxx>
|
||||
|
||||
#include <TopAbs.hxx>
|
||||
//#include <GeomTools.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
|
||||
// definitions
|
||||
#include <Dico_DictionaryOfInteger.hxx>
|
||||
#include <Dico_DictionaryOfTransient.hxx>
|
||||
|
||||
static Handle(Dico_DictionaryOfInteger)& defchecks()
|
||||
{
|
||||
static Handle(Dico_DictionaryOfInteger) defch;
|
||||
if (defch.IsNull()) defch = new Dico_DictionaryOfInteger();
|
||||
return defch;
|
||||
}
|
||||
|
||||
static Handle(Dico_DictionaryOfTransient)& defmess()
|
||||
{
|
||||
static Handle(Dico_DictionaryOfTransient) defms;
|
||||
if (defms.IsNull()) defms = new Dico_DictionaryOfTransient();
|
||||
return defms;
|
||||
}
|
||||
|
||||
|
||||
static Standard_Boolean stachr = Standard_False;
|
||||
|
||||
//static OSD_Timer chrono;
|
||||
// because merdouille link dynamique & perf, ne creer le static qu au 1er usage
|
||||
static OSD_Timer& chrono() {
|
||||
static OSD_Timer chr;
|
||||
return chr;
|
||||
}
|
||||
|
||||
|
||||
MoniTool_CaseData::MoniTool_CaseData
|
||||
(const Standard_CString caseid, const Standard_CString name)
|
||||
: thesubst (0) , thecase (caseid) , thename (name)
|
||||
{ thecheck = DefCheck(caseid); }
|
||||
|
||||
void MoniTool_CaseData::SetCaseId (const Standard_CString caseid)
|
||||
{ thecase.Clear(); thecase.AssignCat (caseid); thecheck = DefCheck(caseid); thesubst = 0; }
|
||||
|
||||
void MoniTool_CaseData::SetName (const Standard_CString name)
|
||||
{ thename.Clear(); thename.AssignCat (name); thesubst = 0; }
|
||||
|
||||
Standard_CString MoniTool_CaseData::CaseId () const
|
||||
{ return thecase.ToCString(); }
|
||||
|
||||
Standard_CString MoniTool_CaseData::Name () const
|
||||
{ return thename.ToCString(); }
|
||||
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::IsCheck () const
|
||||
{ return (thecheck > 0); }
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::IsWarning () const
|
||||
{ return (thecheck == 1); }
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::IsFail () const
|
||||
{ return (thecheck == 2); }
|
||||
|
||||
void MoniTool_CaseData::ResetCheck ()
|
||||
{ thecheck = 0; }
|
||||
|
||||
void MoniTool_CaseData::SetWarning ()
|
||||
{ thecheck = 1; }
|
||||
|
||||
void MoniTool_CaseData::SetFail ()
|
||||
{ thecheck = 2; }
|
||||
|
||||
// #### DATA ####
|
||||
|
||||
void MoniTool_CaseData::SetChange ()
|
||||
{ thesubst = -1; }
|
||||
|
||||
void MoniTool_CaseData::SetReplace (const Standard_Integer num)
|
||||
{ thesubst = num; }
|
||||
|
||||
void MoniTool_CaseData::AddData
|
||||
(const Handle(Standard_Transient)& val,
|
||||
const Standard_Integer kind, const Standard_CString name)
|
||||
{
|
||||
TCollection_AsciiString aname(name);
|
||||
Standard_Integer subs = thesubst;
|
||||
|
||||
// SetChange (calculer la position d apres Name)
|
||||
if (thesubst < 0) {
|
||||
if (name[0] != '\0') subs = NameNum (name);
|
||||
}
|
||||
// SetChange / SetReplace
|
||||
if (subs > 0 && subs <= thedata.Length()) {
|
||||
thedata.SetValue (subs,val);
|
||||
thekind.SetValue (subs,kind);
|
||||
if (aname.Length() > 0) thednam.SetValue (subs,aname);
|
||||
// Ajout Normal
|
||||
} else {
|
||||
thedata.Append (val);
|
||||
thekind.Append (kind);
|
||||
thednam.Append (aname);
|
||||
}
|
||||
thesubst = 0;
|
||||
}
|
||||
|
||||
void MoniTool_CaseData::AddRaised (const Standard_CString name)
|
||||
{ AddData ( Standard_Failure::Caught(),1,name); }
|
||||
|
||||
void MoniTool_CaseData::AddShape
|
||||
(const TopoDS_Shape& sh, const Standard_CString name)
|
||||
{ AddData ( new TopoDS_HShape(sh), 4,name); }
|
||||
|
||||
void MoniTool_CaseData::AddXYZ
|
||||
(const gp_XYZ& aXYZ, const Standard_CString name)
|
||||
{ AddData ( new Geom_CartesianPoint (aXYZ), 5,name); }
|
||||
|
||||
void MoniTool_CaseData::AddXY
|
||||
(const gp_XY& aXY, const Standard_CString name)
|
||||
{ AddData ( new Geom2d_CartesianPoint (aXY), 6,name); }
|
||||
|
||||
void MoniTool_CaseData::AddReal
|
||||
(const Standard_Real val, const Standard_CString name)
|
||||
{ AddData ( new Geom2d_CartesianPoint (val,0.), 8,name); }
|
||||
|
||||
void MoniTool_CaseData::AddReals
|
||||
(const Standard_Real v1, const Standard_Real v2, const Standard_CString name)
|
||||
{ AddData ( new Geom2d_CartesianPoint (v1,v2), 7,name); }
|
||||
|
||||
void MoniTool_CaseData::AddCPU
|
||||
(const Standard_Real lastCPU, const Standard_Real curCPU,
|
||||
const Standard_CString name)
|
||||
{
|
||||
Standard_Real cpu = curCPU;
|
||||
if (cpu == 0.) {
|
||||
Standard_Real sec; Standard_Integer i1,i2;
|
||||
chrono().Show (sec,i1,i2,cpu);
|
||||
}
|
||||
cpu = cpu - lastCPU;
|
||||
AddData ( new Geom2d_CartesianPoint (cpu,0.), 9,name);
|
||||
}
|
||||
|
||||
Standard_Real MoniTool_CaseData::GetCPU () const
|
||||
{
|
||||
if (!stachr) { chrono().Start(); stachr = Standard_True; }
|
||||
Standard_Real sec,cpu; Standard_Integer i1,i2;
|
||||
chrono().Show (sec,i1,i2,cpu);
|
||||
return cpu;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::LargeCPU
|
||||
(const Standard_Real maxCPU,
|
||||
const Standard_Real lastCPU, const Standard_Real curCPU) const
|
||||
{
|
||||
Standard_Real cpu = curCPU;
|
||||
if (cpu == 0.) {
|
||||
Standard_Real sec; Standard_Integer i1,i2;
|
||||
chrono().Show (sec,i1,i2,cpu);
|
||||
}
|
||||
cpu = cpu - lastCPU;
|
||||
return (cpu >= maxCPU);
|
||||
}
|
||||
|
||||
void MoniTool_CaseData::AddGeom
|
||||
(const Handle(Standard_Transient)& val, const Standard_CString name)
|
||||
{ AddData (val,3,name); }
|
||||
|
||||
void MoniTool_CaseData::AddEntity
|
||||
(const Handle(Standard_Transient)& val, const Standard_CString name)
|
||||
{ AddData (val,2,name); }
|
||||
|
||||
void MoniTool_CaseData::AddText
|
||||
(const Standard_CString text, const Standard_CString name)
|
||||
{ AddData (new TCollection_HAsciiString(text),10,name); }
|
||||
|
||||
void MoniTool_CaseData::AddInteger
|
||||
(const Standard_Integer val, const Standard_CString name)
|
||||
{
|
||||
Standard_Real rval = val;
|
||||
AddData ( new Geom2d_CartesianPoint (rval,0.), 11,name);
|
||||
}
|
||||
|
||||
void MoniTool_CaseData::AddAny
|
||||
(const Handle(Standard_Transient)& val, const Standard_CString name)
|
||||
{ AddData (val,0,name); }
|
||||
|
||||
|
||||
void MoniTool_CaseData::RemoveData (const Standard_Integer num)
|
||||
{
|
||||
if (num < 1 || num > thedata.Length()) return;
|
||||
thedata.Remove(num); thekind.Remove(num); thednam.Remove(num);
|
||||
}
|
||||
|
||||
// #### INTERROGATIONS ####
|
||||
|
||||
Standard_Integer MoniTool_CaseData::NbData () const
|
||||
{ return thedata.Length(); }
|
||||
|
||||
Handle(Standard_Transient) MoniTool_CaseData::Data
|
||||
(const Standard_Integer nd) const
|
||||
{
|
||||
Handle(Standard_Transient) val;
|
||||
if (nd < 1 || nd > thedata.Length()) return val;
|
||||
return thedata (nd);
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::GetData
|
||||
(const Standard_Integer nd, const Handle(Standard_Type)& type,
|
||||
Handle(Standard_Transient)& val) const
|
||||
{
|
||||
if (type.IsNull()) return Standard_False;
|
||||
if (nd < 1 || nd > thedata.Length()) return Standard_False;
|
||||
Handle(Standard_Transient) v = thedata (nd);
|
||||
if (v.IsNull()) return Standard_False;
|
||||
if (!v->IsKind(type)) return Standard_False;
|
||||
val = v;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Integer MoniTool_CaseData::Kind
|
||||
(const Standard_Integer nd) const
|
||||
{
|
||||
if (nd < 1 || nd > thekind.Length()) return 0;
|
||||
return thekind (nd);
|
||||
}
|
||||
|
||||
|
||||
static const TCollection_AsciiString& nulname ()
|
||||
{
|
||||
static TCollection_AsciiString nuln;
|
||||
return nuln;
|
||||
}
|
||||
|
||||
const TCollection_AsciiString& MoniTool_CaseData::Name
|
||||
(const Standard_Integer nd) const
|
||||
{
|
||||
if (nd < 1 || nd > thednam.Length()) return nulname();
|
||||
return thednam(nd);
|
||||
}
|
||||
|
||||
static Standard_Integer NameKind (const Standard_CString name)
|
||||
{
|
||||
char n0 = name[0];
|
||||
if (n0 == 'A' && name[1] == 'N' && name[2] == 'Y' && name[3] == '\0') return 0;
|
||||
if (n0 == 'E') {
|
||||
if (name[1] == 'X' && name[2] == '\0') return 1;
|
||||
if (name[1] == 'N' && name[2] == '\0') return 2;
|
||||
return 0;
|
||||
}
|
||||
if (n0 == 'G' && name[1] == '\0') return 3;
|
||||
if (n0 == 'S' && name[1] == 'H' && name[2] == '\0') return 4;
|
||||
if (n0 == 'X' && name[1] == 'Y') {
|
||||
if (name[2] == 'Z' && name[3] == '\0') return 5;
|
||||
if (name[2] == '\0') return 6;
|
||||
}
|
||||
if (n0 == 'U' && name[1] == 'V' && name[2] == '\0') return 6;
|
||||
if (n0 == 'R') {
|
||||
if (name[1] == '\0') return 8;
|
||||
if (name[1] == 'R' && name[2] == '\0') return 7;
|
||||
}
|
||||
if (n0 == 'C' && name[1] == 'P' && name[2] == 'U' && name[3] == '\0') return 9;
|
||||
if (n0 == 'T' && name[1] == '\0') return 10;
|
||||
if (n0 == 'I' && name[1] == '\0') return 11;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer NameRank (const Standard_CString name)
|
||||
{
|
||||
for (Standard_Integer i = 0; name[i] != '\0'; i ++) {
|
||||
if (name[i] == ':' && name[i+1] != '\0') return atoi(&name[i+1]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Integer MoniTool_CaseData::NameNum
|
||||
(const Standard_CString name) const
|
||||
{
|
||||
if (!name || name[0] == '\0') return 0;
|
||||
Standard_Integer nd, nn = 0, nb = NbData();
|
||||
for (nd = 1; nd <= nb; nd ++) {
|
||||
if (thednam(nd).IsEqual(name)) return nd;
|
||||
}
|
||||
|
||||
Standard_Integer kind = NameKind (name);
|
||||
if (kind < 0) return 0;
|
||||
Standard_Integer num = NameRank (name);
|
||||
|
||||
for (nd = 1; nd <= nb; nd ++) {
|
||||
if (thekind(nd) == kind) {
|
||||
nn ++;
|
||||
if (nn == num) return nd;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// #### RETOUR DES VALEURS ####
|
||||
|
||||
TopoDS_Shape MoniTool_CaseData::Shape
|
||||
(const Standard_Integer nd) const
|
||||
{
|
||||
TopoDS_Shape sh;
|
||||
Handle(TopoDS_HShape) hs = Handle(TopoDS_HShape)::DownCast (Data(nd));
|
||||
if (!hs.IsNull()) sh = hs->Shape();
|
||||
return sh;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::XYZ
|
||||
(const Standard_Integer nd, gp_XYZ& val) const
|
||||
{
|
||||
Handle(Geom_CartesianPoint) p = Handle(Geom_CartesianPoint)::DownCast(Data(nd));
|
||||
if (p.IsNull()) return Standard_False;
|
||||
val = p->Pnt().XYZ();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::XY
|
||||
(const Standard_Integer nd, gp_XY& val) const
|
||||
{
|
||||
Handle(Geom2d_CartesianPoint) p = Handle(Geom2d_CartesianPoint)::DownCast(Data(nd));
|
||||
if (p.IsNull()) return Standard_False;
|
||||
val = p->Pnt2d().XY();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::Reals
|
||||
(const Standard_Integer nd,
|
||||
Standard_Real& v1, Standard_Real& v2) const
|
||||
{
|
||||
Handle(Geom2d_CartesianPoint) p = Handle(Geom2d_CartesianPoint)::DownCast(Data(nd));
|
||||
if (p.IsNull()) return Standard_False;
|
||||
v1 = p->X(); v2 = p->Y();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::Real
|
||||
(const Standard_Integer nd,
|
||||
Standard_Real& val) const
|
||||
{
|
||||
Handle(Geom2d_CartesianPoint) p = Handle(Geom2d_CartesianPoint)::DownCast(Data(nd));
|
||||
if (p.IsNull()) return Standard_False;
|
||||
val = p->X();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::Text
|
||||
(const Standard_Integer nd,
|
||||
Standard_CString& text) const
|
||||
{
|
||||
Handle(TCollection_HAsciiString) t = Handle(TCollection_HAsciiString)::DownCast(Data(nd));
|
||||
if (t.IsNull()) return Standard_False;
|
||||
text = t->ToCString();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_CaseData::Integer
|
||||
(const Standard_Integer nd,
|
||||
Standard_Integer& val) const
|
||||
{
|
||||
Handle(Geom2d_CartesianPoint) p = Handle(Geom2d_CartesianPoint)::DownCast(Data(nd));
|
||||
// if (p.IsNull()) return Standard_False;
|
||||
if (thekind(nd) != 11) return Standard_False;
|
||||
Standard_Real rval = p->X();
|
||||
val = (Standard_Integer)rval;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
// #### MESSAGES ET DEFINITIONS ####
|
||||
|
||||
Message_Msg MoniTool_CaseData::Msg () const
|
||||
{
|
||||
Standard_CString defm = DefMsg (thecase.ToCString());
|
||||
|
||||
// A REPRENDRE COMPLETEMENT ! Il faut analyser defm = mescode + variables
|
||||
Message_Msg mess;
|
||||
mess.Set (defm);
|
||||
|
||||
return mess;
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_CaseData::SetDefWarning (const Standard_CString acode)
|
||||
{ defchecks()->SetItem (acode,1); }
|
||||
|
||||
void MoniTool_CaseData::SetDefFail (const Standard_CString acode)
|
||||
{ defchecks()->SetItem (acode,2); }
|
||||
|
||||
Standard_Integer MoniTool_CaseData::DefCheck (const Standard_CString acode)
|
||||
{
|
||||
Standard_Integer val;
|
||||
if (!defchecks()->GetItem (acode,val)) val = 0;
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_CaseData::SetDefMsg
|
||||
(const Standard_CString casecode, const Standard_CString mesdef)
|
||||
{
|
||||
Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString (mesdef);
|
||||
defmess()->SetItem (casecode,str);
|
||||
}
|
||||
|
||||
Standard_CString MoniTool_CaseData::DefMsg (const Standard_CString casecode)
|
||||
{
|
||||
//Standard_CString mesd;
|
||||
Handle(TCollection_HAsciiString) str;
|
||||
if (!defmess()->GetItem (casecode,str)) return "";
|
||||
if (str.IsNull()) return "";
|
||||
return str->ToCString();
|
||||
}
|
26
src/MoniTool/MoniTool_DataInfo.cdl
Executable file
26
src/MoniTool/MoniTool_DataInfo.cdl
Executable file
@@ -0,0 +1,26 @@
|
||||
-- File: MoniTool_DataInfo.cdl
|
||||
-- Created: Wed Sep 4 10:47:02 1996
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@fidox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
|
||||
class DataInfo from MoniTool
|
||||
|
||||
---Purpose : Gives informations on an object
|
||||
-- Used as template to instantiate Elem, etc
|
||||
-- This class is for Transient
|
||||
|
||||
uses CString, Transient, Type
|
||||
|
||||
is
|
||||
|
||||
Type (myclass; ent : Transient) returns Type;
|
||||
---Purpose : Returns the Type attached to an object
|
||||
-- Here, the Dynamic Type of a Transient. Null Type if unknown
|
||||
|
||||
TypeName (myclass; ent : Transient) returns CString;
|
||||
---Purpose : Returns Type Name (string)
|
||||
-- Allows to name type of non-handled objects
|
||||
|
||||
end DataInfo;
|
9
src/MoniTool/MoniTool_DataInfo.cxx
Executable file
9
src/MoniTool/MoniTool_DataInfo.cxx
Executable file
@@ -0,0 +1,9 @@
|
||||
#include <MoniTool_DataInfo.ixx>
|
||||
|
||||
Handle(Standard_Type) MoniTool_DataInfo::Type
|
||||
(const Handle(Standard_Transient)& ent)
|
||||
{ return ent->DynamicType(); }
|
||||
|
||||
Standard_CString MoniTool_DataInfo::TypeName
|
||||
(const Handle(Standard_Transient)& ent)
|
||||
{ return ent->DynamicType()->Name(); }
|
53
src/MoniTool/MoniTool_Elem.cdl
Executable file
53
src/MoniTool/MoniTool_Elem.cdl
Executable file
@@ -0,0 +1,53 @@
|
||||
-- File: MoniTool_Elem.cdl
|
||||
-- Created: Fri Nov 4 10:47:55 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@anion>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
generic class Elem from MoniTool
|
||||
(TheKey as any;
|
||||
TheHasher as any;
|
||||
TheInfo as any)
|
||||
inherits Element
|
||||
|
||||
---Purpose : an Elem defines an Element for a specific input class
|
||||
-- its definition includes the value of the Key to be mapped,
|
||||
-- and the HashCoder associated to the class of the Key
|
||||
--
|
||||
-- TheKey defines the class to be keyed
|
||||
-- TheHasher is the associated Hasher
|
||||
-- TheInfo is an additionnal class which helps to provide
|
||||
-- informations on the value (template : see DataInfo)
|
||||
|
||||
uses CString
|
||||
|
||||
is
|
||||
|
||||
Create (akey : any TheKey) returns mutable Elem;
|
||||
---Purpose : Creates a Elem with a Value. This Value can then not be
|
||||
-- changed. It is used by the Hasher to compute the HashCode,
|
||||
-- which will then be stored for an immediate reading.
|
||||
|
||||
Value (me) returns any TheKey is static;
|
||||
---Purpose : Returns the contained value
|
||||
---C++ : return const &
|
||||
|
||||
Equates (me; other : Element) returns Boolean;
|
||||
---Purpose : Specific testof equallity : defined as False if <other> has
|
||||
-- not the same true Type, else contents are compared (by
|
||||
-- C++ operator ==)
|
||||
|
||||
ValueType (me) returns Type is redefined;
|
||||
---Purpose : Returns the Type of the Value. By default, returns the
|
||||
-- DynamicType of <me>, but can be redefined
|
||||
|
||||
ValueTypeName (me) returns CString is redefined;
|
||||
---Purpose : Returns the name of the Type of the Value. Default is name
|
||||
-- of ValueType, unless it is for a non-handled object
|
||||
|
||||
fields
|
||||
|
||||
theval : TheKey;
|
||||
|
||||
end Elem;
|
28
src/MoniTool/MoniTool_Elem.gxx
Executable file
28
src/MoniTool/MoniTool_Elem.gxx
Executable file
@@ -0,0 +1,28 @@
|
||||
//#include <MoniTool_Elem.ixx>
|
||||
#include <Standard_Integer.hxx>
|
||||
|
||||
|
||||
MoniTool_Elem::MoniTool_Elem (const TheKey& akey)
|
||||
: theval (akey)
|
||||
{ SetHashCode ( TheHasher::HashCode (akey, IntegerLast() ) ); }
|
||||
|
||||
|
||||
const TheKey& MoniTool_Elem::Value () const
|
||||
{ return theval; }
|
||||
|
||||
Standard_Boolean MoniTool_Elem::Equates
|
||||
(const Handle(MoniTool_Element)& other) const
|
||||
{
|
||||
if (other.IsNull()) return Standard_False;
|
||||
if (GetHashCode() != other->GetHashCode()) return Standard_False;
|
||||
if (other->DynamicType() != DynamicType()) return Standard_False;
|
||||
Handle(MoniTool_Elem) another = Handle(MoniTool_Elem)::DownCast(other);
|
||||
// return (theval == another->Value());
|
||||
return TheHasher::IsEqual (theval,another->Value());
|
||||
}
|
||||
|
||||
Handle(Standard_Type) MoniTool_Elem::ValueType () const
|
||||
{ return TheInfo::Type(theval); }
|
||||
|
||||
Standard_CString MoniTool_Elem::ValueTypeName () const
|
||||
{ return TheInfo::TypeName(theval); }
|
31
src/MoniTool/MoniTool_ElemHasher.cdl
Executable file
31
src/MoniTool/MoniTool_ElemHasher.cdl
Executable file
@@ -0,0 +1,31 @@
|
||||
-- File: MoniTool_ElemHasher.cdl
|
||||
-- Created: Fri Nov 4 11:06:49 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@anion>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class ElemHasher from MoniTool
|
||||
|
||||
---Purpose : ElemHasher defines HashCode for Element, which is : ask a
|
||||
-- Element its HashCode ! Because this is the Element itself
|
||||
-- which brings the HashCode for its Key
|
||||
--
|
||||
-- This class complies to the template given in TCollection by
|
||||
-- MapHasher itself
|
||||
|
||||
uses Element
|
||||
|
||||
is
|
||||
|
||||
HashCode (myclass; K : Element; Upper : Integer) returns Integer;
|
||||
---Purpose : Returns a HashCode in the range <0,Upper> for a Element :
|
||||
-- asks the Element its HashCode then transforms it to be in the
|
||||
-- required range
|
||||
|
||||
IsEqual (myclass; K1, K2 : Element) returns Boolean;
|
||||
---Purpose : Returns True if two keys are the same.
|
||||
-- The test does not work on the Elements themselves but by
|
||||
-- calling their methods Equates
|
||||
|
||||
end ElemHasher;
|
15
src/MoniTool/MoniTool_ElemHasher.cxx
Executable file
15
src/MoniTool/MoniTool_ElemHasher.cxx
Executable file
@@ -0,0 +1,15 @@
|
||||
#include <MoniTool_ElemHasher.ixx>
|
||||
|
||||
|
||||
Standard_Integer MoniTool_ElemHasher::HashCode
|
||||
(const Handle(MoniTool_Element)& K, const Standard_Integer Upper)
|
||||
{
|
||||
return ((K->GetHashCode() - 1) % Upper) + 1;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_ElemHasher::IsEqual
|
||||
(const Handle(MoniTool_Element)& K1, const Handle(MoniTool_Element)& K2)
|
||||
{
|
||||
if (K1.IsNull()) return Standard_False;
|
||||
return K1->Equates(K2);
|
||||
}
|
57
src/MoniTool/MoniTool_Element.cdl
Executable file
57
src/MoniTool/MoniTool_Element.cdl
Executable file
@@ -0,0 +1,57 @@
|
||||
-- File: MoniTool_Element.cdl
|
||||
-- Created: Fri Nov 4 10:59:26 1994
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@anion>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
deferred class Element from MoniTool inherits TShared
|
||||
|
||||
---Purpose : a Element allows to map any kind of object as a Key for a Map.
|
||||
-- This works by defining, for a Hash Code, that of the real Key,
|
||||
-- not of the Element which acts only as an intermediate.
|
||||
-- When a Map asks for the HashCode of a Element, this one returns
|
||||
-- the code it has determined at creation time
|
||||
|
||||
uses CString, Type, Transient, AttrList from MoniTool
|
||||
|
||||
is
|
||||
|
||||
SetHashCode (me : mutable; code : Integer) is static protected;
|
||||
---Purpose : Stores the HashCode which corresponds to the Value given to
|
||||
-- create the Mapper
|
||||
|
||||
GetHashCode (me) returns Integer is static;
|
||||
---Purpose : Returns the HashCode which has been stored by SetHashCode
|
||||
-- (remark that HashCode could be deferred then be defined by
|
||||
-- sub-classes, the result is the same)
|
||||
|
||||
Equates (me; other : Element) returns Boolean is deferred;
|
||||
---Purpose : Specific testof equallity : to be defined by each sub-class,
|
||||
-- must be False if Elements have not the same true Type, else
|
||||
-- their contents must be compared
|
||||
|
||||
ValueType (me) returns Type is virtual;
|
||||
---Purpose : Returns the Type of the Value. By default, returns the
|
||||
-- DynamicType of <me>, but can be redefined
|
||||
|
||||
ValueTypeName (me) returns CString is virtual;
|
||||
---Purpose : Returns the name of the Type of the Value. Default is name
|
||||
-- of ValueType, unless it is for a non-handled object
|
||||
|
||||
-- -- Attributes
|
||||
|
||||
ListAttr (me) returns AttrList;
|
||||
---Purpose : Returns (readonly) the Attribute List
|
||||
---C++ : return const &
|
||||
|
||||
ChangeAttr (me : mutable) returns AttrList;
|
||||
---Purpose : Returns (modifiable) the Attribute List
|
||||
---C++ : return &
|
||||
|
||||
fields
|
||||
|
||||
thecode : Integer;
|
||||
theattrib : AttrList;
|
||||
|
||||
end Element;
|
24
src/MoniTool/MoniTool_Element.cxx
Executable file
24
src/MoniTool/MoniTool_Element.cxx
Executable file
@@ -0,0 +1,24 @@
|
||||
#include <MoniTool_Element.ixx>
|
||||
|
||||
|
||||
void MoniTool_Element::SetHashCode (const Standard_Integer code)
|
||||
{ thecode = code; }
|
||||
|
||||
Standard_Integer MoniTool_Element::GetHashCode () const
|
||||
{ return thecode; }
|
||||
|
||||
Handle(Standard_Type) MoniTool_Element::ValueType () const
|
||||
{ return DynamicType(); }
|
||||
|
||||
Standard_CString MoniTool_Element::ValueTypeName () const
|
||||
{ return "(finder)"; }
|
||||
|
||||
|
||||
// #### ATTRIBUTES ####
|
||||
|
||||
|
||||
const MoniTool_AttrList& MoniTool_Element::ListAttr () const
|
||||
{ return theattrib; }
|
||||
|
||||
MoniTool_AttrList& MoniTool_Element::ChangeAttr ()
|
||||
{ return theattrib; }
|
27
src/MoniTool/MoniTool_IntVal.cdl
Executable file
27
src/MoniTool/MoniTool_IntVal.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: MoniTool_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 MoniTool inherits TShared from MMgt
|
||||
|
||||
---Purpose : An Integer through a Handle (i.e. managed as TShared)
|
||||
|
||||
uses Integer
|
||||
|
||||
is
|
||||
|
||||
Create (val : Integer = 0) returns mutable IntVal;
|
||||
|
||||
Value (me) returns Integer;
|
||||
|
||||
CValue (me : mutable) returns Integer;
|
||||
---C++ : return &
|
||||
|
||||
fields
|
||||
|
||||
theval : Integer;
|
||||
|
||||
end IntVal;
|
7
src/MoniTool/MoniTool_IntVal.cxx
Executable file
7
src/MoniTool/MoniTool_IntVal.cxx
Executable file
@@ -0,0 +1,7 @@
|
||||
#include <MoniTool_IntVal.ixx>
|
||||
|
||||
MoniTool_IntVal::MoniTool_IntVal (const Standard_Integer val) { theval = val; }
|
||||
|
||||
Standard_Integer MoniTool_IntVal::Value () const { return theval; }
|
||||
|
||||
Standard_Integer& MoniTool_IntVal::CValue () { return theval; }
|
28
src/MoniTool/MoniTool_MTHasher.cdl
Executable file
28
src/MoniTool/MoniTool_MTHasher.cdl
Executable file
@@ -0,0 +1,28 @@
|
||||
-- File: MoniTool_MTHasher.cdl
|
||||
-- Created: Thu Dec 19 12:18:43 2001
|
||||
-- Author: Sergey KUUL
|
||||
-- <skl@polox>
|
||||
---Copyright: Matra Datavision 2001
|
||||
|
||||
|
||||
class MTHasher from MoniTool
|
||||
|
||||
---Purpose:
|
||||
-- The auxiliary class provides hash code for mapping objects
|
||||
|
||||
is
|
||||
|
||||
HashCode(myclass; Str : CString; Upper : Integer) returns Integer;
|
||||
---C++: inline
|
||||
---Purpose: Returns a HasCode value for the CString <Str> in the
|
||||
-- range 0..Upper.
|
||||
-- Default ::HashCode(Str,Upper)
|
||||
|
||||
IsEqual(myclass; Str1, Str2 : CString) returns Boolean;
|
||||
---C++: inline
|
||||
---Purpose: Returns True when the two CString are the same. Two
|
||||
-- same strings must have the same hashcode, the
|
||||
-- contrary is not necessary.
|
||||
-- Default Str1 == Str2
|
||||
|
||||
end MTHasher;
|
5
src/MoniTool/MoniTool_MTHasher.cxx
Executable file
5
src/MoniTool/MoniTool_MTHasher.cxx
Executable file
@@ -0,0 +1,5 @@
|
||||
// File: MoniTool_MTHasher.cxx
|
||||
// Created: Thu Dec 19 12:41:51 2001
|
||||
// Author: Sergey KUUL
|
||||
// <skl@polox>
|
||||
|
25
src/MoniTool/MoniTool_MTHasher.lxx
Executable file
25
src/MoniTool/MoniTool_MTHasher.lxx
Executable file
@@ -0,0 +1,25 @@
|
||||
#include <string.h>
|
||||
|
||||
//=======================================================================
|
||||
//function : HashCode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer MoniTool_MTHasher::HashCode(const Standard_CString Str,
|
||||
const Standard_Integer Upper)
|
||||
{
|
||||
return ::HashCode(Str,Upper);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsEqual
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean MoniTool_MTHasher::IsEqual(const Standard_CString Str1,
|
||||
const Standard_CString Str2)
|
||||
{
|
||||
return ! strcmp(Str1,Str2);
|
||||
}
|
||||
|
||||
|
29
src/MoniTool/MoniTool_Macros.hxx
Executable file
29
src/MoniTool/MoniTool_Macros.hxx
Executable file
@@ -0,0 +1,29 @@
|
||||
// File: MoniTool_Macros.hxx
|
||||
// Created: Mon Nov 22 17:23:11 1999
|
||||
// Author: data exchange team
|
||||
// <det@kinox>
|
||||
|
||||
// Taken from Interface_Macros to avoid cyclic dependency from Shape Healing
|
||||
|
||||
#ifndef MoniTool_Macros_HeaderFile
|
||||
#define MoniTool_Macros_HeaderFile
|
||||
|
||||
// Interface General purpose Macros
|
||||
// Their use is not required, but it gets some program parts easier :
|
||||
// DownCasting, with or without Declaration
|
||||
|
||||
// DownCasting to a "Handle" already declared
|
||||
#define GetCasted(atype,start) Handle(atype)::DownCast(start)
|
||||
|
||||
// DownCasting with Declaration :
|
||||
// - Declares the variable result
|
||||
// - then performs DownCasting
|
||||
// - after it, result can be used as a new variable
|
||||
#define DeclareAndCast(atype,result,start) \
|
||||
Handle(atype) result = Handle(atype)::DownCast(start)
|
||||
|
||||
#define FastCast(atype,result,start) \
|
||||
Handle(atype) result; result = (*(Handle(atype)*))& start
|
||||
|
||||
|
||||
#endif
|
100
src/MoniTool/MoniTool_OptValue.cdl
Executable file
100
src/MoniTool/MoniTool_OptValue.cdl
Executable file
@@ -0,0 +1,100 @@
|
||||
-- File: MoniTool_OptValue.cdl
|
||||
-- Created: Fri Dec 17 10:52:31 1999
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@heliox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1999
|
||||
|
||||
|
||||
class OptValue from MoniTool
|
||||
|
||||
---Purpose : This class allows two kinds of use
|
||||
--
|
||||
-- As an object, a OptValue can be put in any operator or
|
||||
-- algorithm ... to use an Option of a Profile, by recording
|
||||
-- its value, hence avoiding to query the Profile eachtime
|
||||
--
|
||||
-- This object brings a value which can be set as coming from a
|
||||
-- Profile, with a configuration name and for an Option name
|
||||
-- This value is evaluated then returned immediately
|
||||
--
|
||||
-- As a class, it can be redefined to work on a dedicated
|
||||
-- Profile, provided by such or such specific way (as static
|
||||
-- context for instance)
|
||||
--
|
||||
-- To change configuration, etc... can be done by querying and
|
||||
-- editing the Profile
|
||||
|
||||
uses AsciiString from TCollection, Transient,
|
||||
Profile from MoniTool
|
||||
|
||||
is
|
||||
|
||||
Create (opt : CString = "") returns OptValue;
|
||||
---Purpose : Creates an OptValue on a given Option
|
||||
-- This allows to use "shortcut" method to set the value
|
||||
--
|
||||
-- WARNING : loading is not done at creation time. It must be
|
||||
-- done explicitly by call to Load
|
||||
--
|
||||
-- The reason comes from C++ : the Profile being virtual, and
|
||||
-- intended to be redefined in sub-classes, must not be used in
|
||||
-- the constructor. A separate method, called on the object
|
||||
-- already created with its true type, must be called after
|
||||
|
||||
-- Methods to set an OptValue
|
||||
-- Two kinds : basic methods (which require complete set of arguments)
|
||||
-- and shortcuts (which allow to use pre-defined Profile and Option)
|
||||
|
||||
-- Basic Methods
|
||||
|
||||
Clear (me : in out);
|
||||
---Purpose : Clears the Value of the OptValue
|
||||
|
||||
SetValue (me : in out; prof : Profile; opt : CString; fast : Boolean = Standard_True);
|
||||
---Purpose : Sets the value as coming from the Profile, according to an
|
||||
-- Option name. Access as Fast or regular
|
||||
-- If no value is available, the former one remains : can be
|
||||
-- cleared by call to Clear
|
||||
|
||||
-- Context
|
||||
-- It is defined by the Option name given when creating the OptValue,
|
||||
-- and the Profile, provided by a specific virtual method : Prof
|
||||
|
||||
Prof (me) returns Profile is virtual;
|
||||
---Purpose : Returns the Profile which can be used by Short Cut methods
|
||||
-- Defaults returns a Null Handle, can be redefined
|
||||
-- For instance, to return a static used as dictionary or context
|
||||
|
||||
-- Short Cuts
|
||||
-- They suppose that Profile is provided and that Option name has been
|
||||
-- given when creating
|
||||
|
||||
Load (me : in out; fast : Boolean = Standard_True);
|
||||
---Purpose : Sets the value from the Profile returned by method Prof,
|
||||
-- and Option Name given at creation time.
|
||||
-- FastValue by default, else Value
|
||||
--
|
||||
-- Does not check if already loaded : reloads anyway
|
||||
-- IsLoaded allows to test
|
||||
|
||||
-- Returned Value
|
||||
|
||||
IsLoaded (me) returns Boolean;
|
||||
---Purpose : Says if the OptValue is already loaded (i.e. Value defined)
|
||||
|
||||
Value (me; val : out Transient);
|
||||
---Purpose : Returns the Value set by, either SetConf or SetValue
|
||||
-- Can be Null ... (if not set or not properly set)
|
||||
--
|
||||
-- Returned as Argument, hence avoiding DownCast
|
||||
-- Warning : type is not controlled
|
||||
|
||||
Delete (me:out) is virtual;
|
||||
---C++: alias "Standard_EXPORT virtual ~MoniTool_OptValue() { Delete(); }"
|
||||
|
||||
fields
|
||||
|
||||
theopt : AsciiString;
|
||||
theval : Transient;
|
||||
|
||||
end OptValue;
|
48
src/MoniTool/MoniTool_OptValue.cxx
Executable file
48
src/MoniTool/MoniTool_OptValue.cxx
Executable file
@@ -0,0 +1,48 @@
|
||||
#include <MoniTool_OptValue.ixx>
|
||||
|
||||
MoniTool_OptValue::MoniTool_OptValue (const Standard_CString opt)
|
||||
: theopt (opt)
|
||||
{
|
||||
// CKY: NO CALL TO A VIRTUAL METHOD WITHIN THE CONSTRUCTOR
|
||||
// Explicite Load must be done after creation
|
||||
}
|
||||
|
||||
void MoniTool_OptValue::Clear ()
|
||||
{ theval.Nullify(); }
|
||||
|
||||
void MoniTool_OptValue::SetValue
|
||||
(const Handle(MoniTool_Profile)& prof,
|
||||
const Standard_CString opt, const Standard_Boolean fast)
|
||||
{
|
||||
if (prof.IsNull()) return;
|
||||
if (!opt || opt[0] == '\0') return;
|
||||
Handle(Standard_Transient) val;
|
||||
if (fast) prof->FastValue (opt,val);
|
||||
else prof->Value (opt,val);
|
||||
if (!val.IsNull()) theval = val;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean MoniTool_OptValue::IsLoaded () const
|
||||
{ return (!theval.IsNull()); }
|
||||
|
||||
Handle(MoniTool_Profile) MoniTool_OptValue::Prof () const
|
||||
{
|
||||
Handle(MoniTool_Profile) prof;
|
||||
return prof;
|
||||
}
|
||||
|
||||
void MoniTool_OptValue::Load (const Standard_Boolean fast)
|
||||
{ SetValue (Prof(),theopt.ToCString(),fast); }
|
||||
|
||||
|
||||
void MoniTool_OptValue::Value (Handle(Standard_Transient)& val) const
|
||||
{ val = theval; }
|
||||
|
||||
//=======================================================================
|
||||
//function : Delete
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void MoniTool_OptValue::Delete()
|
||||
{}
|
135
src/MoniTool/MoniTool_Option.cdl
Executable file
135
src/MoniTool/MoniTool_Option.cdl
Executable file
@@ -0,0 +1,135 @@
|
||||
-- File: MoniTool_Option.cdl
|
||||
-- Created: Mon Dec 14 10:28:14 1998
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@heliox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Option from MoniTool inherits TShared from MMgt
|
||||
|
||||
---Purpose : An Option gives a way of recording an enumerated list of
|
||||
-- instances of a given class, each instance being identified
|
||||
-- by a case name.
|
||||
--
|
||||
-- Also, an Option allows to manage basic types through a Typed
|
||||
-- Value (which also applies to Static Parameter). It may record
|
||||
-- an enumerated list of values for a TypedValue or Static
|
||||
-- Parameter, each of them is recorded as a string (HAsciiString)
|
||||
--
|
||||
-- An Option is defined by the type of the class to be optioned,
|
||||
-- or (mutually exclusive) the TypedValue/Static of which values
|
||||
-- are to be optioned, a specific name, a list of named values.
|
||||
-- It brings a current case with its name and value
|
||||
-- It may also have a default case (the first recorded one if not
|
||||
-- precised)
|
||||
--
|
||||
-- An Option may be created from another one, by sharing its Type
|
||||
-- and its list of Items (one per case), with the same name or
|
||||
-- another one. It may then be duplicated to break this sharing.
|
||||
|
||||
uses CString, Transient, Type from Standard,
|
||||
AsciiString from TCollection, HSequenceOfAsciiString from TColStd,
|
||||
DictionaryOfTransient from Dico, TypedValue from MoniTool
|
||||
|
||||
is
|
||||
|
||||
Create (atype : Type; aname : CString) returns mutable Option;
|
||||
---Purpose : Creates an Option from scratch, with a Type and a Name
|
||||
|
||||
Create (aval : TypedValue; aname : CString = "") returns mutable Option;
|
||||
---Purpose : Creates an Option for a TypedValue (for basic, non-cdl-typed,
|
||||
-- value : integer, real, string ...)
|
||||
-- If <name> is not given, the name of the TypedValue is taken
|
||||
-- Remark that Type is then enforced to TCollection_HAsciiString
|
||||
|
||||
Create (other : Option; aname : CString = "") returns mutable Option;
|
||||
---Purpose : Creates an Option from another one, the name can be redefined
|
||||
-- The Type remains the same. The list of Items, too, it can also
|
||||
-- be later duplicated by call to Duplicate
|
||||
|
||||
Add (me : mutable; name : CString; val : Transient) returns Boolean;
|
||||
---Purpose : Adds an item : value and name (replaces it if name is already
|
||||
-- recorded)
|
||||
-- Returns True when done, False if <val> is not Kind of the
|
||||
-- definition Type
|
||||
-- For a TypedValue, val must be a HAsciiString, its content must
|
||||
-- satisfy the definition of the TypedValue
|
||||
|
||||
AddBasic (me : mutable; name : CString; val : CString = "") returns Boolean;
|
||||
---Purpose : Short-cut to add an item for a TypedValue (basic type) : name
|
||||
-- is the name of the case, val is its value as a CString
|
||||
-- If val is not provided, val = name is assumed
|
||||
-- Returns True when done, False if this Option is not for a
|
||||
-- TypedValue or if the new value does not satisfy the definition
|
||||
-- of the TypedValue
|
||||
|
||||
Duplicate (me : mutable);
|
||||
---Purpose : Duplicates the list of items
|
||||
-- It starts with the same definitions as before Duplicate, but
|
||||
-- it is not longer shared with other options
|
||||
|
||||
Name (me) returns AsciiString;
|
||||
---Purpose : Returns the Name of the Option
|
||||
---C++ : return const &
|
||||
|
||||
Type (me) returns Type;
|
||||
---Purpose : Returns the Type of the Option
|
||||
|
||||
TypedValue (me) returns TypedValue;
|
||||
---Purpose : Returns the TypedValue of the Option, or a Null Handle
|
||||
|
||||
Items (me) returns DictionaryOfTransient is private;
|
||||
---Purpose : Returns the list of items, to be shared (to copy an option)
|
||||
|
||||
Item (me; name : CString; val : out Transient) returns Boolean;
|
||||
---Purpose : Gives the value bound with a name, in val
|
||||
-- Returns True if <name> is found, False else
|
||||
-- This way of returning a Transient, bound with the Type Control
|
||||
-- avoids DownCast and ensures the value is directly usable
|
||||
|
||||
ItemList (me) returns HSequenceOfAsciiString;
|
||||
---Purpose : Returns the list of available item names
|
||||
|
||||
Aliases (me; name : CString; exact : Boolean = Standard_True)
|
||||
returns HSequenceOfAsciiString;
|
||||
---Purpose : Returns the list of cases, other than <name>, which bring the
|
||||
-- same value as <name>
|
||||
-- Empty list (not a Null Handle) if no alias, or <name> unknown
|
||||
-- if <exact> is True (D), exact name is required, no completion
|
||||
-- if <exact> is False and <name> is not complete, but addresses
|
||||
-- only one item, completion is done and the list includes the
|
||||
-- complete name
|
||||
|
||||
-- Switch actions
|
||||
|
||||
Switch (me : mutable; name : CString) returns Boolean;
|
||||
---Purpose : Commands the Option to switch on an item name
|
||||
-- Returns True when done, False if <name> is not recorded
|
||||
-- (in that case, former switch remains unchanged)
|
||||
-- If no switch has been called, it is active on the last added
|
||||
-- items
|
||||
|
||||
CaseName (me) returns AsciiString from TCollection;
|
||||
---Purpose : Returns the Name of the currently switched item (Case)
|
||||
---C++ : return const &
|
||||
|
||||
CaseValue (me) returns Transient;
|
||||
---Purpose : Returns the Value of the currently switch item
|
||||
-- To be down-casted as needed before use
|
||||
|
||||
Value (me; val : out Transient);
|
||||
---Purpose : Returns the Value of the currently switch item
|
||||
-- This way of returning a Transient, bound with the Type Control
|
||||
-- avoids DownCast and ensures the value is directly usable
|
||||
-- For a TypedValue, returns the corresponding HAsciiString
|
||||
|
||||
fields
|
||||
|
||||
thename : AsciiString;
|
||||
thetype : Type;
|
||||
thevalue : TypedValue;
|
||||
theitems : DictionaryOfTransient;
|
||||
thecase : AsciiString;
|
||||
theval : Transient;
|
||||
|
||||
end Option;
|
131
src/MoniTool/MoniTool_Option.cxx
Executable file
131
src/MoniTool/MoniTool_Option.cxx
Executable file
@@ -0,0 +1,131 @@
|
||||
#include <MoniTool_Option.ixx>
|
||||
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
|
||||
|
||||
MoniTool_Option::MoniTool_Option
|
||||
(const Handle(Standard_Type)& atype, const Standard_CString aname)
|
||||
: thename (aname) , thetype (atype)
|
||||
{ theitems = new Dico_DictionaryOfTransient(); }
|
||||
|
||||
MoniTool_Option::MoniTool_Option
|
||||
(const Handle(MoniTool_TypedValue)& aval, const Standard_CString aname)
|
||||
: thename (aname) ,
|
||||
thetype (STANDARD_TYPE(TCollection_HAsciiString)) ,
|
||||
thevalue (aval)
|
||||
{ theitems = new Dico_DictionaryOfTransient();
|
||||
if (thename.Length() == 0) thename.AssignCat (aval->Name()); }
|
||||
|
||||
MoniTool_Option::MoniTool_Option
|
||||
(const Handle(MoniTool_Option)& other, const Standard_CString aname)
|
||||
: thename (aname) ,
|
||||
thetype (other->Type()) ,
|
||||
thevalue (other->TypedValue()) ,
|
||||
theitems (other->Items())
|
||||
{
|
||||
if (thename.Length() == 0) thename.AssignCat (other->Name());
|
||||
thecase.Clear(); thecase.AssignCat (other->CaseName());
|
||||
other->Value(theval);
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_Option::Add
|
||||
(const Standard_CString name, const Handle(Standard_Transient)& val)
|
||||
{
|
||||
if (val.IsNull()) return Standard_False;
|
||||
if (!val->IsKind (thetype)) return Standard_False;
|
||||
if (!thevalue.IsNull()) {
|
||||
Handle(TCollection_HAsciiString) str = Handle(TCollection_HAsciiString)::DownCast(val);
|
||||
if (str.IsNull()) return Standard_False;
|
||||
if (!thevalue->Satisfies(str)) return Standard_False;
|
||||
}
|
||||
theitems->SetItem (name,val);
|
||||
thecase.Clear(); thecase.AssignCat (name); // switch mis a jour par defaut
|
||||
theval = val;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_Option::AddBasic
|
||||
(const Standard_CString name, const Standard_CString val)
|
||||
{
|
||||
if (thevalue.IsNull()) return Standard_False;
|
||||
Handle(TCollection_HAsciiString) str;
|
||||
if (val && val[0] != '\0') str = new TCollection_HAsciiString (val);
|
||||
else str = new TCollection_HAsciiString (name);
|
||||
return Add (name,str);
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_Option::Duplicate ()
|
||||
{
|
||||
Handle(Dico_DictionaryOfTransient) items = new Dico_DictionaryOfTransient();
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theitems);
|
||||
for (; iter.More(); iter.Next())
|
||||
items->SetItem (iter.Name().ToCString(),iter.Value());
|
||||
theitems = items;
|
||||
}
|
||||
|
||||
const TCollection_AsciiString& MoniTool_Option::Name () const
|
||||
{ return thename; }
|
||||
|
||||
Handle(Standard_Type) MoniTool_Option::Type () const
|
||||
{ return thetype; }
|
||||
|
||||
Handle(MoniTool_TypedValue) MoniTool_Option::TypedValue () const
|
||||
{ return thevalue; }
|
||||
|
||||
Handle(Dico_DictionaryOfTransient) MoniTool_Option::Items () const
|
||||
{ return theitems; }
|
||||
|
||||
Standard_Boolean MoniTool_Option::Item
|
||||
(const Standard_CString name, Handle(Standard_Transient)& val) const
|
||||
{
|
||||
Handle(Standard_Transient) v;
|
||||
if (!theitems->GetItem (name,v)) return Standard_False;
|
||||
val = v;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) MoniTool_Option::ItemList () const
|
||||
{
|
||||
Handle(TColStd_HSequenceOfAsciiString) list = new TColStd_HSequenceOfAsciiString();
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theitems);
|
||||
for (; iter.More(); iter.Next()) list->Append (iter.Name());
|
||||
return list;
|
||||
}
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) MoniTool_Option::Aliases
|
||||
(const Standard_CString name, const Standard_Boolean exact) const
|
||||
{
|
||||
Handle(TColStd_HSequenceOfAsciiString) list = new TColStd_HSequenceOfAsciiString();
|
||||
Handle(Standard_Transient) v;
|
||||
if (!theitems->GetItem (name,v, exact)) return list;
|
||||
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theitems);
|
||||
for (; iter.More(); iter.Next()) {
|
||||
if (iter.Value() != v) continue;
|
||||
TCollection_AsciiString itname = iter.Name();
|
||||
if (!itname.IsEqual(name)) list->Append (itname);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// #### SWITCH ACTIONS ####
|
||||
|
||||
Standard_Boolean MoniTool_Option::Switch (const Standard_CString name)
|
||||
{
|
||||
Handle(Standard_Transient) val;
|
||||
if (!theitems->GetItem (name,val)) return Standard_False;
|
||||
thecase.Clear(); thecase.AssignCat (name);
|
||||
theval = val;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
const TCollection_AsciiString& MoniTool_Option::CaseName () const
|
||||
{ return thecase; }
|
||||
|
||||
Handle(Standard_Transient) MoniTool_Option::CaseValue () const
|
||||
{ return theval; }
|
||||
|
||||
void MoniTool_Option::Value (Handle(Standard_Transient)& val) const
|
||||
{ if (!theval.IsNull()) val = theval; }
|
205
src/MoniTool/MoniTool_Profile.cdl
Executable file
205
src/MoniTool/MoniTool_Profile.cdl
Executable file
@@ -0,0 +1,205 @@
|
||||
-- File: MoniTool_Profile.cdl
|
||||
-- Created: Mon Dec 14 12:50:18 1998
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@heliox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class Profile from MoniTool inherits TShared from MMgt
|
||||
|
||||
---Purpose : A Profile gives access to a set of options :
|
||||
-- - it defines and gives access to options, by names specific
|
||||
-- to this Profile, defaulted to basic names of the Options
|
||||
-- - it records one or more Configurations, each of one is
|
||||
-- identified by a name, and commands for each option a switch
|
||||
-- value
|
||||
-- - a Configuration may be partial, i.e. concern only a subset
|
||||
-- of the complete list of options
|
||||
-- - Values are accessed through a Current Configuration, which
|
||||
-- name is fixed as ".", which can cumulate several
|
||||
-- configurations (especially when they are partial)
|
||||
--
|
||||
-- It may also bring a "fast" access to values, which has been
|
||||
-- formerly computed from current configuration or another given
|
||||
-- one. But its up-to-date status regarding existing
|
||||
-- configurations is not checked : it may be recomputed or
|
||||
-- cleared at any time. If not set, the current configuration
|
||||
-- is then taken
|
||||
|
||||
uses CString, Transient, AsciiString from TCollection,
|
||||
HSequenceOfAsciiString from TColStd,
|
||||
DictionaryOfTransient from Dico,
|
||||
Option
|
||||
|
||||
is
|
||||
|
||||
Create returns Profile;
|
||||
---Purpose : Creates an empty Profile, with an empty Current Configuration
|
||||
-- (named ".")
|
||||
|
||||
-- Declaration of the Options
|
||||
|
||||
AddOption (me : mutable; option : Option; name : CString = "");
|
||||
---Purpose : Adds an Option, with a Name, by default takes the Name of the
|
||||
-- Option
|
||||
|
||||
Option (me; name : CString) returns Option;
|
||||
---Purpose : Returns an Option from its Name. Null Handle if unknown
|
||||
|
||||
OptionList (me) returns HSequenceOfAsciiString;
|
||||
---Purpose : Returns the list of Option Names
|
||||
|
||||
TypedValueList (me) returns HSequenceOfAsciiString;
|
||||
---Purpose : Returns the list of Option Names which are defined on a
|
||||
-- TypedValue/Static, i.e. for Basic Type
|
||||
|
||||
-- Declaration of the Configurations
|
||||
|
||||
NewConf (me : mutable; confname : CString);
|
||||
---Purpose : Adds a new Configuration, yet empty, then filled by AddSwitch
|
||||
-- If <confname> already existed, it is replaced from scratch
|
||||
-- While AddConf creates new Conf only if it does not yet exist
|
||||
--
|
||||
-- Remark : the Current Configuration "." may not be changed
|
||||
|
||||
AddConf (me : mutable; confname : CString);
|
||||
---Purpose : Adds a new Configuration, yet empty, then filled by AddSwitch
|
||||
-- If <confname> already existed, it is kept as it is
|
||||
-- While NewConf restrts from scratch anyway
|
||||
--
|
||||
-- Remark : the Current Configuration "." may not be changed
|
||||
|
||||
HasConf (me; confname : CString) returns Boolean;
|
||||
---Purpose : Tells if <confname> is known as a Configuration
|
||||
|
||||
ConfList (me) returns HSequenceOfAsciiString;
|
||||
---Purpose : Returns the list of Configuration Names, including Current "."
|
||||
|
||||
Conf (me; confname : CString) returns DictionaryOfTransient is private;
|
||||
---Purpose : Internal
|
||||
|
||||
ClearConf (me : mutable; confname : CString) returns Boolean;
|
||||
---Purpose : Clears a configuration (does not remove it)
|
||||
-- A cleared configuration has no effect, it can be reloaded
|
||||
|
||||
AddFromOtherConf (me : mutable; confname, otherconf : CString) returns Boolean;
|
||||
---Purpose : Adds the definitions from the configuration <otherconf> to
|
||||
-- those of <confname>
|
||||
-- Returns True if done, False if confname or otherconf are unknown
|
||||
|
||||
SetFromCurrent (me : mutable; confname : CString) returns Boolean;
|
||||
---Purpose : Sets the definitions of a configuration from the actual state
|
||||
-- (current configuration plus current state of options for those
|
||||
-- which are not recorded in current conf)
|
||||
|
||||
AddSwitch (me : mutable; confname, optname : CString; casename : CString = "") returns Boolean;
|
||||
---Purpose : Adds to the Configuration <confname>, for the option <optname>
|
||||
-- the command to switch it to <casename>
|
||||
-- If <casename> is not given, records the actual current
|
||||
-- CaseName of this Option
|
||||
-- Returns True if done, False if <confname> or <optname> is
|
||||
-- unknown, or <casename> not allowed for <optname>
|
||||
|
||||
RemoveSwitch (me : mutable; confname, optname : CString) returns Boolean;
|
||||
---Purpose : Removes from the Configuration <confname>, the switch for the
|
||||
-- option <optname>. Hence, it will consider the basic default
|
||||
-- switch for this option
|
||||
-- Returns True if done or switch was not recorded, False if
|
||||
-- <confname> or <optname> is unknown
|
||||
|
||||
SwitchList (me; confname : CString;
|
||||
optlist, caselist : out HSequenceOfAsciiString);
|
||||
---Purpose : Returns the list of switches properly concerned by a config :
|
||||
-- two lists in parallel, <optlist> lists the names of options
|
||||
-- and for each one, <caselist> gives the case for this config
|
||||
|
||||
|
||||
-- Access to the state (Configuration)
|
||||
|
||||
SetCurrent (me : mutable; confname : CString) returns Boolean;
|
||||
---Purpose : Copies (Cumulates) the definition of <confname> to current
|
||||
-- Records the current name as the last current setting
|
||||
--
|
||||
-- Returns True if done, False (and does nothing> if <confname>
|
||||
-- is not recorded as a Configuration
|
||||
-- If no SetCurrent has been called, the last added one is taken
|
||||
--
|
||||
-- Remark : SetCurrent is for the Profile : the individual
|
||||
-- options are not switched themselves, they are only queried
|
||||
-- To switch the options themselves, see below RecordCurrent
|
||||
--
|
||||
-- Remark : for Options which are listed in the Profile but not
|
||||
-- in the current Configuration, their current switch is taken
|
||||
|
||||
RecordCurrent (me : mutable);
|
||||
---Purpose : Records the switches of current configuration in the options
|
||||
-- themselves
|
||||
|
||||
Current (me) returns AsciiString;
|
||||
---Purpose : Returns the name of last current configuration
|
||||
---C++ : return const &
|
||||
|
||||
CaseName (me; optname : CString; proper : Boolean = Standard_False)
|
||||
returns AsciiString;
|
||||
---Purpose : Returns the selected case name of option <optname> in current
|
||||
-- configuration
|
||||
-- Empty String if <optname> unknown
|
||||
--
|
||||
-- If <proper> is False (D), if <optname> is not recorded in the
|
||||
-- current configuration, the own current name of the option
|
||||
-- itself is taken
|
||||
-- Else, an empty string is returned
|
||||
|
||||
CaseValue (me; optname : CString) returns Transient;
|
||||
---Purpose : Returns the Value of the switch selected for option <optname>
|
||||
-- in current configuration
|
||||
-- Null Handle if <optname> unknown
|
||||
-- To be down-casted as needed before use
|
||||
|
||||
Value (me; optname : CString; val : out Transient) returns Boolean;
|
||||
---Purpose : Returns the Value of the switch selected for option <optname>
|
||||
-- in current configuration
|
||||
-- Returns True if done, False + Null Handle if <optname> unknown
|
||||
-- This way of returning a Transient, bound with the Type Control
|
||||
-- avoids DownCast and ensures the value is directly usable
|
||||
|
||||
SetTypedValues (me; proper : Boolean = Standard_False; name : CString = "");
|
||||
---Purpose : For the Options which are defined with a TypedValue/Static,
|
||||
-- takes the value defined in current configuration, and sets
|
||||
-- the TypedValue with it
|
||||
--
|
||||
-- If <proper> is False (D), takes the current value, whatever
|
||||
-- it is properly recorded in current configuration or not
|
||||
-- If <proper> is True, sets the value only if it is properly
|
||||
-- recorded in the current configuration
|
||||
--
|
||||
-- By default, considers all the Options with a TypedValue
|
||||
-- If <name> is given, considers the Options of which the name
|
||||
-- begins by <name>
|
||||
|
||||
-- Fast Access
|
||||
|
||||
SetFast (me : mutable; confname : CString = "");
|
||||
---Purpose : Recomputes fast access from the definition of a configuration
|
||||
-- By default, the current one
|
||||
-- Else, a configuration identified by its name
|
||||
|
||||
ClearFast (me : mutable);
|
||||
---Purpose : Clears definitions of fast access
|
||||
|
||||
FastValue (me; optname : CString; val : out Transient) returns Boolean;
|
||||
---Purpose : Gets the value corresponding to Option <optname>, as fast
|
||||
-- If not defined as fast, check "normal" access by calling Value
|
||||
-- Returns True if OK (either Fast or normal), False if not found
|
||||
-- (if not found, <val> is returned Null Handle)
|
||||
|
||||
fields
|
||||
|
||||
theopts : DictionaryOfTransient;
|
||||
theconfs : DictionaryOfTransient;
|
||||
-- each conf is itself a DictionaryOfTransient which brings strings
|
||||
thecurname : AsciiString;
|
||||
thecurconf : DictionaryOfTransient;
|
||||
thefastval : DictionaryOfTransient;
|
||||
|
||||
end Profile;
|
314
src/MoniTool/MoniTool_Profile.cxx
Executable file
314
src/MoniTool/MoniTool_Profile.cxx
Executable file
@@ -0,0 +1,314 @@
|
||||
#include <MoniTool_Profile.ixx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
|
||||
#include <MoniTool_TypedValue.hxx>
|
||||
|
||||
|
||||
static Standard_Boolean IsCurrent (const Standard_CString name)
|
||||
{ return (name[0] == '.' && name[1] == '\0'); }
|
||||
|
||||
MoniTool_Profile::MoniTool_Profile ()
|
||||
{
|
||||
theopts = new Dico_DictionaryOfTransient;
|
||||
theconfs = new Dico_DictionaryOfTransient;
|
||||
// Current
|
||||
Handle(Dico_DictionaryOfTransient) conf = new Dico_DictionaryOfTransient;
|
||||
theconfs->SetItem (".",conf);
|
||||
thecurname.AssignCat(".");
|
||||
thecurconf = conf;
|
||||
}
|
||||
|
||||
void MoniTool_Profile::AddOption
|
||||
(const Handle(MoniTool_Option)& option,
|
||||
const Standard_CString name)
|
||||
{
|
||||
if (option.IsNull()) return;
|
||||
if (name[0] == '\0') theopts->SetItem (option->Name().ToCString(),option);
|
||||
else theopts->SetItem (name,option);
|
||||
}
|
||||
|
||||
Handle(MoniTool_Option) MoniTool_Profile::Option
|
||||
(const Standard_CString name) const
|
||||
{
|
||||
Handle(MoniTool_Option) opt;
|
||||
if (!theopts->GetItem (name,opt,Standard_True)) opt.Nullify();
|
||||
return opt;
|
||||
}
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) MoniTool_Profile::OptionList () const
|
||||
{
|
||||
Handle(TColStd_HSequenceOfAsciiString) list = new TColStd_HSequenceOfAsciiString();
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theopts);
|
||||
for (; iter.More(); iter.Next()) list->Append (iter.Name());
|
||||
return list;
|
||||
}
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) MoniTool_Profile::TypedValueList () const
|
||||
{
|
||||
Handle(TColStd_HSequenceOfAsciiString) list = new TColStd_HSequenceOfAsciiString();
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theopts);
|
||||
for (; iter.More(); iter.Next()) {
|
||||
Handle(MoniTool_Option) opt = Handle(MoniTool_Option)::DownCast(iter.Value());
|
||||
if (!opt->TypedValue().IsNull()) list->Append (iter.Name());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void MoniTool_Profile::NewConf (const Standard_CString name)
|
||||
{
|
||||
if (IsCurrent (name)) return;
|
||||
Handle(Dico_DictionaryOfTransient) conf = new Dico_DictionaryOfTransient;
|
||||
theconfs->SetItem (name,conf);
|
||||
// thecurname.Clear(); thecurname.AssignCat (name);
|
||||
// thecurconf = conf;
|
||||
}
|
||||
|
||||
void MoniTool_Profile::AddConf (const Standard_CString name)
|
||||
{
|
||||
if (IsCurrent (name)) return;
|
||||
Handle(Dico_DictionaryOfTransient) conf;
|
||||
if (theconfs->GetItem (name,conf,Standard_False)) return;
|
||||
conf = new Dico_DictionaryOfTransient;
|
||||
theconfs->SetItem (name,conf);
|
||||
// thecurname.Clear(); thecurname.AssignCat (name);
|
||||
// thecurconf = conf;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_Profile::HasConf (const Standard_CString name) const
|
||||
{ return theconfs->HasItem (name,Standard_False); }
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) MoniTool_Profile::ConfList () const
|
||||
{
|
||||
Handle(TColStd_HSequenceOfAsciiString) list = new TColStd_HSequenceOfAsciiString();
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theconfs);
|
||||
for (; iter.More(); iter.Next()) list->Append (iter.Name());
|
||||
return list;
|
||||
}
|
||||
|
||||
Handle(Dico_DictionaryOfTransient) MoniTool_Profile::Conf
|
||||
(const Standard_CString name) const
|
||||
{
|
||||
Handle(Dico_DictionaryOfTransient) conf;
|
||||
if (!theconfs->GetItem (name,conf,Standard_False)) conf.Nullify();
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean MoniTool_Profile::ClearConf
|
||||
(const Standard_CString confname)
|
||||
{
|
||||
Handle(Dico_DictionaryOfTransient) conf;
|
||||
if (!theconfs->GetItem (confname,conf,Standard_False)) return Standard_False;
|
||||
conf->Clear();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_Profile::AddFromOtherConf
|
||||
(const Standard_CString confname, const Standard_CString otherconf)
|
||||
{
|
||||
Handle(Dico_DictionaryOfTransient) conf, other;
|
||||
if (!theconfs->GetItem (confname,conf,Standard_False)) return Standard_False;
|
||||
if (!theconfs->GetItem (otherconf,other,Standard_False)) return Standard_False;
|
||||
if (conf == other) return Standard_True;
|
||||
Dico_IteratorOfDictionaryOfTransient iter(other);
|
||||
for (; iter.More(); iter.Next()) conf->SetItem (iter.Name(),iter.Value());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_Profile::SetFromCurrent
|
||||
(const Standard_CString confname)
|
||||
{
|
||||
Handle(Dico_DictionaryOfTransient) conf;
|
||||
if (!theconfs->GetItem (confname,conf,Standard_False)) return Standard_False;
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theopts);
|
||||
for (; iter.More(); iter.Next()) {
|
||||
TCollection_AsciiString name = iter.Name();
|
||||
TCollection_AsciiString cn = CaseName (name.ToCString());
|
||||
AddSwitch (name.ToCString(), cn.ToCString() );
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean MoniTool_Profile::AddSwitch
|
||||
(const Standard_CString confname,
|
||||
const Standard_CString optname,
|
||||
const Standard_CString casename)
|
||||
{
|
||||
Handle(Dico_DictionaryOfTransient) conf = Conf (confname);
|
||||
Handle(MoniTool_Option) opt = Option (optname);
|
||||
if (conf.IsNull() || opt.IsNull()) return Standard_False;
|
||||
Handle(TCollection_HAsciiString) sw = new TCollection_HAsciiString(casename);
|
||||
if (casename[0] == '\0') sw = new TCollection_HAsciiString (opt->CaseName());
|
||||
Handle(Standard_Transient) val;
|
||||
if (!opt->Item (sw->ToCString(),val)) return Standard_False;
|
||||
conf->SetItem (optname,sw);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_Profile::RemoveSwitch
|
||||
(const Standard_CString confname,
|
||||
const Standard_CString optname)
|
||||
{
|
||||
Handle(Dico_DictionaryOfTransient) conf = Conf (confname);
|
||||
Handle(MoniTool_Option) opt = Option (optname);
|
||||
if (conf.IsNull() || opt.IsNull()) return Standard_False;
|
||||
conf->RemoveItem (optname,Standard_False,Standard_False);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_Profile::SwitchList
|
||||
(const Standard_CString confname,
|
||||
Handle(TColStd_HSequenceOfAsciiString)& optlist,
|
||||
Handle(TColStd_HSequenceOfAsciiString)& caselist) const
|
||||
{
|
||||
optlist = new TColStd_HSequenceOfAsciiString();
|
||||
caselist = new TColStd_HSequenceOfAsciiString();
|
||||
Handle(Dico_DictionaryOfTransient) conf = Conf (confname);
|
||||
if (conf.IsNull()) return;
|
||||
Dico_IteratorOfDictionaryOfTransient iter (conf);
|
||||
for (; iter.More(); iter.Next()) {
|
||||
TCollection_AsciiString optname = iter.Name();
|
||||
Handle(TCollection_HAsciiString) cn =
|
||||
Handle(TCollection_HAsciiString)::DownCast(iter.Value());
|
||||
TCollection_AsciiString casename(cn->ToCString());
|
||||
optlist->Append(optname);
|
||||
caselist->Append(casename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean MoniTool_Profile::SetCurrent
|
||||
(const Standard_CString confname)
|
||||
{
|
||||
if (!AddFromOtherConf (".",confname)) return Standard_False;
|
||||
thecurname.Clear(); thecurname.AssignCat (confname);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
void MoniTool_Profile::RecordCurrent ()
|
||||
{
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theconfs);
|
||||
for (; iter.More(); iter.Next()) {
|
||||
Handle(MoniTool_Option) opt = Option (iter.Name().ToCString());
|
||||
Handle(TCollection_HAsciiString) val =
|
||||
Handle(TCollection_HAsciiString)::DownCast (iter.Value());
|
||||
if (!val.IsNull()) opt->Switch (val->ToCString());
|
||||
}
|
||||
}
|
||||
|
||||
const TCollection_AsciiString& MoniTool_Profile::Current () const
|
||||
{ return thecurname; }
|
||||
|
||||
TCollection_AsciiString MoniTool_Profile::CaseName
|
||||
(const Standard_CString optname, const Standard_Boolean proper) const
|
||||
{
|
||||
TCollection_AsciiString cn;
|
||||
Handle(TCollection_HAsciiString) sw;
|
||||
if (thecurconf->GetItem (optname,sw,Standard_True)) {
|
||||
cn.AssignCat (sw->ToCString());
|
||||
return cn;
|
||||
}
|
||||
if (proper) return cn;
|
||||
Handle(MoniTool_Option) opt = Option (optname);
|
||||
if (opt.IsNull()) return cn;
|
||||
return opt->CaseName();
|
||||
}
|
||||
|
||||
Handle(Standard_Transient) MoniTool_Profile::CaseValue
|
||||
(const Standard_CString optname) const
|
||||
{
|
||||
Handle(Standard_Transient) val;
|
||||
Handle(MoniTool_Option) opt = Option (optname);
|
||||
if (opt.IsNull()) return val;
|
||||
|
||||
Handle(TCollection_HAsciiString) sw;
|
||||
if (!thecurconf->GetItem (optname,sw,Standard_True)) sw.Nullify();
|
||||
|
||||
if (sw.IsNull()) return opt->CaseValue();
|
||||
if (!opt->Item (sw->ToCString(),val)) val.Nullify();
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean MoniTool_Profile::Value
|
||||
(const Standard_CString optname,
|
||||
Handle(Standard_Transient)& val) const
|
||||
{
|
||||
Handle(MoniTool_Option) opt = Option (optname);
|
||||
if (opt.IsNull()) return Standard_False;
|
||||
|
||||
Handle(TCollection_HAsciiString) sw;
|
||||
if (!thecurconf->GetItem (optname,sw,Standard_True)) sw.Nullify();
|
||||
|
||||
if (sw.IsNull()) { opt->Value(val); return Standard_True; }
|
||||
return opt->Item (sw->ToCString(),val);
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_Profile::SetTypedValues
|
||||
(const Standard_Boolean proper, const Standard_CString name) const
|
||||
{
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theopts,name);
|
||||
for (; iter.More(); iter.Next()) {
|
||||
Handle(MoniTool_Option) opt = Handle(MoniTool_Option)::DownCast(iter.Value());
|
||||
Handle(MoniTool_TypedValue) tv = opt->TypedValue();
|
||||
if (tv.IsNull()) continue;
|
||||
|
||||
// On recherche la valeur: en conf courante, sinon dans l option (cf proper)
|
||||
|
||||
Handle(TCollection_HAsciiString) sw, val;
|
||||
if (!thecurconf->GetItem (name,sw,Standard_True)) sw.Nullify();
|
||||
if (!sw.IsNull()) {
|
||||
if (!opt->Item (sw->ToCString(),val)) val.Nullify();
|
||||
}
|
||||
if (val.IsNull() && !proper) opt->Value(val);
|
||||
|
||||
// On applique
|
||||
if (!val.IsNull()) tv->SetHStringValue (val);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MoniTool_Profile::SetFast (const Standard_CString confname)
|
||||
{
|
||||
Standard_Boolean cur = (confname[0] == '\0');
|
||||
thefastval = new Dico_DictionaryOfTransient;
|
||||
Dico_IteratorOfDictionaryOfTransient iter(theopts);
|
||||
for (; iter.More(); iter.Next()) {
|
||||
Handle(MoniTool_Option) opt = Handle(MoniTool_Option)::DownCast(iter.Value());
|
||||
if (opt.IsNull()) continue;
|
||||
Standard_Boolean iaopt = Standard_True;
|
||||
TCollection_AsciiString optnam = iter.Name();
|
||||
Standard_CString optname = optnam.ToCString();
|
||||
Handle(Standard_Transient) val;
|
||||
|
||||
if (cur) {
|
||||
Handle(TCollection_HAsciiString) sw;
|
||||
if (!thecurconf->GetItem (optname,sw,Standard_True)) sw.Nullify();
|
||||
|
||||
if (sw.IsNull()) opt->Value(val);
|
||||
else iaopt = opt->Item (sw->ToCString(),val);
|
||||
}
|
||||
else iaopt = opt->Item (confname,val);
|
||||
|
||||
// Now, recording
|
||||
if (iaopt) thefastval->SetItem (optname,val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_Profile::ClearFast ()
|
||||
{ thefastval.Nullify(); }
|
||||
|
||||
|
||||
Standard_Boolean MoniTool_Profile::FastValue
|
||||
(const Standard_CString optname,
|
||||
Handle(Standard_Transient)& val) const
|
||||
{
|
||||
if (!thefastval.IsNull()) {
|
||||
if (thefastval->GetItem (optname,val,Standard_True)) return Standard_True;
|
||||
}
|
||||
return Value (optname,val);
|
||||
}
|
27
src/MoniTool/MoniTool_RealVal.cdl
Executable file
27
src/MoniTool/MoniTool_RealVal.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: MoniTool_RealVal.cdl
|
||||
-- Created: Wed Sep 3 15:25:38 1997
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@heliox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
class RealVal from MoniTool inherits TShared from MMgt
|
||||
|
||||
---Purpose : A Real through a Handle (i.e. managed as TShared)
|
||||
|
||||
uses Real
|
||||
|
||||
is
|
||||
|
||||
Create (val : Real = 0.0) returns mutable RealVal;
|
||||
|
||||
Value (me) returns Real;
|
||||
|
||||
CValue (me : mutable) returns Real;
|
||||
---C++ : return &
|
||||
|
||||
fields
|
||||
|
||||
theval : Real;
|
||||
|
||||
end RealVal;
|
7
src/MoniTool/MoniTool_RealVal.cxx
Executable file
7
src/MoniTool/MoniTool_RealVal.cxx
Executable file
@@ -0,0 +1,7 @@
|
||||
#include <MoniTool_RealVal.ixx>
|
||||
|
||||
MoniTool_RealVal::MoniTool_RealVal (const Standard_Real val) { theval = val; }
|
||||
|
||||
Standard_Real MoniTool_RealVal::Value () const { return theval; }
|
||||
|
||||
Standard_Real& MoniTool_RealVal::CValue () { return theval; }
|
27
src/MoniTool/MoniTool_SignShape.cdl
Executable file
27
src/MoniTool/MoniTool_SignShape.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: MoniTool_SignShape.cdl
|
||||
-- Created: Wed Feb 4 18:23:38 1998
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@heliox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
class SignShape from MoniTool inherits SignText from MoniTool
|
||||
|
||||
---Purpose : Signs HShape according to its real content (type of Shape)
|
||||
-- Context is not used
|
||||
|
||||
uses CString, Transient, AsciiString
|
||||
|
||||
is
|
||||
|
||||
Create returns mutable SignShape;
|
||||
|
||||
Name (me) returns CString;
|
||||
---Purpose : Returns "SHAPE"
|
||||
|
||||
Text (me; ent : any Transient; context : any Transient)
|
||||
returns AsciiString from TCollection;
|
||||
---Purpose : Returns for a HShape, the string of its ShapeEnum
|
||||
-- The Model is absolutely useless (may be null)
|
||||
|
||||
end SignShape;
|
32
src/MoniTool/MoniTool_SignShape.cxx
Executable file
32
src/MoniTool/MoniTool_SignShape.cxx
Executable file
@@ -0,0 +1,32 @@
|
||||
#include <MoniTool_SignShape.ixx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_HShape.hxx>
|
||||
|
||||
|
||||
MoniTool_SignShape::MoniTool_SignShape () { }
|
||||
|
||||
Standard_CString MoniTool_SignShape::Name () const
|
||||
{ return "SHAPE"; }
|
||||
|
||||
TCollection_AsciiString MoniTool_SignShape::Text
|
||||
(const Handle(Standard_Transient)& ent,
|
||||
const Handle(Standard_Transient)& context) const
|
||||
{
|
||||
if (ent.IsNull()) return "";
|
||||
Handle(TopoDS_HShape) HS = Handle(TopoDS_HShape)::DownCast(ent);
|
||||
if (HS.IsNull()) return ent->DynamicType()->Name();
|
||||
TopoDS_Shape sh = HS->Shape();
|
||||
if (sh.IsNull()) return "SHAPE";
|
||||
switch (sh.ShapeType()) {
|
||||
case TopAbs_VERTEX : return "VERTEX";
|
||||
case TopAbs_EDGE : return "EDGE";
|
||||
case TopAbs_WIRE : return "WIRE";
|
||||
case TopAbs_FACE : return "FACE";
|
||||
case TopAbs_SHELL : return "SHELL";
|
||||
case TopAbs_SOLID : return "SOLID";
|
||||
case TopAbs_COMPSOLID : return "COMPSOLID";
|
||||
case TopAbs_COMPOUND : return "COMPOUND";
|
||||
default : break;
|
||||
}
|
||||
return "SHAPE";
|
||||
}
|
39
src/MoniTool/MoniTool_SignText.cdl
Executable file
39
src/MoniTool/MoniTool_SignText.cdl
Executable file
@@ -0,0 +1,39 @@
|
||||
-- File: MoniTool_SignText.cdl
|
||||
-- Created: Wed May 20 16:47:50 1998
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@heliox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
|
||||
deferred class SignText from MoniTool inherits TShared
|
||||
|
||||
---Purpose : Provides the basic service to get a text which identifies
|
||||
-- an object in a context
|
||||
-- It can be used for other classes (general signatures ...)
|
||||
-- It can also be used to build a message in which an object
|
||||
-- is to be identified
|
||||
|
||||
uses CString, Transient, AsciiString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Name (me) returns CString is deferred;
|
||||
---Purpose : Returns an identification of the Signature (a word), given at
|
||||
-- initialization time
|
||||
|
||||
TextAlone (me; ent : any Transient)
|
||||
returns AsciiString from TCollection is virtual;
|
||||
---Purpose : Gives a text as a signature for a transient object alone, i.e.
|
||||
-- without defined context.
|
||||
-- By default, calls Text with undefined context (Null Handle) and
|
||||
-- if empty, then returns DynamicType
|
||||
|
||||
Text (me; ent : any Transient; context : any Transient)
|
||||
returns AsciiString from TCollection is deferred;
|
||||
---Purpose : Gives a text as a signature for a transient object in a context
|
||||
-- If the context is senseless, it can be given as Null Handle
|
||||
-- empty result if nothing to give (at least the DynamicType could
|
||||
-- be sent ?)
|
||||
|
||||
end SignText;
|
13
src/MoniTool/MoniTool_SignText.cxx
Executable file
13
src/MoniTool/MoniTool_SignText.cxx
Executable file
@@ -0,0 +1,13 @@
|
||||
#include <MoniTool_SignText.ixx>
|
||||
|
||||
TCollection_AsciiString MoniTool_SignText::TextAlone
|
||||
(const Handle(Standard_Transient)& ent) const
|
||||
{
|
||||
Handle(Standard_Transient) nulctx; // no context
|
||||
TCollection_AsciiString atext = Text (ent,nulctx);
|
||||
if (atext.Length() == 0) {
|
||||
if (ent.IsNull()) atext.AssignCat ("(NULL)");
|
||||
else atext.AssignCat (ent->DynamicType()->Name());
|
||||
}
|
||||
return atext;
|
||||
}
|
95
src/MoniTool/MoniTool_Stat.cdl
Executable file
95
src/MoniTool/MoniTool_Stat.cdl
Executable file
@@ -0,0 +1,95 @@
|
||||
-- File: MoniTool_Stat.cdl
|
||||
-- Created: Thu Feb 15 16:45:14 1996
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@fidox>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
|
||||
class Stat from MoniTool
|
||||
|
||||
---Purpose : This class manages Statistics to be queried asynchronously.
|
||||
--
|
||||
-- It is organized as a stack of counters, identified by their
|
||||
-- levels, from one to ... . Each one has a total account of
|
||||
-- items to be counted, a count of already passed items, plus a
|
||||
-- count of "current items". The counters of higher level play on
|
||||
-- these current items.
|
||||
-- For instance, if a counter has been opened for 100 items, 40
|
||||
-- already passed, 20 current, its own percent is 40, but there
|
||||
-- is the contribution of higher level counters, rated for 20 %
|
||||
-- of this counter.
|
||||
--
|
||||
-- Hence, a counter is opened, items are added. Also items can be
|
||||
-- add for sub-counter (of higher level), they will be added
|
||||
-- definitively when the sub-counter will be closed. When the
|
||||
-- count has ended, this counter is closed, the counter of
|
||||
-- lower level cumulates it and goes on. As follows :
|
||||
--
|
||||
-- Way of use :
|
||||
-- Open(nbitems);
|
||||
-- Add(..) : direct adding
|
||||
-- Add(..)
|
||||
-- AddSub (nsub) : for sub-counter
|
||||
-- Open (nbsubs) : nbsubs for this sub-counter
|
||||
-- Add (..)
|
||||
-- Close : the sub-counter
|
||||
-- AddEnd()
|
||||
-- etc...
|
||||
-- Close : the starting counter
|
||||
--
|
||||
-- This means that a counter can be opened in a Stat, regardless
|
||||
-- to the already opened ones :: this will be cumulated
|
||||
--
|
||||
-- A Current Stat is available, but it is possible to have others
|
||||
|
||||
uses Integer, Real, HArray1OfInteger,
|
||||
CString, HAsciiString
|
||||
|
||||
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
|
||||
|
||||
Current (myclass) returns Stat;
|
||||
---C++ : return &
|
||||
|
||||
Open (me : in out; nb : Integer = 100) returns Integer;
|
||||
---Purpose : Opens a new counter with a starting count of items
|
||||
|
||||
OpenMore (me : in out; id : Integer; nb : Integer);
|
||||
---Purpose : Adds more items to be counted by Add... on current level
|
||||
|
||||
Add (me : in out; nb : Integer = 1);
|
||||
---Purpose : Directly addes items
|
||||
|
||||
AddSub (me : in out; nb : Integer = 1);
|
||||
---Purpose : Declares a count of items to be added later. If a sub-counter
|
||||
-- is opened, its percentage multiplies this sub-count to compute
|
||||
-- the percent of current level
|
||||
|
||||
AddEnd (me : in out);
|
||||
---Purpose : Ends the AddSub and cumulates the sub-count to current level
|
||||
|
||||
Close (me : in out; id : Integer);
|
||||
|
||||
Level (me) returns Integer;
|
||||
|
||||
Percent (me; fromlev : Integer = 0) returns Real;
|
||||
|
||||
fields
|
||||
|
||||
thetit : HAsciiString from TCollection;
|
||||
thelev : Integer;
|
||||
thetot : HArray1OfInteger;
|
||||
thedone : HArray1OfInteger;
|
||||
thecurr : HArray1OfInteger;
|
||||
|
||||
end Stat;
|
88
src/MoniTool/MoniTool_Stat.cxx
Executable file
88
src/MoniTool/MoniTool_Stat.cxx
Executable file
@@ -0,0 +1,88 @@
|
||||
#include <MoniTool_Stat.ixx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
//static MoniTool_Stat Statvoid("");
|
||||
//static MoniTool_Stat Statact ("");
|
||||
|
||||
//not Used
|
||||
//static Standard_CString voidname = "";
|
||||
|
||||
|
||||
MoniTool_Stat::MoniTool_Stat (const Standard_CString title)
|
||||
{
|
||||
thetit = new TCollection_HAsciiString(title);
|
||||
thelev = 0;
|
||||
thetot = new TColStd_HArray1OfInteger (1,20); thetot->Init(0);
|
||||
thedone = new TColStd_HArray1OfInteger (1,20); thetot->Init(0);
|
||||
thecurr = new TColStd_HArray1OfInteger (1,20); thetot->Init(0);
|
||||
}
|
||||
|
||||
MoniTool_Stat::MoniTool_Stat (const MoniTool_Stat& )
|
||||
{ }
|
||||
|
||||
MoniTool_Stat& MoniTool_Stat::Current ()
|
||||
{
|
||||
static MoniTool_Stat thecur;
|
||||
return thecur;
|
||||
}
|
||||
|
||||
Standard_Integer MoniTool_Stat::Open (const Standard_Integer nb)
|
||||
{
|
||||
thelev ++;
|
||||
thetot->SetValue(thelev,nb);
|
||||
thedone->SetValue(thelev,0);
|
||||
thecurr->SetValue(thelev,0);
|
||||
return thelev;
|
||||
}
|
||||
|
||||
void MoniTool_Stat::OpenMore (const Standard_Integer id, const Standard_Integer nb)
|
||||
{
|
||||
if (id <= 0 || id > thelev) return;
|
||||
thetot->SetValue (id, thetot->Value(id)+nb);
|
||||
}
|
||||
|
||||
void MoniTool_Stat::Add (const Standard_Integer nb)
|
||||
{
|
||||
thedone->SetValue (thelev, thedone->Value(thelev) + nb);
|
||||
thecurr->SetValue (thelev, 0);
|
||||
}
|
||||
|
||||
void MoniTool_Stat::AddSub (const Standard_Integer nb)
|
||||
{
|
||||
thecurr->SetValue (thelev, nb);
|
||||
}
|
||||
|
||||
void MoniTool_Stat::AddEnd ()
|
||||
{
|
||||
thedone->SetValue (thelev, thedone->Value(thelev) + thecurr->Value(thelev));
|
||||
thecurr->SetValue (thelev, 0);
|
||||
}
|
||||
|
||||
void MoniTool_Stat::Close (const Standard_Integer id)
|
||||
{
|
||||
if (id < thelev) Close (id+1);
|
||||
AddEnd();
|
||||
thelev --;
|
||||
}
|
||||
|
||||
Standard_Integer MoniTool_Stat::Level () const
|
||||
{ return thelev; }
|
||||
|
||||
Standard_Real MoniTool_Stat::Percent (const Standard_Integer fromlev) const
|
||||
{
|
||||
if (fromlev > thelev) return 0;
|
||||
Standard_Real r1,r2,r3;
|
||||
Standard_Integer tot = thetot->Value(fromlev);
|
||||
Standard_Integer done = thedone->Value(fromlev);
|
||||
if (done >= tot) return 100.;
|
||||
if (fromlev == thelev) {
|
||||
r1 = tot; r2 = done;
|
||||
return (r2*100)/r1;
|
||||
}
|
||||
Standard_Integer cur = thecurr->Value(fromlev);
|
||||
r1 = tot; r2 = done;
|
||||
r3 = 0;
|
||||
if (cur > 0) { r3 = cur; r3 = cur/tot; r3 = r3*Percent (fromlev+1); }
|
||||
if (r1 == 0) return 1;
|
||||
return (r2*100)/r1 + r3;
|
||||
}
|
115
src/MoniTool/MoniTool_Timer.cdl
Executable file
115
src/MoniTool/MoniTool_Timer.cdl
Executable file
@@ -0,0 +1,115 @@
|
||||
-- File: MoniTool_Timer.cdl
|
||||
-- Created: Tue Dec 13 12:35:33 2001
|
||||
-- Author: Sergey KUUl
|
||||
---Copyright: Matra Datavision 2001
|
||||
|
||||
class Timer from MoniTool inherits TShared from MMgt
|
||||
|
||||
---Purpose: Provides convenient service on global timers
|
||||
-- accessed by string name, mostly aimed for debugging purposes
|
||||
--
|
||||
-- As an instance, envelopes the OSD_Timer to have it as Handle
|
||||
--
|
||||
-- As a tool, supports static dictionary of timers
|
||||
-- and provides static methods to easily access them
|
||||
|
||||
uses
|
||||
Timer from OSD,
|
||||
DataMapOfTimer from MoniTool
|
||||
|
||||
is
|
||||
|
||||
---Section: Instance methods
|
||||
|
||||
Create returns Timer from MoniTool;
|
||||
---C++: inline
|
||||
---Purpose: Create timer in empty state
|
||||
|
||||
Timer (me) returns Timer from OSD;
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
|
||||
Timer (me: mutable) returns Timer from OSD;
|
||||
---C++: inline
|
||||
---C++: return &
|
||||
---Purpose: Return reference to embedded OSD_Timer
|
||||
|
||||
Start (me: mutable);
|
||||
---C++: inline
|
||||
|
||||
Stop (me: mutable);
|
||||
---C++: inline
|
||||
|
||||
Reset (me: mutable);
|
||||
---C++: inline
|
||||
---Purpose: Start, Stop and reset the timer
|
||||
-- In addition to doing that to embedded OSD_Timer,
|
||||
-- manage also counter of hits
|
||||
|
||||
Count (me) returns Integer;
|
||||
---C++: inline
|
||||
---Purpose: Return value of hits counter (count of Start/Stop pairs)
|
||||
|
||||
IsRunning (me) returns Integer;
|
||||
---C++: inline
|
||||
---Purpose: Returns value of nesting counter
|
||||
|
||||
CPU (me: mutable) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Return value of CPU time minus accumulated amendment
|
||||
|
||||
Amend (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Return value of accumulated amendment on CPU time
|
||||
|
||||
Dump (me: mutable; ostr: in out OStream);
|
||||
---Purpose: Dumps current state of a timer shortly (one-line output)
|
||||
|
||||
---Section: Static methods
|
||||
|
||||
Timer (myclass; name: CString from Standard) returns Timer from MoniTool;
|
||||
---Purpose: Returns a timer from a dictionary by its name
|
||||
-- If timer not existed, creates a new one
|
||||
|
||||
Start (myclass; name: CString from Standard);
|
||||
---C++: inline
|
||||
|
||||
Stop (myclass; name: CString from Standard);
|
||||
---C++: inline
|
||||
---Purpose: Inline methods to conveniently start/stop timer by name
|
||||
-- Shortcut to Timer(name)->Start/Stop()
|
||||
|
||||
Dictionary (myclass) returns DataMapOfTimer from MoniTool;
|
||||
---Purpose: Returns map of timers
|
||||
---C++: return&
|
||||
|
||||
ClearTimers (myclass);
|
||||
---Purpose: Clears map of timers
|
||||
|
||||
DumpTimers (myclass; ostr: in out OStream);
|
||||
---Purpose: Dumps contents of the whole dictionary
|
||||
|
||||
ComputeAmendments (myclass);
|
||||
---Purpose: Computes and remembers amendments for times to
|
||||
-- access, start, and stop of timer, and estimates
|
||||
-- second-order error measured by 10 nested timers
|
||||
|
||||
GetAmendments (myclass; Access, Internal, External, Error10: out Real);
|
||||
---Purpose: The computed amendmens are returned (for information only)
|
||||
|
||||
AmendAccess (myclass) is private;
|
||||
AmendStart (me: mutable) is private;
|
||||
AmendStop (me: mutable) is private;
|
||||
---Purpose: Internal functions to amend other timers to avoid
|
||||
-- side effects of operations with current one
|
||||
|
||||
fields
|
||||
|
||||
myTimer : Timer from OSD;
|
||||
myCount : Integer;
|
||||
myNesting: Integer;
|
||||
|
||||
myAmend : Real;
|
||||
myPrev, myNext: Timer from MoniTool; -- chained active timers
|
||||
|
||||
end Timer;
|
247
src/MoniTool/MoniTool_Timer.cxx
Executable file
247
src/MoniTool/MoniTool_Timer.cxx
Executable file
@@ -0,0 +1,247 @@
|
||||
#include <MoniTool_Timer.ixx>
|
||||
|
||||
#include <MoniTool_DataMapOfTimer.hxx>
|
||||
#include <MoniTool_DataMapIteratorOfDataMapOfTimer.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
#include <MoniTool_TimerSentry.hxx>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void MoniTool_Timer::Dump(Standard_OStream &ostr)
|
||||
{
|
||||
Standard_Integer hours, minutes;
|
||||
Standard_Real seconds, CPUtime, user, system;
|
||||
|
||||
myTimer.Show(seconds,minutes,hours,CPUtime);
|
||||
myTimer.OSD_Chronometer::Show(user,system);
|
||||
|
||||
Standard_Real elapsed = seconds + minutes*60 + hours*3600;
|
||||
|
||||
char buff[1024];
|
||||
sprintf ( buff, "Elapsed:%6.1f sec, CPU User:%9.4f sec, CPU Sys:%9.4f sec, hits: %d",
|
||||
elapsed, user, system, myCount );
|
||||
|
||||
ostr << buff << endl;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dictionary
|
||||
//purpose : Return DataMapOfTimer
|
||||
//=======================================================================
|
||||
|
||||
MoniTool_DataMapOfTimer& MoniTool_Timer::Dictionary ()
|
||||
{
|
||||
static MoniTool_DataMapOfTimer dic;
|
||||
return dic;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Timer
|
||||
//purpose : Return handle for timer from map
|
||||
//=======================================================================
|
||||
|
||||
Handle(MoniTool_Timer) MoniTool_Timer::Timer(const Standard_CString name)
|
||||
{
|
||||
// AmendAccess();
|
||||
MoniTool_DataMapOfTimer &dic = Dictionary();
|
||||
if ( dic.IsBound(name) )
|
||||
return dic.Find(name);
|
||||
Handle(MoniTool_Timer) MT = new MoniTool_Timer;
|
||||
MT->Timer().Reset();
|
||||
dic.Bind(name,MT);
|
||||
return MT;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ClearTimers
|
||||
//purpose : Clears all the map of timers
|
||||
//=======================================================================
|
||||
|
||||
void MoniTool_Timer::ClearTimers()
|
||||
{
|
||||
Dictionary().Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpTimers
|
||||
//purpose : Shows all timer from Dictionary
|
||||
//=======================================================================
|
||||
|
||||
void MoniTool_Timer::DumpTimers (Standard_OStream &ostr)
|
||||
{
|
||||
MoniTool_DataMapOfTimer &dic = Dictionary();
|
||||
MoniTool_DataMapIteratorOfDataMapOfTimer iter(dic);
|
||||
|
||||
Standard_Integer NbTimers = dic.Extent();
|
||||
|
||||
ostr << "DUMP OF TIMERS:" << endl;
|
||||
Standard_CString *keys = new Standard_CString[NbTimers];
|
||||
Standard_Integer i=0;
|
||||
for( ; iter.More() && i < NbTimers; iter.Next()) {
|
||||
keys[i++] = iter.Key();
|
||||
}
|
||||
for(i=0; i < NbTimers; i++) {
|
||||
Standard_Integer ntmp = 0;
|
||||
Standard_CString stmp = 0;
|
||||
for(Standard_Integer j=0; j < NbTimers; j++) {
|
||||
if ( keys[j] && ( ! stmp || strcmp(stmp,keys[j]) > 0 ) ) {
|
||||
ntmp=j;
|
||||
stmp=keys[j];
|
||||
}
|
||||
}
|
||||
//Handle(MoniTool_Timer) MT = iter.Value();
|
||||
char buff[1024];
|
||||
sprintf ( buff, "%-20s\t", stmp );
|
||||
ostr << "TIMER: " << buff;
|
||||
//iter.Value()->Dump ( ostr );
|
||||
Timer(stmp)->Dump(ostr);
|
||||
keys[ntmp]=0;
|
||||
if ( Timer(stmp)->IsRunning() ) cerr << "Warning: timer " << stmp << " is running" << endl;
|
||||
}
|
||||
delete[] keys;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeAmendments
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Real amAccess=0., amInternal=0., amExternal=0., amError=0.;
|
||||
|
||||
void MoniTool_Timer::ComputeAmendments ()
|
||||
{
|
||||
const Standard_Integer NBTESTS = 100000;
|
||||
|
||||
Standard_Integer i;
|
||||
|
||||
Handle(MoniTool_Timer) MT0 = MoniTool_Timer::Timer("_mt_amend_0_");
|
||||
Handle(MoniTool_Timer) MT1 = MoniTool_Timer::Timer("_mt_amend_1_");
|
||||
Handle(MoniTool_Timer) MT2 = MoniTool_Timer::Timer("_mt_amend_2_");
|
||||
Handle(MoniTool_Timer) MT3 = MoniTool_Timer::Timer("_mt_amend_3_");
|
||||
MT0->Reset();
|
||||
MT1->Reset();
|
||||
MT2->Reset();
|
||||
MT3->Reset();
|
||||
MoniTool_Timer::Timer("_mt_amend_t1_")->Reset();
|
||||
MoniTool_Timer::Timer("_mt_amend_t2_")->Reset();
|
||||
MoniTool_Timer::Timer("_mt_amend_t3_")->Reset();
|
||||
|
||||
// reference test
|
||||
MT0->Start();
|
||||
for ( i=1; i <= NBTESTS; i++ ) {
|
||||
for ( int k=1; k <= 100; k++ ) Sqrt ( i+k );
|
||||
}
|
||||
MT0->Stop();
|
||||
|
||||
// test for direct access
|
||||
Handle(MoniTool_Timer) MT = MoniTool_Timer::Timer("_mt_amend_t1_");
|
||||
MT1->Start();
|
||||
for ( i=1; i <= NBTESTS; i++ ) {
|
||||
MT->Start();
|
||||
for ( int k=1; k <= 100; k++ ) Sqrt ( i+k );
|
||||
MT->Stop();
|
||||
}
|
||||
MT1->Stop();
|
||||
|
||||
// test for using Sentry
|
||||
MT2->Start();
|
||||
for ( i=1; i <= NBTESTS; i++ ) {
|
||||
MoniTool_TimerSentry TS ("_mt_amend_t2_");
|
||||
for ( int k=1; k <= 100; k++ ) Sqrt ( i+k );
|
||||
}
|
||||
MT2->Stop();
|
||||
|
||||
// test for access by name
|
||||
MT3->Start();
|
||||
for ( i=1; i <= NBTESTS; i++ ) {
|
||||
MoniTool_Timer::Start("_mt_amend_t3_");
|
||||
for ( int k=1; k <= 100; k++ ) Sqrt ( i+k );
|
||||
MoniTool_Timer::Stop("_mt_amend_t3_");
|
||||
}
|
||||
MT3->Stop();
|
||||
|
||||
// analyze results
|
||||
Standard_Real cpu0, cpu1, cpu2, cpu3, cput1, cput2, cput3;
|
||||
cpu0 = MoniTool_Timer::Timer("_mt_amend_0_")->CPU();
|
||||
cpu1 = MoniTool_Timer::Timer("_mt_amend_1_")->CPU();
|
||||
cput1 = MT->CPU();
|
||||
cpu2 = MoniTool_Timer::Timer("_mt_amend_2_")->CPU();
|
||||
cput2 = MoniTool_Timer::Timer("_mt_amend_t2_")->CPU();
|
||||
cpu3 = MoniTool_Timer::Timer("_mt_amend_3_")->CPU();
|
||||
cput3 = MoniTool_Timer::Timer("_mt_amend_t3_")->CPU();
|
||||
|
||||
amExternal += ( cpu1 - cpu0 ) / NBTESTS;
|
||||
amInternal += ( cput1 - cpu0 ) / NBTESTS;
|
||||
amAccess += ( 0.5 * ( cpu3 - cpu1 ) ) / NBTESTS;
|
||||
amError = Abs ( cpu1 + cpu3 - 2 * cpu2 ) / NBTESTS;
|
||||
|
||||
cout << "CPU 0: " << cpu0 << endl;
|
||||
cout << "CPU 1: " << cpu1 << " INTERNAL: " << cput1 << endl;
|
||||
cout << "CPU 2: " << cpu2 << " INTERNAL: " << cput2 << endl;
|
||||
cout << "CPU 3: " << cpu3 << " INTERNAL: " << cput3 << endl;
|
||||
cout << "Access: " << amAccess << ", External: " << amExternal <<
|
||||
", Internal: " << amInternal << ", Error: " << amError << endl;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetAmendments
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void MoniTool_Timer::GetAmendments (Standard_Real &access,
|
||||
Standard_Real &internal,
|
||||
Standard_Real &external,
|
||||
Standard_Real &error10)
|
||||
{
|
||||
access = amAccess;
|
||||
internal = amInternal;
|
||||
external = amExternal;
|
||||
error10 = amError;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AmendAccess
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Handle(MoniTool_Timer) myActive;
|
||||
|
||||
void MoniTool_Timer::AmendAccess ()
|
||||
{
|
||||
Standard_Real amend = amAccess;
|
||||
for ( Handle(MoniTool_Timer) act = myActive; ! act.IsNull(); act = act->myNext )
|
||||
act->myAmend += amend;
|
||||
}
|
||||
|
||||
void MoniTool_Timer::AmendStart ()
|
||||
{
|
||||
Standard_Real amend = amExternal;
|
||||
for ( Handle(MoniTool_Timer) act = myActive; ! act.IsNull(); act = act->myNext )
|
||||
act->myAmend += amend;
|
||||
myAmend += amInternal;
|
||||
|
||||
// add to list
|
||||
if ( ! myActive.IsNull() ) {
|
||||
myActive->myPrev = this;
|
||||
myNext = myActive;
|
||||
}
|
||||
myActive = this;
|
||||
}
|
||||
|
||||
void MoniTool_Timer::AmendStop ()
|
||||
{
|
||||
Handle (MoniTool_Timer) thisActive(this);
|
||||
if ( myActive == thisActive ) myActive = myNext;
|
||||
// if ( myActive == this ) myActive = myNext;
|
||||
|
||||
if ( ! myPrev.IsNull() ) myPrev->myNext = myNext;
|
||||
if ( ! myNext.IsNull() ) myNext->myPrev = myPrev;
|
||||
|
||||
myNext = myPrev = 0;
|
||||
}
|
128
src/MoniTool/MoniTool_Timer.lxx
Executable file
128
src/MoniTool/MoniTool_Timer.lxx
Executable file
@@ -0,0 +1,128 @@
|
||||
//=======================================================================
|
||||
//function : MoniTool_Timer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline MoniTool_Timer::MoniTool_Timer() : myCount(0), myNesting(0), myAmend(0)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Timer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline OSD_Timer& MoniTool_Timer::Timer()
|
||||
{
|
||||
return myTimer;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Timer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline const OSD_Timer& MoniTool_Timer::Timer() const
|
||||
{
|
||||
return myTimer;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Start
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void MoniTool_Timer::Start()
|
||||
{
|
||||
// AmendStart();
|
||||
if ( ! myNesting ) myTimer.Start();
|
||||
myCount++;
|
||||
myNesting++;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Stop
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void MoniTool_Timer::Stop()
|
||||
{
|
||||
myNesting--;
|
||||
if ( ! myNesting ) myTimer.Stop();
|
||||
// AmendStop();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Reset
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void MoniTool_Timer::Reset()
|
||||
{
|
||||
myTimer.Reset();
|
||||
myCount = myNesting = 0;
|
||||
myAmend = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Count
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer MoniTool_Timer::Count() const
|
||||
{
|
||||
return myCount;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsRunning
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Integer MoniTool_Timer::IsRunning() const
|
||||
{
|
||||
return myNesting;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Amend
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real MoniTool_Timer::Amend() const
|
||||
{
|
||||
return myAmend;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPU
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real MoniTool_Timer::CPU()
|
||||
{
|
||||
Standard_Integer minutes, hours;
|
||||
Standard_Real seconds, cpu;
|
||||
myTimer.Show(seconds,minutes,hours,cpu);
|
||||
return cpu - myAmend;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Start
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void MoniTool_Timer::Start(const Standard_CString name)
|
||||
{
|
||||
Timer(name)->Start();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Stop
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void MoniTool_Timer::Stop(const Standard_CString name)
|
||||
{
|
||||
Timer(name)->Stop();
|
||||
}
|
46
src/MoniTool/MoniTool_TimerSentry.cdl
Executable file
46
src/MoniTool/MoniTool_TimerSentry.cdl
Executable file
@@ -0,0 +1,46 @@
|
||||
-- File: MoniTool_TimerSentry.cdl
|
||||
-- Created: Tue Dec 13 12:35:33 2001
|
||||
-- Author: Sergey KUUl
|
||||
---Copyright: Matra Datavision 2001
|
||||
|
||||
class TimerSentry from MoniTool
|
||||
|
||||
---Purpose: A tool to facilitate using MoniTool_Timer functionality
|
||||
-- by automatically ensuring consistency of start/stop actions
|
||||
--
|
||||
-- When instance of TimerSentry is created, a timer
|
||||
-- with corresponding name is started
|
||||
-- When instance is deleted, timer stops
|
||||
|
||||
uses
|
||||
Timer from MoniTool
|
||||
|
||||
is
|
||||
|
||||
Create (cname: CString from Standard)
|
||||
returns TimerSentry from MoniTool;
|
||||
---C++: inline
|
||||
---Purpose: Constructor creates an instance and runs the corresponding timer
|
||||
|
||||
Create (timer: Timer from MoniTool)
|
||||
returns TimerSentry from MoniTool;
|
||||
---C++: inline
|
||||
---Purpose: Constructor creates an instance and runs the corresponding timer
|
||||
|
||||
Destroy(me: in out);
|
||||
---C++: inline
|
||||
---Purpose: Destructor stops the associated timer
|
||||
---C++: alias "Standard_EXPORT ~MoniTool_TimerSentry () { Destroy(); }"
|
||||
|
||||
Timer (me) returns Timer from MoniTool;
|
||||
---C++: inline
|
||||
|
||||
Stop (me: in out);
|
||||
---C++: inline
|
||||
---Purpose: Manually stops the timer
|
||||
|
||||
fields
|
||||
|
||||
myTimer: Timer from MoniTool;
|
||||
|
||||
end TimerSentry;
|
1
src/MoniTool/MoniTool_TimerSentry.cxx
Executable file
1
src/MoniTool/MoniTool_TimerSentry.cxx
Executable file
@@ -0,0 +1 @@
|
||||
//#include <MoniTool_TimerSentry.ixx>
|
54
src/MoniTool/MoniTool_TimerSentry.lxx
Executable file
54
src/MoniTool/MoniTool_TimerSentry.lxx
Executable file
@@ -0,0 +1,54 @@
|
||||
#include <MoniTool_Timer.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : MoniTool_TimerSentry
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline MoniTool_TimerSentry::MoniTool_TimerSentry (const Standard_CString cname)
|
||||
: myTimer ( MoniTool_Timer::Timer ( cname ) )
|
||||
{
|
||||
myTimer->Start();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MoniTool_TimerSentry
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline MoniTool_TimerSentry::MoniTool_TimerSentry (const Handle(MoniTool_Timer)& timer)
|
||||
{
|
||||
myTimer = timer;
|
||||
myTimer->Start();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Destroy
|
||||
//purpose : make stop for corresponding timer before destroying
|
||||
//=======================================================================
|
||||
|
||||
inline void MoniTool_TimerSentry::Destroy()
|
||||
{
|
||||
if ( ! myTimer.IsNull() ) myTimer->Stop();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Timer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Handle(MoniTool_Timer) MoniTool_TimerSentry::Timer() const
|
||||
{
|
||||
return myTimer;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Stop
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void MoniTool_TimerSentry::Stop()
|
||||
{
|
||||
if ( ! myTimer.IsNull() ) myTimer->Stop();
|
||||
myTimer.Nullify();
|
||||
}
|
360
src/MoniTool/MoniTool_TypedValue.cdl
Executable file
360
src/MoniTool/MoniTool_TypedValue.cdl
Executable file
@@ -0,0 +1,360 @@
|
||||
-- File: MoniTool_TypedValue.cdl
|
||||
-- Created: Mon Feb 23 12:32:29 1998
|
||||
-- Author: Christian CAILLET
|
||||
-- <cky@fidox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class TypedValue from MoniTool inherits TShared
|
||||
|
||||
---Purpose : 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,
|
||||
Messenger from Message,
|
||||
AsciiString from TCollection, HAsciiString from TCollection,
|
||||
HArray1OfAsciiString from TColStd, HSequenceOfAsciiString from TColStd,
|
||||
DictionaryOfInteger from Dico, DictionaryOfTransient from Dico,
|
||||
ValueType from MoniTool,
|
||||
ValueSatisfies from MoniTool, ValueInterpret from MoniTool
|
||||
|
||||
raises ConstructionError
|
||||
|
||||
is
|
||||
|
||||
Create (name : CString;
|
||||
type : ValueType from MoniTool = MoniTool_ValueText;
|
||||
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
|
||||
|
||||
Create (other : TypedValue) returns mutable TypedValue;
|
||||
---Purpose : Creates a TypedValue from another one, by duplication
|
||||
|
||||
Internals (me; interp : out ValueInterpret; satisf : out ValueSatisfies;
|
||||
satisname : out CString; enums : out DictionaryOfInteger);
|
||||
---Purpose : Access to internal data which have no other access
|
||||
|
||||
Name (me) returns CString;
|
||||
---Purpose : Returns the name
|
||||
|
||||
ValueType (me) returns ValueType from MoniTool;
|
||||
---Purpose : Returns the type of the value
|
||||
|
||||
Definition (me) returns AsciiString from TCollection;
|
||||
---Purpose : Returns the Definition
|
||||
-- By priority, the enforced one, else an automatic one, computed
|
||||
-- from the specification
|
||||
|
||||
SetDefinition (me : mutable; deftext : CString);
|
||||
---Purpose : Enforces a Definition
|
||||
|
||||
Print (me; S : Messenger from Message) is virtual;
|
||||
---Purpose : Prints definition, specification, and actual status and value
|
||||
|
||||
PrintValue (me; S : Messenger from Message);
|
||||
---Purpose : Prints only the Value
|
||||
|
||||
-- -- Additional definitions -- --
|
||||
|
||||
AddDef (me : mutable; initext : CString) returns Boolean;
|
||||
---Purpose : Completes the definition of a TypedValue by command <initext>,
|
||||
-- once created with its type
|
||||
-- Returns True if done, False if could not be interpreted
|
||||
-- <initext> may be :
|
||||
-- imin ival : minimum value for an integer
|
||||
-- imax ival : maximum value for an integer
|
||||
-- rmin rval : minimum value for a real
|
||||
-- rmax rval : maximum value for a real
|
||||
-- unit name : name of unit
|
||||
-- ematch i : enum from integer value i, match required
|
||||
-- enum i : enum from integer value i, match not required
|
||||
-- eval text : add an enumerative value (increments max by 1)
|
||||
-- eval ?? : add a non-authorised enum value (to be skipped)
|
||||
-- tmax l : maximum length for a text
|
||||
|
||||
SetLabel (me : mutable; label : CString);
|
||||
---Purpose : Sets a label, which can then be displayed
|
||||
|
||||
Label (me) returns CString;
|
||||
---Purpose : Returns the label, if set; else returns an empty string
|
||||
|
||||
|
||||
SetMaxLength (me : mutable; max : Integer);
|
||||
---Purpose : Sets a maximum length for a text (active only for a free text)
|
||||
|
||||
MaxLength (me) returns Integer;
|
||||
---Purpose : Returns the maximum length, 0 if not set
|
||||
|
||||
SetIntegerLimit (me : mutable; max : Boolean; val : Integer)
|
||||
---Purpose : Sets an Integer limit (included) to <val>, the upper limit
|
||||
-- if <max> is True, the lower limit if <max> is False
|
||||
raises ConstructionError;
|
||||
-- Error for a TypedValue not an Integer
|
||||
|
||||
IntegerLimit (me; max : Boolean; val : out Integer) returns Boolean;
|
||||
---Purpose : Gives an Integer Limit (upper if <max> True, lower if <max>
|
||||
-- False). Returns True if this limit is defined, False else
|
||||
-- (in that case, gives the natural limit for Integer)
|
||||
|
||||
SetRealLimit (me : mutable; max : Boolean; val : Real)
|
||||
---Purpose : Sets a Real limit (included) to <val>, the upper limit
|
||||
-- if <max> is True, the lower limit if <max> is False
|
||||
raises ConstructionError;
|
||||
-- Error for a TypedValue not a Real
|
||||
|
||||
RealLimit (me; max : Boolean; val : out Real) returns Boolean;
|
||||
---Purpose : Gives an Real Limit (upper if <max> True, lower if <max>
|
||||
-- False). Returns True if this limit is defined, False else
|
||||
-- (in that case, gives the natural limit for Real)
|
||||
|
||||
SetUnitDef (me : mutable; def : CString)
|
||||
---Purpose : Sets (Clears if <def> empty) a unit definition, as an equation
|
||||
-- of dimensions. TypedValue just records this definition, does
|
||||
-- not exploit it, to be done as required by user applications
|
||||
raises ConstructionError;
|
||||
-- Error for a TypedValue not a Real
|
||||
|
||||
UnitDef (me) returns CString;
|
||||
---Purpose : Returns the recorded unit definition, empty if not set
|
||||
|
||||
|
||||
StartEnum (me : mutable;
|
||||
start : Integer = 0; match : Boolean = Standard_True)
|
||||
---Purpose : For an enumeration, precises the starting value (default 0)
|
||||
-- and the match condition : if True (D), the string value must
|
||||
-- match the definition, else it may take another value : in that
|
||||
-- case, the Integer Value will be Start - 1.
|
||||
-- (empty value remains allowed)
|
||||
raises ConstructionError;
|
||||
-- Error for a TypedValue not an Enum
|
||||
|
||||
AddEnum (me : mutable; v1,v2,v3,v4,v5,v6,v7,v8,v9,v10 : CString = "")
|
||||
---Purpose : Adds enumerative definitions. For more than 10, several calls
|
||||
raises ConstructionError;
|
||||
-- Error for a TypedValue not an Enum
|
||||
|
||||
AddEnumValue (me : mutable; val : CString; num : Integer)
|
||||
---Purpose : Adds an enumeration definition, by its string and numeric
|
||||
-- values. If it is the first setting for this value, it is
|
||||
-- recorded as main value. Else, it is recognized as alternate
|
||||
-- string for this numeric value
|
||||
raises ConstructionError;
|
||||
-- Error for a TypedValue not an Enum
|
||||
|
||||
EnumDef (me; startcase, endcase : out Integer; match : out Boolean)
|
||||
returns Boolean;
|
||||
---Purpose : Gives the Enum definitions : start value, end value, match
|
||||
-- status. Returns True for an Enum, False else.
|
||||
|
||||
EnumVal (me; num : Integer) returns CString;
|
||||
---Purpose : Returns the value of an enumerative definition, from its rank
|
||||
-- Empty string if out of range or not an Enum
|
||||
|
||||
EnumCase (me; val : CString) returns Integer;
|
||||
---Purpose : Returns the case number which cooresponds to a string value
|
||||
-- Works with main and additionnal values
|
||||
-- Returns (StartEnum - 1) if not OK, -1 if not an Enum
|
||||
|
||||
SetObjectType (me : mutable; typ : Type)
|
||||
---Purpose : Sets type of which an Object TypedValue must be kind of
|
||||
raises ConstructionError;
|
||||
---Purpose: Error for a TypedValue not an Object (Entity)
|
||||
|
||||
ObjectType (me) returns Type;
|
||||
---Purpose : Returns the type of which an Object TypedValue must be kind of
|
||||
-- Default is Standard_Transient
|
||||
-- Null for a TypedValue not an Object
|
||||
|
||||
SetInterpret (me : mutable; func : ValueInterpret);
|
||||
---Purpose : Sets a specific Interpret function
|
||||
|
||||
HasInterpret (me) returns Boolean is virtual;
|
||||
---Purpose : Tells if a TypedValue has an Interpret
|
||||
|
||||
SetSatisfies (me : mutable; func : ValueSatisfies; name : CString);
|
||||
---Purpose : Sets a specific Satisfies function : it is added to the
|
||||
-- already defined criteria
|
||||
-- It must match the form :
|
||||
-- statisfies (val : HAsciiString) returns Boolean
|
||||
|
||||
SatisfiesName (me) returns CString;
|
||||
---Purpose : Returns name of specific satisfy, empty string if none
|
||||
|
||||
-- -- Value -- --
|
||||
|
||||
IsSetValue (me) returns Boolean;
|
||||
---Purpose : Returns True if the value is set (not empty/not null object)
|
||||
|
||||
CStringValue (me) returns CString;
|
||||
---Purpose : Returns the value, as a cstring. Empty if not set.
|
||||
|
||||
HStringValue (me) returns mutable HAsciiString;
|
||||
---Purpose : Returns the value, as a Handle (can then be shared)
|
||||
-- Null if not defined
|
||||
|
||||
Interpret (me; hval : HAsciiString; native : Boolean)
|
||||
returns HAsciiString is virtual;
|
||||
---Purpose : Interprets a value.
|
||||
-- <native> True : returns a native value
|
||||
-- <native> False : returns a coded value
|
||||
-- If the Interpret function is set, calls it
|
||||
-- Else, for an Enum, Native returns the Text, Coded returns
|
||||
-- the number
|
||||
-- STANDARD RETURNS : = hval means no specific interpretation
|
||||
-- Null means senseless
|
||||
-- Can also be redefined
|
||||
|
||||
Satisfies (me; hval : HAsciiString) returns Boolean is virtual;
|
||||
---Purpose : Returns True if a value statifies the specification
|
||||
-- (remark : does not apply to Entity : see ObjectType, for this
|
||||
-- type, the string is just a comment)
|
||||
|
||||
ClearValue (me : mutable);
|
||||
---Purpose : Clears the recorded Value : it is now unset
|
||||
|
||||
SetCStringValue (me : mutable; val : CString)
|
||||
---Purpose : Changes the value. The new one must satisfy the specification
|
||||
returns Boolean is virtual;
|
||||
---Purpose: Returns False (and did not set) if the new value
|
||||
-- does not satisfy the specification
|
||||
-- Can be redefined to be managed (in a subclass)
|
||||
|
||||
SetHStringValue (me : mutable; hval : mutable HAsciiString)
|
||||
---Purpose : Forces a new Handle for the Value
|
||||
-- It can be empty, else (if Type is not free Text), it must
|
||||
-- satisfy the specification.
|
||||
-- Not only the value is changed, but also the way it is shared
|
||||
-- Remark : for Type=Object, this value is not controlled, it can
|
||||
-- be set as a comment
|
||||
returns Boolean is virtual;
|
||||
---Purpose: Returns False (and did not set) if the new value
|
||||
-- does not satisfy the specification
|
||||
-- Can be redefined to be managed (in a subclass)
|
||||
|
||||
IntegerValue (me) returns Integer;
|
||||
---Purpose : Returns the value as integer, i.e. :
|
||||
-- For type = Integer, the integer itself; 0 if not set
|
||||
-- For type = Enum, the designated rank (see Enum definition)
|
||||
-- StartEnum - 1 if not set or not in the definition
|
||||
-- Else, returns 0
|
||||
|
||||
SetIntegerValue (me : mutable; ival : Integer)
|
||||
---Purpose : Changes the value as an integer, only for Integer or Enum
|
||||
returns Boolean is virtual;
|
||||
-- Returns False (and did not set) if type is neither Integer
|
||||
-- nor Enum, or if ival is out of range (if a range is specified)
|
||||
-- Can be redefined to be managed (in a subclass)
|
||||
|
||||
RealValue (me) returns Real;
|
||||
---Purpose : Returns the value as real, for a Real type TypedValue
|
||||
-- Else, returns 0.
|
||||
|
||||
SetRealValue (me : mutable; rval : Real)
|
||||
---Purpose : Changes the value as a real, only for Real
|
||||
returns Boolean is virtual;
|
||||
-- Returns False (and did not set) if type is not Real or
|
||||
-- out of range (if a range is specified)
|
||||
-- Can be redefined to be managed (in a subclass)
|
||||
|
||||
ObjectValue (me) returns any Transient;
|
||||
---Purpose : Returns the value as Transient Object, only for Object/Entity
|
||||
-- Remark that the "HString value" is IGNORED here
|
||||
-- Null if not set; remains to be casted
|
||||
|
||||
GetObjectValue (me; val : out Transient);
|
||||
---Purpose : Same as ObjectValue, but avoids DownCast : the receiving
|
||||
-- variable is directly loaded. It is assumed that it complies
|
||||
-- with the definition of ObjectType ! Otherwise, big trouble
|
||||
|
||||
SetObjectValue (me : mutable; obj : any Transient)
|
||||
returns Boolean is virtual;
|
||||
---Purpose : Changes the value as Transient Object, only for Object/Entity
|
||||
-- Returns False if DynamicType does not satisfy ObjectType
|
||||
-- Can be redefined to be managed (in a subclass)
|
||||
|
||||
ObjectTypeName (me) returns CString;
|
||||
---Purpose : Returns the type name of the ObjectValue, or an empty string
|
||||
-- if not set
|
||||
|
||||
-- -- Library of TypedValue as Type Definitions, -- --
|
||||
-- accessed by definition name
|
||||
-- It starts with 3 basic types : "Integer" "Real" "Text"
|
||||
|
||||
AddLib (myclass; tv : TypedValue; def : CString = "") returns Boolean;
|
||||
---Purpose : Adds a TypedValue in the library.
|
||||
-- It is recorded then will be accessed by its Name
|
||||
-- Its Definition may be imposed, else it is computed as usual
|
||||
-- By default it will be accessed by its Definition (string)
|
||||
-- Returns True if done, False if tv is Null or brings no
|
||||
-- Definition or <def> not defined
|
||||
--
|
||||
-- If a TypedValue was already recorded under this name, it is
|
||||
-- replaced
|
||||
|
||||
Lib (myclass; def : CString) returns TypedValue;
|
||||
---Purpose : Returns the TypedValue bound with a given Name
|
||||
-- Null Handle if none recorded
|
||||
-- Warning : it is the original, not duplicated
|
||||
|
||||
FromLib (myclass; def : CString) returns TypedValue;
|
||||
---Purpose : Returns a COPY of the TypedValue bound with a given Name
|
||||
-- Null Handle if none recorded
|
||||
|
||||
LibList (myclass) returns HSequenceOfAsciiString;
|
||||
---Purpose : Returns the list of names of items of the Library of Types
|
||||
-- -- Library of TypedValue as Valued Parameters, -- --
|
||||
-- accessed by parameter name
|
||||
-- for use by management of Static Parameters
|
||||
|
||||
Stats (myclass) returns DictionaryOfTransient is protected;
|
||||
---Purpose : Gives the internal library of static values
|
||||
|
||||
StaticValue (myclass; name : CString) returns TypedValue;
|
||||
---Purpose : Returns a static value from its name, null if unknown
|
||||
|
||||
fields
|
||||
|
||||
thename : AsciiString;
|
||||
thedef : AsciiString;
|
||||
thelabel : AsciiString;
|
||||
thetype : ValueType from MoniTool;
|
||||
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 TypedValue;
|
765
src/MoniTool/MoniTool_TypedValue.cxx
Executable file
765
src/MoniTool/MoniTool_TypedValue.cxx
Executable file
@@ -0,0 +1,765 @@
|
||||
#include <MoniTool_TypedValue.ixx>
|
||||
|
||||
#include <Dico_DictionaryOfInteger.hxx>
|
||||
#include <Dico_IteratorOfDictionaryOfInteger.hxx>
|
||||
#include <Dico_DictionaryOfTransient.hxx>
|
||||
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
|
||||
#include <MoniTool_Element.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
|
||||
#include <OSD_Path.hxx>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
// Not Used :
|
||||
//static char defmess[30];
|
||||
|
||||
static Handle(Dico_DictionaryOfTransient) libtv()
|
||||
{
|
||||
static Handle(Dico_DictionaryOfTransient) thelibtv;
|
||||
if (thelibtv.IsNull()) {
|
||||
thelibtv = new Dico_DictionaryOfTransient;
|
||||
Handle(MoniTool_TypedValue) tv;
|
||||
tv = new MoniTool_TypedValue("Integer",MoniTool_ValueInteger);
|
||||
thelibtv->SetItem ("Integer",tv);
|
||||
tv = new MoniTool_TypedValue("Real",MoniTool_ValueReal);
|
||||
thelibtv->SetItem ("Real",tv);
|
||||
tv = new MoniTool_TypedValue("Text",MoniTool_ValueText);
|
||||
thelibtv->SetItem ("Text",tv);
|
||||
tv = new MoniTool_TypedValue("Transient",MoniTool_ValueIdent);
|
||||
thelibtv->SetItem ("Transient",tv);
|
||||
tv = new MoniTool_TypedValue("Boolean",MoniTool_ValueEnum);
|
||||
tv->AddDef ("enum 0"); // = 0 False , > 0 True
|
||||
tv->AddDef ("eval False");
|
||||
tv->AddDef ("eval True");
|
||||
thelibtv->SetItem ("Boolean",tv);
|
||||
tv = new MoniTool_TypedValue("Logical",MoniTool_ValueEnum);
|
||||
tv->AddDef ("enum -1"); // < 0 False , = 0 Unk , > 0 True
|
||||
tv->AddDef ("eval False");
|
||||
tv->AddDef ("eval Unknown");
|
||||
tv->AddDef ("eval True");
|
||||
thelibtv->SetItem ("Logical",tv);
|
||||
}
|
||||
return thelibtv;
|
||||
}
|
||||
|
||||
|
||||
// Fonctions Satisfies offertes en standard ...
|
||||
/* Not Used
|
||||
|
||||
static Standard_Boolean StaticPath(const Handle(TCollection_HAsciiString)& val)
|
||||
{
|
||||
OSD_Path apath;
|
||||
return apath.IsValid (TCollection_AsciiString(val->ToCString()));
|
||||
}
|
||||
*/
|
||||
|
||||
MoniTool_TypedValue::MoniTool_TypedValue
|
||||
(const Standard_CString name,
|
||||
const MoniTool_ValueType type, const Standard_CString init)
|
||||
: thename (name) , thetype (type) ,
|
||||
thelims (0), themaxlen (0) , theintlow (0) , theintup (-1) ,
|
||||
theinterp (NULL) , thesatisf (NULL) ,
|
||||
theival (0),
|
||||
thehval (new TCollection_HAsciiString(""))
|
||||
{
|
||||
if (type != MoniTool_ValueInteger && type != MoniTool_ValueReal &&
|
||||
type != MoniTool_ValueEnum && type != MoniTool_ValueText &&
|
||||
type != MoniTool_ValueIdent)
|
||||
Standard_ConstructionError::Raise("MoniTool_TypedValue : Type not supported");
|
||||
if (init[0] != '\0')
|
||||
if (Satisfies(new TCollection_HAsciiString(init))) SetCStringValue (init);
|
||||
|
||||
}
|
||||
|
||||
|
||||
MoniTool_TypedValue::MoniTool_TypedValue
|
||||
(const Handle(MoniTool_TypedValue)& other)
|
||||
: thename (other->Name()) , thedef (other->Definition()) ,
|
||||
thelabel (other->Label()) , thetype (other->ValueType()) ,
|
||||
theotyp (other->ObjectType()) ,
|
||||
thelims (0) , themaxlen (other->MaxLength()) ,
|
||||
theintlow (0) , theintup (0) , therealow (0) , therealup (0) ,
|
||||
theunidef (other->UnitDef()) ,
|
||||
theival (other->IntegerValue()) , thehval (other->HStringValue()) ,
|
||||
theoval (other->ObjectValue())
|
||||
{
|
||||
Handle(Dico_DictionaryOfInteger) eadds;
|
||||
Standard_CString satisname;
|
||||
other->Internals (theinterp,thesatisf,satisname, eadds);
|
||||
thesatisn.AssignCat (satisname);
|
||||
|
||||
if (other->IntegerLimit (Standard_False,theintlow)) thelims |= 1;
|
||||
if (other->IntegerLimit (Standard_True ,theintup )) thelims |= 2;
|
||||
if (other->RealLimit (Standard_False,therealow)) thelims |= 1;
|
||||
if (other->RealLimit (Standard_True ,therealup)) thelims |= 2;
|
||||
|
||||
Standard_Integer startcase, endcase; Standard_Boolean match;
|
||||
if (other->EnumDef (startcase,endcase,match)) {
|
||||
theintlow = startcase; theintup = endcase;
|
||||
if (match) thelims |= 4;
|
||||
if (theintup >= theintlow) theenums = new TColStd_HArray1OfAsciiString (theintlow,theintup);
|
||||
for (startcase = theintlow; startcase <= theintup; startcase ++) {
|
||||
theenums->SetValue (startcase,other->EnumVal (startcase));
|
||||
}
|
||||
}
|
||||
// dupliquer theeadds
|
||||
if (!eadds.IsNull()) {
|
||||
theeadds = new Dico_DictionaryOfInteger;
|
||||
Dico_IteratorOfDictionaryOfInteger itad (eadds);
|
||||
for (; itad.More(); itad.Next()) theeadds->SetItem (itad.Name(),itad.Value());
|
||||
}
|
||||
|
||||
// on duplique la string
|
||||
if (!thehval.IsNull()) thehval = new TCollection_HAsciiString (other->CStringValue());
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_TypedValue::Internals
|
||||
(MoniTool_ValueInterpret& interp, MoniTool_ValueSatisfies& satisf,
|
||||
Standard_CString& satisname,
|
||||
Handle(Dico_DictionaryOfInteger)& enums) const
|
||||
{ interp = theinterp; satisf = thesatisf; satisname = thesatisn.ToCString();
|
||||
enums = theeadds; }
|
||||
|
||||
Standard_CString MoniTool_TypedValue::Name () const
|
||||
{ return thename.ToCString(); }
|
||||
|
||||
MoniTool_ValueType MoniTool_TypedValue::ValueType () const
|
||||
{ return thetype; }
|
||||
|
||||
TCollection_AsciiString MoniTool_TypedValue::Definition () const
|
||||
{
|
||||
if (thedef.Length() > 0) return thedef;
|
||||
TCollection_AsciiString def;
|
||||
char mess[50];
|
||||
switch (thetype) {
|
||||
case MoniTool_ValueInteger : {
|
||||
def.AssignCat("Integer");
|
||||
Standard_Integer ilim;
|
||||
if (IntegerLimit(Standard_False, ilim)) {
|
||||
sprintf(mess," >= %d",ilim);
|
||||
def.AssignCat(mess);
|
||||
}
|
||||
if (IntegerLimit(Standard_True, ilim)) {
|
||||
sprintf(mess," <= %d",ilim);
|
||||
def.AssignCat(mess);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MoniTool_ValueReal : {
|
||||
def.AssignCat("Real");
|
||||
Standard_Real rlim;
|
||||
if (RealLimit(Standard_False, rlim)) {
|
||||
sprintf(mess," >= %f",rlim);
|
||||
def.AssignCat(mess);
|
||||
}
|
||||
if (RealLimit(Standard_True, rlim)) {
|
||||
sprintf(mess," <= %f",rlim);
|
||||
def.AssignCat(mess);
|
||||
}
|
||||
if (theunidef.Length() > 0)
|
||||
{ def.AssignCat(" Unit:"); def.AssignCat(UnitDef()); }
|
||||
}
|
||||
break;
|
||||
case MoniTool_ValueEnum : {
|
||||
def.AssignCat("Enum");
|
||||
Standard_Integer startcase, endcase; Standard_Boolean match;
|
||||
EnumDef (startcase,endcase,match);
|
||||
sprintf(mess," [%s%d-%d]",(match ? "in " : ""),startcase,endcase);
|
||||
def.AssignCat(mess);
|
||||
for (Standard_Integer i = startcase; i <= endcase; i ++) {
|
||||
Standard_CString enva = EnumVal(i);
|
||||
if (enva[0] == '?' || enva[0] == '\0') continue;
|
||||
sprintf(mess," %d:%s",i,enva);
|
||||
def.AssignCat (mess);
|
||||
}
|
||||
if (!theeadds.IsNull()) {
|
||||
def.AssignCat(" , alpha: ");
|
||||
Dico_IteratorOfDictionaryOfInteger listadd(theeadds);
|
||||
for (listadd.Start(); listadd.More(); listadd.Next()) {
|
||||
Standard_CString enva = listadd.Name().ToCString();
|
||||
if (enva[0] == '?') continue;
|
||||
sprintf(mess,":%d ",listadd.Value());
|
||||
def.AssignCat (enva);
|
||||
def.AssignCat (mess);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MoniTool_ValueIdent : {
|
||||
def.AssignCat("Object(Entity)");
|
||||
if (!theotyp.IsNull()) {
|
||||
def.AssignCat(":");
|
||||
def.AssignCat(theotyp->Name());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MoniTool_ValueText : {
|
||||
def.AssignCat("Text");
|
||||
if (themaxlen > 0) {
|
||||
sprintf (mess," <= %d C.",themaxlen);
|
||||
def.AssignCat (mess);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default : def.AssignCat("(undefined)"); break;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
void MoniTool_TypedValue::SetDefinition (const Standard_CString deftext)
|
||||
{ thedef.Clear(); thedef.AssignCat(deftext); }
|
||||
|
||||
// ## Print ##
|
||||
|
||||
void MoniTool_TypedValue::Print (const Handle(Message_Messenger)& S) const
|
||||
{
|
||||
S<<"--- Typed Value : "<<Name();
|
||||
if (thelabel.Length() > 0) S<<" Label : "<<Label();
|
||||
S<<endl<<"--- Type : "<<Definition()<<endl<<"--- Value : ";
|
||||
|
||||
PrintValue (S);
|
||||
S<<endl;
|
||||
|
||||
if (thesatisf) S<<" -- Specific Function for Satisfies : "<<thesatisn.ToCString()<<endl;
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_TypedValue::PrintValue (const Handle(Message_Messenger)& S) const
|
||||
{
|
||||
if (IsSetValue()) {
|
||||
if (thetype == MoniTool_ValueIdent)
|
||||
S<<" (type) "<<theoval->DynamicType()->Name();
|
||||
if (!thehval.IsNull())
|
||||
S<<(thetype == MoniTool_ValueIdent ? " : " : "")<<thehval->ToCString();
|
||||
|
||||
if (HasInterpret()) {
|
||||
S<<" (";
|
||||
Handle(TCollection_HAsciiString) str = Interpret (thehval,Standard_True);
|
||||
if (!str.IsNull() && str != thehval) S<<"Native:"<<str->ToCString();
|
||||
str = Interpret (thehval,Standard_False);
|
||||
if (!str.IsNull() && str != thehval) S<<" Coded:"<<str->ToCString();
|
||||
S<<")";
|
||||
}
|
||||
}
|
||||
else S<<"(not set)";
|
||||
}
|
||||
|
||||
|
||||
// ######### COMPLEMENTS ##########
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::AddDef
|
||||
(const Standard_CString init)
|
||||
{
|
||||
// Editions : init donne un petit texte d edition, en 2 termes "cmd var" :
|
||||
Standard_Integer i,iblc = 0;
|
||||
for (i = 0; init[i] != '\0'; i ++) if (init[i] == ' ') iblc = i+1;
|
||||
if (iblc == 0) return Standard_False;
|
||||
// Reconnaissance du sous-cas et aiguillage
|
||||
if (init[0] == 'i' && init[2] == 'i') // imin ival
|
||||
SetIntegerLimit (Standard_False,atoi(&init[iblc]));
|
||||
else if (init[0] == 'i' && init[2] == 'a') // imax ival
|
||||
SetIntegerLimit (Standard_True ,atoi(&init[iblc]));
|
||||
else if (init[0] == 'r' && init[2] == 'i') // rmin rval
|
||||
SetRealLimit (Standard_False,atof(&init[iblc]));
|
||||
else if (init[0] == 'r' && init[2] == 'a') // rmax rval
|
||||
SetRealLimit (Standard_True ,atof(&init[iblc]));
|
||||
else if (init[0] == 'u') // unit name
|
||||
SetUnitDef (&init[iblc]);
|
||||
else if (init[0] == 'e' && init[1] == 'm') // ematch istart
|
||||
StartEnum (atoi(&init[iblc]),Standard_True);
|
||||
else if (init[0] == 'e' && init[1] == 'n') // enum istart
|
||||
StartEnum (atoi(&init[iblc]),Standard_False);
|
||||
else if (init[0] == 'e' && init[1] == 'v') // eval text
|
||||
AddEnum (&init[iblc]);
|
||||
else if (init[0] == 't' && init[1] == 'm') // tmax length
|
||||
SetMaxLength (atoi(&init[iblc]));
|
||||
|
||||
else return Standard_False;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_TypedValue::SetLabel (const Standard_CString label)
|
||||
{ thelabel.Clear(); thelabel.AssignCat (label); }
|
||||
|
||||
Standard_CString MoniTool_TypedValue::Label () const
|
||||
{ return thelabel.ToCString(); }
|
||||
|
||||
|
||||
|
||||
void MoniTool_TypedValue::SetMaxLength
|
||||
(const Standard_Integer max)
|
||||
{ themaxlen = max; if (max < 0) themaxlen = 0; }
|
||||
|
||||
Standard_Integer MoniTool_TypedValue::MaxLength () const
|
||||
{ return themaxlen; }
|
||||
|
||||
void MoniTool_TypedValue::SetIntegerLimit
|
||||
(const Standard_Boolean max, const Standard_Integer val)
|
||||
{
|
||||
if (thetype != MoniTool_ValueInteger) Standard_ConstructionError::Raise
|
||||
("MoniTool_TypedValue : SetIntegerLimit, not an Integer");
|
||||
|
||||
if (max) { thelims |= 2; theintup = val; }
|
||||
else { thelims |= 1; theintlow = val; }
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::IntegerLimit
|
||||
(const Standard_Boolean max, Standard_Integer& val) const
|
||||
{
|
||||
Standard_Boolean res = Standard_False;
|
||||
if (max) { res = (thelims & 2) != 0; val = (res ? theintup : IntegerLast()); }
|
||||
else { res = (thelims & 1) != 0; val = (res ? theintlow : IntegerFirst()); }
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void MoniTool_TypedValue::SetRealLimit
|
||||
(const Standard_Boolean max, const Standard_Real val)
|
||||
{
|
||||
if (thetype != MoniTool_ValueReal) Standard_ConstructionError::Raise
|
||||
("MoniTool_TypedValue : SetRealLimit, not a Real");
|
||||
|
||||
if (max) { thelims |= 2; therealup = val; }
|
||||
else { thelims |= 1; therealow = val; }
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::RealLimit
|
||||
(const Standard_Boolean max, Standard_Real& val) const
|
||||
{
|
||||
Standard_Boolean res = Standard_False;
|
||||
if (max) { res = (thelims & 2) != 0; val = (res ? therealup : RealLast()); }
|
||||
else { res = (thelims & 1) != 0; val = (res ? therealow : RealFirst()); }
|
||||
return res;
|
||||
}
|
||||
|
||||
void MoniTool_TypedValue::SetUnitDef (const Standard_CString def)
|
||||
{ theunidef.Clear(); theunidef.AssignCat(def); }
|
||||
|
||||
Standard_CString MoniTool_TypedValue::UnitDef () const
|
||||
{ return theunidef.ToCString(); }
|
||||
|
||||
// ****** les enums ******
|
||||
|
||||
void MoniTool_TypedValue::StartEnum
|
||||
(const Standard_Integer start, const Standard_Boolean match)
|
||||
{
|
||||
if (thetype != MoniTool_ValueEnum) Standard_ConstructionError::Raise
|
||||
("MoniTool_TypedValue : StartEnum, Not an Enum");
|
||||
|
||||
thelims |= 4; if (!match) thelims -= 4;
|
||||
theintlow = start; theintup = start -1;
|
||||
}
|
||||
|
||||
void MoniTool_TypedValue::AddEnum
|
||||
(const Standard_CString v1, const Standard_CString v2,
|
||||
const Standard_CString v3, const Standard_CString v4,
|
||||
const Standard_CString v5, const Standard_CString v6,
|
||||
const Standard_CString v7, const Standard_CString v8,
|
||||
const Standard_CString v9, const Standard_CString v10)
|
||||
{
|
||||
if (thetype != MoniTool_ValueEnum) Standard_ConstructionError::Raise
|
||||
("MoniTool_TypedValue : AddEnum, Not an Enum");
|
||||
if (theenums.IsNull()) theenums =
|
||||
new TColStd_HArray1OfAsciiString(theintlow,theintlow+10);
|
||||
else if (theenums->Upper() < theintup + 10) {
|
||||
Handle(TColStd_HArray1OfAsciiString) enums =
|
||||
new TColStd_HArray1OfAsciiString(theintlow,theintup+10);
|
||||
for (Standard_Integer i = theintlow; i <= theintup; i ++)
|
||||
enums->SetValue(i,theenums->Value(i));
|
||||
theenums = enums;
|
||||
}
|
||||
|
||||
if (theeadds.IsNull()) theeadds = new Dico_DictionaryOfInteger;
|
||||
if (v1[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v1));
|
||||
theeadds->SetItem (v1,theintup);
|
||||
}
|
||||
if (v2[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v2));
|
||||
theeadds->SetItem (v2,theintup);
|
||||
}
|
||||
if (v3[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v3));
|
||||
theeadds->SetItem (v3,theintup);
|
||||
}
|
||||
if (v4[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v4));
|
||||
theeadds->SetItem (v4,theintup);
|
||||
}
|
||||
if (v5[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v5));
|
||||
theeadds->SetItem (v5,theintup);
|
||||
}
|
||||
if (v6[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v6));
|
||||
theeadds->SetItem (v6,theintup);
|
||||
}
|
||||
if (v7[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v7));
|
||||
theeadds->SetItem (v7,theintup);
|
||||
}
|
||||
if (v8[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v8));
|
||||
theeadds->SetItem (v8,theintup);
|
||||
}
|
||||
if (v9[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v9));
|
||||
theeadds->SetItem (v9,theintup);
|
||||
}
|
||||
if (v10[0] != '\0') {
|
||||
theintup ++; theenums->SetValue(theintup,TCollection_AsciiString(v10));
|
||||
theeadds->SetItem (v10,theintup);
|
||||
}
|
||||
}
|
||||
|
||||
void MoniTool_TypedValue::AddEnumValue
|
||||
(const Standard_CString val, const Standard_Integer num)
|
||||
{
|
||||
if (thetype != MoniTool_ValueEnum) Standard_ConstructionError::Raise
|
||||
("MoniTool_TypedValue : AddEnum, Not an Enum");
|
||||
if (num < theintlow) Standard_ConstructionError::Raise
|
||||
("MoniTool_TypedValue : AddEnum, out of range");
|
||||
if (val[0] == '\0') return;
|
||||
if (theenums.IsNull()) theenums =
|
||||
new TColStd_HArray1OfAsciiString(theintlow,num+1);
|
||||
else if (theenums->Upper() < num) {
|
||||
Handle(TColStd_HArray1OfAsciiString) enums =
|
||||
new TColStd_HArray1OfAsciiString(theintlow,num+1);
|
||||
for (Standard_Integer i = theintlow; i <= theintup; i ++)
|
||||
enums->SetValue(i,theenums->Value(i));
|
||||
theenums = enums;
|
||||
}
|
||||
|
||||
if (theintup < num) theintup = num;
|
||||
if (theenums->Value(num).Length() == 0)
|
||||
theenums->SetValue(num,TCollection_AsciiString(val));
|
||||
// On met AUSSI dans le dictionnaire
|
||||
// else {
|
||||
if (theeadds.IsNull()) theeadds = new Dico_DictionaryOfInteger;
|
||||
theeadds->SetItem (val,num);
|
||||
// }
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::EnumDef
|
||||
(Standard_Integer& startcase, Standard_Integer& endcase,
|
||||
Standard_Boolean& match) const
|
||||
{
|
||||
if (thetype != MoniTool_ValueEnum) return Standard_False;
|
||||
startcase = theintlow; endcase = theintup;
|
||||
match = ((thelims & 4) != 0);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_CString MoniTool_TypedValue::EnumVal
|
||||
(const Standard_Integer num) const
|
||||
{
|
||||
if (thetype != MoniTool_ValueEnum) return "";
|
||||
if (num < theintlow || num > theintup) return "";
|
||||
return theenums->Value(num).ToCString();
|
||||
}
|
||||
|
||||
Standard_Integer MoniTool_TypedValue::EnumCase
|
||||
(const Standard_CString val) const
|
||||
{
|
||||
if (thetype != MoniTool_ValueEnum) return (theintlow - 1);
|
||||
Standard_Integer i; // svv Jan 10 2000 : porting on DEC
|
||||
for (i = theintlow; i <= theintup; i ++)
|
||||
if (theenums->Value(i).IsEqual(val)) return i;
|
||||
// cas additionnel ?
|
||||
if (!theeadds.IsNull()) {
|
||||
if (theeadds->GetItem (val,i,Standard_False)) return i;
|
||||
}
|
||||
// entier possible
|
||||
//gka S4054
|
||||
for (i = 0; val[i] != '\0'; i ++)
|
||||
if (val[i] != ' ' && val[i] != '-' && (val[i] < '0' || val[i] > '9' )) return (theintlow -1);
|
||||
return atoi(val);
|
||||
}
|
||||
|
||||
// ****** object/entity ******
|
||||
|
||||
void MoniTool_TypedValue::SetObjectType
|
||||
(const Handle(Standard_Type)& typ)
|
||||
{
|
||||
if (thetype != MoniTool_ValueIdent) Standard_ConstructionError::Raise
|
||||
("MoniTool_TypedValue : AddEnum, Not an Entity/Object");
|
||||
theotyp = typ;
|
||||
}
|
||||
|
||||
Handle(Standard_Type) MoniTool_TypedValue::ObjectType () const
|
||||
{
|
||||
if (!theotyp.IsNull()) return theotyp;
|
||||
return STANDARD_TYPE(Standard_Transient);
|
||||
}
|
||||
|
||||
// ****** Specific Interpret/Satisfy ******
|
||||
|
||||
void MoniTool_TypedValue::SetInterpret
|
||||
(const MoniTool_ValueInterpret func)
|
||||
{ theinterp = func; }
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::HasInterpret () const
|
||||
{
|
||||
if (theinterp) return Standard_True;
|
||||
if (thetype == MoniTool_ValueEnum) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
void MoniTool_TypedValue::SetSatisfies
|
||||
(const MoniTool_ValueSatisfies func, const Standard_CString name)
|
||||
{
|
||||
thesatisn.Clear();
|
||||
thesatisf = func;
|
||||
if (thesatisf) thesatisn.AssignCat (name);
|
||||
}
|
||||
|
||||
Standard_CString MoniTool_TypedValue::SatisfiesName () const
|
||||
{ return thesatisn.ToCString(); }
|
||||
|
||||
// ########### VALEUR DU STATIC ############
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::IsSetValue () const
|
||||
{
|
||||
if (thetype == MoniTool_ValueIdent) return (!theoval.IsNull());
|
||||
if (thehval->Length() > 0) return Standard_True;
|
||||
if (!theoval.IsNull()) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_CString MoniTool_TypedValue::CStringValue () const
|
||||
{ if (thehval.IsNull()) return ""; return thehval->ToCString(); }
|
||||
|
||||
Handle(TCollection_HAsciiString) MoniTool_TypedValue::HStringValue () const
|
||||
{ return thehval; }
|
||||
|
||||
Handle(TCollection_HAsciiString) MoniTool_TypedValue::Interpret
|
||||
(const Handle(TCollection_HAsciiString)& hval,
|
||||
const Standard_Boolean native) const
|
||||
{
|
||||
Handle(TCollection_HAsciiString) inter = hval;
|
||||
if (hval.IsNull()) return hval;
|
||||
if (theinterp) return theinterp (this,hval,native);
|
||||
if (thetype == MoniTool_ValueEnum) {
|
||||
// On admet les deux formes : Enum de preference, sinon Integer
|
||||
Standard_Integer startcase, endcase; Standard_Boolean match;
|
||||
EnumDef (startcase,endcase,match);
|
||||
Standard_Integer encas = EnumCase (hval->ToCString());
|
||||
if (encas < startcase) return hval; // loupe
|
||||
if (native) inter = new TCollection_HAsciiString (EnumVal(encas));
|
||||
else inter = new TCollection_HAsciiString (encas);
|
||||
}
|
||||
return inter;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::Satisfies
|
||||
(const Handle(TCollection_HAsciiString)& val) const
|
||||
{
|
||||
if (val.IsNull()) return Standard_False;
|
||||
if (thesatisf)
|
||||
if (!thesatisf (val) ) return Standard_False;
|
||||
if (val->Length() == 0) return Standard_True;
|
||||
switch (thetype) {
|
||||
case MoniTool_ValueInteger : {
|
||||
if (!val->IsIntegerValue()) return Standard_False;
|
||||
Standard_Integer ival, ilim; ival = atoi(val->ToCString());
|
||||
if (IntegerLimit(Standard_False, ilim))
|
||||
if (ilim > ival) return Standard_False;
|
||||
if (IntegerLimit(Standard_True, ilim))
|
||||
if (ilim < ival) return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
case MoniTool_ValueReal : {
|
||||
if (!val->IsRealValue()) return Standard_False;
|
||||
Standard_Real rval, rlim; rval = val->RealValue();
|
||||
if (RealLimit(Standard_False, rlim))
|
||||
if (rlim > rval) return Standard_False;
|
||||
if (RealLimit(Standard_True, rlim))
|
||||
if (rlim < rval) return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
case MoniTool_ValueEnum : {
|
||||
// On admet les deux formes : Enum de preference, sinon Integer
|
||||
Standard_Integer startcase, endcase;// unused ival;
|
||||
Standard_Boolean match;
|
||||
EnumDef (startcase,endcase,match);
|
||||
if (!match) return Standard_True;
|
||||
if (EnumCase (val->ToCString()) >= startcase) return Standard_True;
|
||||
// Ici, on admet un entier dans la fourchette
|
||||
//// if (val->IsIntegerValue()) ival = atoi (val->ToCString());
|
||||
|
||||
// PTV 16.09.2000 The if is comment, cause this check is never been done (You can see the logic)
|
||||
// if (ival >= startcase && ival <= endcase) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
case MoniTool_ValueText : {
|
||||
if (themaxlen > 0 && val->Length() > themaxlen) return Standard_False;
|
||||
break;
|
||||
}
|
||||
default : break;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
void MoniTool_TypedValue::ClearValue ()
|
||||
{
|
||||
thehval.Nullify();
|
||||
theoval.Nullify();
|
||||
theival = 0;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::SetCStringValue
|
||||
(const Standard_CString val)
|
||||
{
|
||||
Handle(TCollection_HAsciiString) hval = new TCollection_HAsciiString(val);
|
||||
if (hval->IsSameString (thehval)) return Standard_True;
|
||||
if (!Satisfies(hval)) return Standard_False;
|
||||
if (thetype == MoniTool_ValueInteger) {
|
||||
thehval->Clear();
|
||||
theival = atoi(val);
|
||||
thehval->AssignCat(val);
|
||||
}
|
||||
else if (thetype == MoniTool_ValueEnum) {
|
||||
Standard_Integer ival = EnumCase(val);
|
||||
Standard_CString cval = EnumVal(ival);
|
||||
if (!cval || cval[0] == '\0') return Standard_False;
|
||||
theival = ival;
|
||||
thehval->Clear();
|
||||
thehval->AssignCat(cval);
|
||||
} else {
|
||||
thehval->Clear();
|
||||
thehval->AssignCat(val);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::SetHStringValue
|
||||
(const Handle(TCollection_HAsciiString)& hval)
|
||||
{
|
||||
if (hval.IsNull()) return Standard_False;
|
||||
if (!Satisfies(hval)) return Standard_False;
|
||||
thehval = hval;
|
||||
if (thetype == MoniTool_ValueInteger) theival = atoi(hval->ToCString());
|
||||
else if (thetype == MoniTool_ValueEnum) theival = EnumCase(hval->ToCString());
|
||||
// else return Standard_True;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Integer MoniTool_TypedValue::IntegerValue () const
|
||||
{ return theival; }
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::SetIntegerValue
|
||||
(const Standard_Integer ival)
|
||||
{
|
||||
Handle(TCollection_HAsciiString) hval = new TCollection_HAsciiString(ival);
|
||||
if (hval->IsSameString (thehval)) return Standard_True;
|
||||
if (!Satisfies(hval)) return Standard_False;
|
||||
thehval->Clear();
|
||||
if (thetype == MoniTool_ValueEnum) thehval->AssignCat (EnumVal(ival));
|
||||
else thehval->AssignCat (hval->ToCString());
|
||||
theival = ival;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Real MoniTool_TypedValue::RealValue () const
|
||||
{
|
||||
if (thehval->Length() == 0) return 0.0;
|
||||
if (!thehval->IsRealValue()) return 0.0;
|
||||
return thehval->RealValue();
|
||||
}
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::SetRealValue (const Standard_Real rval)
|
||||
{
|
||||
Handle(TCollection_HAsciiString) hval = new TCollection_HAsciiString(rval);
|
||||
if (hval->IsSameString (thehval)) return Standard_True;
|
||||
if (!Satisfies(hval)) return Standard_False;
|
||||
thehval->Clear(); thehval->AssignCat (hval->ToCString());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Handle(Standard_Transient) MoniTool_TypedValue::ObjectValue () const
|
||||
{ return theoval; }
|
||||
|
||||
void MoniTool_TypedValue::GetObjectValue (Handle(Standard_Transient)& val) const
|
||||
{ val = theoval; }
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::SetObjectValue
|
||||
(const Handle(Standard_Transient)& obj)
|
||||
{
|
||||
if (thetype != MoniTool_ValueIdent) return Standard_False;
|
||||
if (obj.IsNull()) { theoval.Nullify(); return Standard_True; }
|
||||
if (!theotyp.IsNull())
|
||||
if (!obj->IsKind(theotyp)) return Standard_False;
|
||||
theoval = obj;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
Standard_CString MoniTool_TypedValue::ObjectTypeName () const
|
||||
{
|
||||
if (theoval.IsNull()) return "";
|
||||
Handle(MoniTool_Element) elm = Handle(MoniTool_Element)::DownCast(theoval);
|
||||
if (!elm.IsNull()) return elm->ValueTypeName();
|
||||
return theoval->DynamicType()->Name();
|
||||
}
|
||||
|
||||
|
||||
// ######## LIBRARY ########
|
||||
|
||||
Standard_Boolean MoniTool_TypedValue::AddLib
|
||||
(const Handle(MoniTool_TypedValue)& tv, const Standard_CString defin)
|
||||
{
|
||||
if (tv.IsNull()) return Standard_False;
|
||||
if (defin[0] != '\0') tv->SetDefinition(defin);
|
||||
// else if (tv->Definition() == '\0') return Standard_False;
|
||||
libtv()->SetItem (tv->Name(),tv);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Handle(MoniTool_TypedValue) MoniTool_TypedValue::Lib
|
||||
(const Standard_CString defin)
|
||||
{
|
||||
Handle(MoniTool_TypedValue) val;
|
||||
if (!libtv()->GetItem (defin,val,Standard_False)) val.Nullify();
|
||||
return val;
|
||||
}
|
||||
|
||||
Handle(MoniTool_TypedValue) MoniTool_TypedValue::FromLib
|
||||
(const Standard_CString defin)
|
||||
{
|
||||
Handle(MoniTool_TypedValue) val = MoniTool_TypedValue::Lib(defin);
|
||||
if (!val.IsNull()) val = new MoniTool_TypedValue (val);
|
||||
return val;
|
||||
}
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) MoniTool_TypedValue::LibList ()
|
||||
{
|
||||
Handle(TColStd_HSequenceOfAsciiString) list = new TColStd_HSequenceOfAsciiString();
|
||||
if (libtv().IsNull()) return list;
|
||||
for (Dico_IteratorOfDictionaryOfTransient it(libtv()); it.More();it.Next()) {
|
||||
list->Append (it.Name());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Handle(Dico_DictionaryOfTransient) MoniTool_TypedValue::Stats ()
|
||||
{
|
||||
static Handle(Dico_DictionaryOfTransient) astats;
|
||||
if (astats.IsNull()) astats = new Dico_DictionaryOfTransient;
|
||||
return astats;
|
||||
}
|
||||
|
||||
Handle(MoniTool_TypedValue) MoniTool_TypedValue::StaticValue
|
||||
(const Standard_CString name)
|
||||
{
|
||||
Handle(MoniTool_TypedValue) result;
|
||||
if (!Stats()->GetItem(name,result)) result.Nullify();
|
||||
return result;
|
||||
}
|
21
src/MoniTool/MoniTool_ValueInterpret.cxx
Executable file
21
src/MoniTool/MoniTool_ValueInterpret.cxx
Executable file
@@ -0,0 +1,21 @@
|
||||
// File: MoniTool_ValueInterpret.cxx
|
||||
// Created: Mon Feb 28 18:59:29 2000
|
||||
// Author: data exchange team
|
||||
// <det@kinox>
|
||||
|
||||
|
||||
#include <MoniTool_ValueInterpret.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : MoniTool_ValueInterpret_Type_
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Standard_Type)& STANDARD_TYPE(MoniTool_ValueInterpret)
|
||||
{
|
||||
static Handle(Standard_Type) _aType =
|
||||
new Standard_Type("MoniTool_ValueInterpret", sizeof(MoniTool_ValueInterpret), 0, NULL);
|
||||
|
||||
return _aType;
|
||||
}
|
||||
|
20
src/MoniTool/MoniTool_ValueInterpret.hxx
Executable file
20
src/MoniTool/MoniTool_ValueInterpret.hxx
Executable file
@@ -0,0 +1,20 @@
|
||||
// File: MoniTool_ValueInterpret.hxx
|
||||
// Created: Mon Feb 28 18:58:03 2000
|
||||
// Author: data exchange team
|
||||
// <det@kinox>
|
||||
|
||||
|
||||
#ifndef MoniTool_ValueInterpret_HeaderFile
|
||||
#define MoniTool_ValueInterpret_HeaderFile
|
||||
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <Handle_MoniTool_TypedValue.hxx>
|
||||
|
||||
typedef Handle(TCollection_HAsciiString) (*MoniTool_ValueInterpret) (const Handle(MoniTool_TypedValue)& typval,
|
||||
const Handle(TCollection_HAsciiString)& val,
|
||||
const Standard_Boolean native);
|
||||
|
||||
Standard_EXPORT Handle(Standard_Type)& STANDARD_TYPE(MoniTool_ValueInterpret);
|
||||
|
||||
#endif
|
21
src/MoniTool/MoniTool_ValueSatisfies.cxx
Executable file
21
src/MoniTool/MoniTool_ValueSatisfies.cxx
Executable file
@@ -0,0 +1,21 @@
|
||||
// File: MoniTool_ValueSatisfies.cxx
|
||||
// Created: Mon Feb 28 18:28:47 2000
|
||||
// Author: data exchange team
|
||||
// <det@kinox>
|
||||
|
||||
|
||||
#include <MoniTool_ValueSatisfies.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : MoniTool_ValueSatisfies_Type_
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Standard_Type)& STANDARD_TYPE(MoniTool_ValueSatisfies)
|
||||
{
|
||||
static Handle(Standard_Type) _aType =
|
||||
new Standard_Type("MoniTool_ValueSatisfies", sizeof(MoniTool_ValueSatisfies), 0, NULL);
|
||||
|
||||
return _aType;
|
||||
}
|
||||
|
17
src/MoniTool/MoniTool_ValueSatisfies.hxx
Executable file
17
src/MoniTool/MoniTool_ValueSatisfies.hxx
Executable file
@@ -0,0 +1,17 @@
|
||||
// File: MoniTool_ValueSatisfies.hxx
|
||||
// Created: Mon Feb 28 18:26:00 2000
|
||||
// Author: data exchange team
|
||||
// <det@kinox>
|
||||
|
||||
|
||||
#ifndef MoniTool_ValueSatisfies_HeaderFile
|
||||
#define MoniTool_ValueSatisfies_HeaderFile
|
||||
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
|
||||
typedef Standard_Boolean (*MoniTool_ValueSatisfies) (const Handle(TCollection_HAsciiString)& val);
|
||||
|
||||
Standard_EXPORT Handle(Standard_Type)& STANDARD_TYPE(MoniTool_ValueSatisfies);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user