--- /dev/null
+WOKAPI_APICommand.hxx
+WOKAPI_Command_Factory.cxx
+WOKAPI_Command_Workshop.cxx
+WOKAPI_Command_Warehouse.cxx
+WOKAPI_Command_Parcel.cxx
+WOKAPI_Command_Workbench.cxx
+WOKAPI_Command_Unit.cxx
+WOKAPI_Command_TriggeredMake.cxx
--- /dev/null
+-- File: WOKAPI.cdl
+-- Created: Mon Jul 31 19:46:31 1995
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1995
+
+
+package WOKAPI
+
+ ---Purpose: proposes an API to WOK Facilities
+
+uses
+ WOKMake,
+ WOKernel,
+ WOKUtils,
+ WOKTools,
+ TCollection,
+ TColStd
+is
+
+ imported APICommand;
+ imported LocatorCommand;
+
+ enumeration StepType is Start, End, Only, None;
+ enumeration StepStatus is OutOfDate, UpToDate, NeverBuilt;
+ enumeration BuildStatus is Success, Failed;
+
+ class Entity;
+
+ class Session;
+ ---Purpose: Handles Session manipulation
+
+ class Factory;
+
+ class Warehouse;
+
+ class Parcel;
+
+ class Workshop;
+
+ class Workbench;
+
+ class Unit;
+
+ class File;
+ class Locator;
+
+ class Process;
+ class BuildProcess;
+ class MakeStep;
+
+ class MakeOption;
+
+ class Command;
+
+
+-- class UnitGraph;
+
+--- INSTANTIATIONS
+
+ class SequenceOfEntity
+ instantiates Sequence from TCollection ( Entity from WOKAPI );
+
+ class SequenceOfFactory
+ instantiates Sequence from TCollection ( Factory from WOKAPI );
+
+ class SequenceOfParcel
+ instantiates Sequence from TCollection ( Parcel from WOKAPI );
+
+ class SequenceOfWorkshop
+ instantiates Sequence from TCollection ( Workshop from WOKAPI );
+
+ class SequenceOfWorkbench
+ instantiates Sequence from TCollection ( Workbench from WOKAPI );
+
+ class SequenceOfUnit
+ instantiates Sequence from TCollection ( Unit from WOKAPI );
+
+ class SequenceOfMakeStep
+ instantiates Sequence from TCollection ( MakeStep from WOKAPI );
+
+ class SequenceOfFile
+ instantiates Sequence from TCollection ( File from WOKAPI );
+
+ class SequenceOfMakeOption
+ instantiates Sequence from TCollection ( MakeOption from WOKAPI );
+
+end WOKAPI;
+
--- /dev/null
+// File: WOKAPI_APICommand.hxx
+// Created: Mon Apr 1 17:16:48 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+#ifndef WOKAPI_APICommand_HeaderFile
+#define WOKAPI_APICommand_HeaderFile
+
+
+#include <WOKTools_ArgTable.hxx>
+#include <WOKTools_Return.hxx>
+
+#include <WOKAPI_Session.hxx>
+
+typedef Standard_Integer (*WOKAPI_APICommand) (const WOKAPI_Session&,
+ const Standard_Integer , const WOKTools_ArgTable& ,
+ WOKTools_Return &);
+
+#endif
+
--- /dev/null
+-- File: WOKAPI_BuildProcess.cdl
+-- Created: Fri Jun 13 11:18:45 1997
+-- Author: Jean GAUTIER
+-- <jga@hourax.paris1.matra-dtv.fr>
+---Copyright: Matra Datavision 1997
+
+
+class BuildProcess from WOKAPI
+
+ ---Purpose:
+
+uses
+ Step from WOKMake,
+ HSequenceOfStepOption from WOKMake,
+ BuildProcess from WOKMake,
+ BuildStatus from WOKAPI,
+ Workbench from WOKAPI,
+ SequenceOfUnit from WOKAPI,
+ Unit from WOKAPI,
+ SequenceOfMakeStep from WOKAPI,
+ HSequenceOfDefine from WOKTools,
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd,
+ SequenceOfHAsciiString from TColStd
+
+
+is
+
+ Create returns BuildProcess from WOKAPI;
+
+ Init(me:out; abench : Workbench from WOKAPI)
+ returns Boolean from Standard;
+
+ SetForceFlag(me:out; aflag : Boolean from Standard);
+
+ Add(me:out; adevunit : Unit from WOKAPI);
+ Add(me:out; units : SequenceOfUnit from WOKAPI);
+
+ SelectOnGroups(me:out; aunit : Unit from WOKAPI;
+ group : HAsciiString from TCollection;
+ selectflag : Boolean from Standard = Standard_True)
+ ---Purpose: Select agroup AND aunit for execution
+ -- all groups are selected if agroup is Null
+ -- all units are treated if aunit is invalid
+ -- returns number of selected steps
+
+ returns Integer from Standard;
+
+ SelectOnGroups(me:out; units : SequenceOfUnit from WOKAPI;
+ groups : SequenceOfHAsciiString from TColStd;
+ selectflag : Boolean from Standard = Standard_True)
+ ---Purpose: Select groups AND units for execution
+ -- all groups are selected if groups is Empty
+ -- all units are treated if units is Empty
+ -- returns number of selected steps
+ returns Integer from Standard;
+
+ SelectOnTypesAndGroups(me:out; unittypes : SequenceOfHAsciiString from TColStd;
+ groups : SequenceOfHAsciiString from TColStd;
+ selectflag : Boolean from Standard = Standard_True)
+ ---Purpose: Select groups AND units on their types for execution
+ -- all groups are selected if groups is Empty
+ -- all units are treated if unit types is Empty
+ -- returns number of selected steps
+ returns Integer from Standard;
+
+ SelectOnSteps(me:out; aunit : Unit from WOKAPI;
+ astart, aend : HAsciiString from TCollection;
+ selectflag : Boolean from Standard = Standard_True)
+ ---Purpose: Select steps within aunit for execution
+ -- select from begining if astart is Null
+ -- select until end if aend is Nul
+ -- returns number of selected steps
+
+ returns Integer from Standard;
+
+ SelectOnSteps(me:out; units : SequenceOfUnit from WOKAPI;
+ astart, aend : HAsciiString from TCollection;
+ selectflag : Boolean from Standard = Standard_True)
+ ---Purpose: Select steps within units for execution
+ -- select from begining if astart is Null
+ -- select until end if aend is Nul
+ -- returns number of selected steps
+ returns Integer from Standard;
+
+ SelectOnSteps(me:out; unittypes : SequenceOfHAsciiString from TColStd;
+ astart, aend : HAsciiString from TCollection;
+ selectflag : Boolean from Standard = Standard_True)
+ ---Purpose: Select steps within unit types for execution
+ -- select from begining if astart is Null
+ -- select until end if aend is Nul
+ -- returns number of selected steps
+ returns Integer from Standard;
+
+ SelectOnDefines(me:out; defines : HSequenceOfDefine from WOKTools)
+ ---Purpose: select steps on defines
+ -- defines are:
+ -- for units:
+ -- Units=Unit1,Unit2,...,UnitN
+ -- UnitTypes=UnitType1,UnitType2,...,UnitTypeN
+ -- XUnits=Unit1,Unit2,...,UnitN
+ -- XUnitTypes=UnitType1,UnitType2,...,UnitTypeN
+ -- for steps within units:
+ -- Groups=Group1,Group2,...GroupN
+ -- XGroups=Group1,Group2,...GroupN
+
+ returns Integer from Standard;
+
+ UnSelectAll(me:out)
+ ---Purpose: unselects all previously selected steps
+ -- returns number of unselected steps
+ returns Integer from Standard;
+
+
+ ApplyTargetsToSteps(me; astep : HAsciiString from TCollection;
+ targets : HSequenceOfHAsciiString from TColStd)
+ returns Integer from Standard;
+
+ SelectedStepsNumber(me)
+ returns Integer from Standard;
+
+ SelectedSteps(me; aseq : out SequenceOfMakeStep from WOKAPI);
+
+ UnitSteps(me; aunit : Unit from WOKAPI; aseq : out SequenceOfMakeStep from WOKAPI);
+
+ PrintBanner(me);
+
+ Execute(me:out; alogflag : Boolean from Standard = Standard_False)
+ returns BuildStatus from WOKAPI;
+
+
+ ------ BuildProcess PRIVATE methods
+
+ SelectStep(me:out; astep : Step from WOKMake;
+ selectflag : Boolean from Standard = Standard_True)
+ returns Integer from Standard
+ is private;
+
+
+fields
+
+ myinit : Boolean from Standard;
+ mybench : Workbench from WOKAPI;
+ myprocess : BuildProcess from WOKMake;
+ myforce : Boolean from Standard;
+ myselect : Integer from Standard;
+ myoptions : HSequenceOfStepOption from WOKMake;
+
+end BuildProcess;
--- /dev/null
+// File: WOKAPI_BuildProcess.cxx
+// Created: Fri Jun 13 11:28:53 1997
+// Author: Jean GAUTIER
+// <jga@hourax.paris1.matra-dtv.fr>
+
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Messages.hxx>
+#include <WOKTools_MapOfHAsciiString.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+
+#include <WOKUtils_Shell.hxx>
+#include <WOKUtils_ShellManager.hxx>
+
+#include <WOKernel_DevUnit.hxx>
+#include <WOKernel_Locator.hxx>
+#include <WOKernel_UnitGraph.hxx>
+#include <WOKernel_DBMSystem.hxx>
+#include <WOKernel_Station.hxx>
+#include <WOKernel_Session.hxx>
+
+
+#include <WOKMake_IndexedDataMapOfBuildProcessGroup.hxx>
+#include <WOKMake_DataMapIteratorOfDataMapOfHAsciiStringOfStep.hxx>
+#include <WOKMake_DataMapIteratorOfDataMapOfHAsciiStringOfSequenceOfHAsciiString.hxx>
+#include <WOKMake_BuildProcessGroup.hxx>
+#include <WOKMake_Step.hxx>
+#include <WOKMake_BuildProcessIterator.hxx>
+#include <WOKMake_HSequenceOfStepOption.hxx>
+
+#include <WOKAPI_MakeStep.hxx>
+#include <WOKAPI_SequenceOfMakeStep.hxx>
+#include <WOKAPI_Session.hxx>
+
+#include <WOKAPI_BuildProcess.ixx>
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : WOKAPI_BuildProcess
+//purpose :
+//=======================================================================
+WOKAPI_BuildProcess::WOKAPI_BuildProcess()
+: myinit(Standard_False), myselect(0)
+{
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Init
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_BuildProcess::Init(const WOKAPI_Workbench& abench)
+{
+
+ if(!abench.IsValid())
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Init"
+ << "Invalid workbench for build process init" << endm;
+ return myinit= Standard_False;
+ }
+
+ abench.Entity()->Open();
+
+ mybench = abench;
+
+ Handle(WOKernel_Locator) alocator = new WOKernel_Locator(Handle(WOKernel_Workbench)::DownCast(abench.Entity()));
+ Handle(WOKernel_UnitGraph) agraph = new WOKernel_UnitGraph(alocator);
+ Handle(WOKUtils_Shell) ashell = WOKUtils_ShellManager::GetShell();
+
+ myprocess = new WOKMake_BuildProcess(alocator, ashell, agraph);
+
+ return myinit = Standard_True;
+}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SetForceFlag
+//purpose :
+//=======================================================================
+void WOKAPI_BuildProcess::SetForceFlag(const Standard_Boolean aflag)
+{
+ if(myoptions.IsNull() && aflag)
+ {
+ myoptions = new WOKMake_HSequenceOfStepOption;
+ myoptions->Append(WOKMake_Force);
+ }
+ if(aflag)
+ {
+ for(Standard_Integer i=1; i<=myoptions->Length(); i++)
+ {
+ if(myoptions->Value(i) == WOKMake_Force) return;
+ }
+ myoptions->Append(WOKMake_Force);
+ return;
+ }
+ else if(!myoptions.IsNull())
+ {
+ for(Standard_Integer i=1; i<=myoptions->Length(); i++)
+ {
+ if(myoptions->Value(i) == WOKMake_Force)
+ {
+ myoptions->Remove(i);
+ }
+ }
+ }
+}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Add
+//purpose :
+//=======================================================================
+void WOKAPI_BuildProcess::Add(const WOKAPI_Unit& adevunit)
+{
+ if(!myinit)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Add"
+ << "Build process is not initialized" << endm;
+ return;
+ }
+
+
+ if(adevunit.IsValid())
+ {
+ adevunit.Entity()->Open();
+
+ Handle(WOKernel_Locator) locator = myprocess->Locator();
+ Handle(TCollection_HAsciiString) umakename = new TCollection_HAsciiString(adevunit.Name());
+ Handle(TCollection_HAsciiString) stepsname = new TCollection_HAsciiString(adevunit.Name());
+
+ umakename->AssignCat("_WOKUMake.edl");
+ stepsname->AssignCat("_WOKSteps.edl");
+
+ Handle(TCollection_HAsciiString) sourcetype = new TCollection_HAsciiString("source");
+
+ Handle(WOKernel_File) ancien = locator->Locate(adevunit.Name(), sourcetype, umakename);
+ Handle(WOKernel_File) nouveau = locator->Locate(adevunit.Name(), sourcetype, stepsname);
+
+ if(!ancien.IsNull() && nouveau.IsNull())
+ {
+ WarningMsg << "WOKAPI_BuildProcess::Add"
+ << "Unit " << adevunit.Name() << " contains a " << umakename << " file and no " << stepsname << endm;
+ }
+
+ if(!adevunit.CheckDirs())
+ {
+ WarningMsg << "WOKAPI_BuildProcess::Add"
+ << "Unit " << adevunit.Name() << " is missing directories : ignored" << endm;
+ }
+ else
+ myprocess->ComputeSteps(*((Handle(WOKernel_DevUnit) *) &(adevunit.Entity())));
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Add"
+ << "Development unit is invalid" << endm;
+ return;
+ }
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Add
+//purpose :
+//=======================================================================
+void WOKAPI_BuildProcess::Add(const WOKAPI_SequenceOfUnit& units)
+{
+ if(!myinit)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Add"
+ << "Build process is not initialized" << endm;
+ return;
+ }
+
+ for(Standard_Integer i=1; i<=units.Length(); i++)
+ {
+ Add( units.Value(i) );
+ }
+ return;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SelectStep
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::SelectStep(const Handle(WOKMake_Step)& astep,
+ const Standard_Boolean selectflag)
+{
+ Standard_Integer result = 0;
+ if(!astep.IsNull())
+ {
+ if(!selectflag && astep->IsToExecute()) {myselect--;result=-1;}
+ else {myselect++;result=1;}
+ if(selectflag) astep->DoExecute();
+ else astep->DontExecute();
+ astep->SetOptions(myoptions);
+ }
+ return result;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SelectOnGroups
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::SelectOnGroups(const WOKAPI_Unit& aunit,
+ const Handle(TCollection_HAsciiString)& agroup,
+ const Standard_Boolean selectflag)
+{
+ Standard_Integer nbselect = 0;
+ Handle(WOKMake_BuildProcessGroup) agrp;
+
+
+ if(!myinit)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Add"
+ << "Build process is not initialized" << endm;
+ return 0;
+ }
+
+ if(!myprocess->IsUnitInProcess(aunit.Name())) Add(aunit);
+
+ if(!agroup.IsNull())
+ {
+ agrp = myprocess->GetGroup(agroup);
+
+ Handle(WOKernel_Entity) anent = aunit.Entity();
+
+ const TColStd_SequenceOfHAsciiString& aseq = agrp->Steps();
+
+ for(Standard_Integer i=1; i<=aseq.Length(); i++)
+ {
+ const Handle(WOKMake_Step)& astep = myprocess->Find(aseq.Value(i));
+
+ if(!astep.IsNull())
+ {
+ if(!astep->IsHidden())
+ {
+ if(!aunit.IsValid())
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ else
+ {
+ if(astep->Unit()->Name()->IsSameString(anent->Name()))
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+
+ const WOKMake_IndexedDataMapOfBuildProcessGroup& groups = myprocess->Groups();
+ for(Standard_Integer j=1; j<=groups.Extent(); j++)
+ {
+ Handle(WOKMake_BuildProcessGroup) group = groups(j);
+
+ Handle(WOKernel_Entity) anent = aunit.Entity();
+
+ const TColStd_SequenceOfHAsciiString& aseq = group->Steps();
+
+ for(Standard_Integer i=1; i<=aseq.Length(); i++)
+ {
+ const Handle(WOKMake_Step)& astep = myprocess->Find(aseq.Value(i));
+ if(!astep.IsNull())
+ {
+ if(!astep->IsHidden())
+ {
+ if(!aunit.IsValid())
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ else
+ {
+ if(astep->Unit()->Name()->IsSameString(anent->Name()))
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return nbselect;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SelectOnGroups
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::SelectOnGroups(const WOKAPI_SequenceOfUnit& units,
+ const TColStd_SequenceOfHAsciiString& groups,
+ const Standard_Boolean selectflag)
+{
+ Standard_Integer nbselect = 0;
+ Handle(WOKMake_BuildProcessGroup) agrp;
+ WOKTools_MapOfHAsciiString amap;
+
+ if(!myinit)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Add"
+ << "Build process is not initialized" << endm;
+ return 0;
+ }
+
+ if(!units.IsEmpty())
+ {
+ for(Standard_Integer i=1; i<=units.Length(); i++)
+ {
+ const Handle(TCollection_HAsciiString)& aname = units.Value(i).Entity()->Name();
+
+ if(!myprocess->IsUnitInProcess(aname)) Add(units.Value(i));
+
+ if(!amap.Contains(aname))
+ {
+ amap.Add(aname);
+ }
+ }
+ }
+
+ if(!groups.IsEmpty())
+ {
+ for(Standard_Integer j=1; j<=groups.Length(); j++)
+ {
+ agrp = myprocess->GetGroup(groups.Value(j));
+
+ const TColStd_SequenceOfHAsciiString& aseq = agrp->Steps();
+
+ if (aseq.IsEmpty()) {
+ InfoMsg << "WOKAPI_BuildProcess::SelectOnGroups"
+ << "group " << groups.Value(j) << " is empty " << endm;
+ }
+ for(Standard_Integer i=1; i<=aseq.Length(); i++)
+ {
+ const Handle(WOKMake_Step)& astep = myprocess->Find(aseq.Value(i));
+
+ if(!astep.IsNull())
+ {
+ if(!astep->IsHidden())
+ {
+ if(units.IsEmpty())
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ else
+ {
+ if(amap.Contains(astep->Unit()->Name()))
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+
+ const WOKMake_IndexedDataMapOfBuildProcessGroup& groups = myprocess->Groups();
+ for(Standard_Integer j=1; j<=groups.Extent(); j++)
+ {
+ Handle(WOKMake_BuildProcessGroup) group = groups(j);
+
+ const TColStd_SequenceOfHAsciiString& aseq = group->Steps();
+
+ for(Standard_Integer i=1; i<=aseq.Length(); i++)
+ {
+ const Handle(WOKMake_Step)& astep = myprocess->Find(aseq.Value(i));
+ if(!astep.IsNull())
+ {
+ if(! astep->IsHidden() )
+ {
+ if(units.IsEmpty())
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ else
+ {
+ if(amap.Contains(astep->Unit()->Name()))
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return nbselect;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SelectOnGroups
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::SelectOnTypesAndGroups(const TColStd_SequenceOfHAsciiString& types,
+ const TColStd_SequenceOfHAsciiString& groups,
+ const Standard_Boolean selectflag)
+{
+ Standard_Integer nbselect = 0;
+ Handle(WOKMake_BuildProcessGroup) agrp;
+ WOKTools_MapOfHAsciiString amap;
+
+ if(!myinit)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Add"
+ << "Build process is not initialized" << endm;
+ return 0;
+ }
+
+ if(!types.IsEmpty())
+ {
+ for(Standard_Integer i=1; i<=types.Length(); i++)
+ {
+ const Handle(TCollection_HAsciiString)& atype = types.Value(i);
+
+ if(!amap.Contains(atype))
+ {
+ amap.Add(atype);
+ }
+ }
+ }
+
+ if(!groups.IsEmpty())
+ {
+ for(Standard_Integer j=1; j<=groups.Length(); j++)
+ {
+ agrp = myprocess->GetGroup(groups.Value(j));
+
+ const TColStd_SequenceOfHAsciiString& aseq = agrp->Steps();
+
+ for(Standard_Integer i=1; i<=aseq.Length(); i++)
+ {
+ const Handle(WOKMake_Step)& astep = myprocess->Find(aseq.Value(i));
+
+ if(!astep.IsNull())
+ {
+ if(!astep->IsHidden())
+ {
+ if(amap.IsEmpty())
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ else
+ {
+ if(amap.Contains(astep->Unit()->Type()))
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+
+ const WOKMake_IndexedDataMapOfBuildProcessGroup& groups = myprocess->Groups();
+ for(Standard_Integer j=1; j<=groups.Extent(); j++)
+ {
+ Handle(WOKMake_BuildProcessGroup) group = groups(j);
+
+ const TColStd_SequenceOfHAsciiString& aseq = group->Steps();
+
+ for(Standard_Integer i=1; i<=aseq.Length(); i++)
+ {
+ const Handle(WOKMake_Step)& astep = myprocess->Find(aseq.Value(i));
+ if(!astep.IsNull())
+ {
+ if(! astep->IsHidden() )
+ {
+ if(amap.IsEmpty())
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ else
+ {
+ if(amap.Contains(astep->Unit()->Type()))
+ {
+ nbselect += SelectStep(astep,selectflag);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return nbselect;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SelectOnSteps
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::SelectOnSteps(const WOKAPI_Unit& aunit,
+ const Handle(TCollection_HAsciiString)& astart,
+ const Handle(TCollection_HAsciiString)& aend,
+ const Standard_Boolean selectflag)
+{
+ Standard_Integer selected = 0;
+
+ if(!myinit)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Add"
+ << "Build process is not initialized" << endm;
+ return 0;
+ }
+
+ if(!myprocess->IsUnitInProcess(aunit.Name())) Add(aunit);
+
+ if(aunit.IsValid())
+ {
+ Standard_Boolean selecting = Standard_False;
+ Standard_Boolean endwasfound = Standard_False;
+
+ if(aend.IsNull()) endwasfound = Standard_True;
+ if(astart.IsNull()) selecting = Standard_True;
+
+ const TColStd_SequenceOfHAsciiString& steps = myprocess->GetUnitSteps(aunit.Name());
+
+ for(Standard_Integer i=1; i<=steps.Length(); i++)
+ {
+ Handle(WOKMake_Step) astep = myprocess->Find(steps.Value(i));
+ Standard_Boolean stepselected = Standard_False;
+
+ if(!selecting)
+ {
+ // pas de selection en cours : puis-je entrer en selection
+ if(!astart.IsNull())
+ {
+ if(astep->IsOrIsSubStepOf(astart))
+ {
+ if(astep->IsHidden())
+ {
+ if(astart->IsSameString(astep->Code()))
+ {
+ if(!stepselected) {selected += SelectStep(astep,selectflag);stepselected=Standard_True;}
+ selecting = Standard_True;
+ }
+ }
+ else
+ {
+ if(!stepselected) {selected += SelectStep(astep,selectflag);stepselected=Standard_True;}
+ selecting = Standard_True;
+ }
+ }
+ }
+ }
+ if(selecting)
+ {
+ // selection en cours
+ if(astep->IsHidden())
+ {
+ if(!astart.IsNull())
+ {
+ if(astart->IsSameString(astep->Code()))
+ {
+ if(!stepselected) {selected += SelectStep(astep,selectflag);stepselected=Standard_True;}
+ }
+ }
+ }
+ else
+ {
+ if(!stepselected) {selected += SelectStep(astep,selectflag);stepselected=Standard_True;}
+ }
+
+ if(!aend.IsNull())
+ {
+ if( aend->IsSameString(astep->Code()) && astep->IsHidden())
+ {
+ if(!stepselected) {SelectStep(astep,selectflag);stepselected=Standard_True;selected++;}
+ }
+
+ if(astep->IsOrIsSubStepOf(aend))
+ {
+ endwasfound = Standard_True;
+ }
+
+ if(i<steps.Length())
+ {
+ // je regarde si la suivante est encore a faire
+ Handle(WOKMake_Step) nextstep = myprocess->Find(steps.Value(i+1));
+
+ if(!nextstep->IsOrIsSubStepOf(aend) && astep->IsOrIsSubStepOf(aend))
+ {
+ selecting = Standard_False;
+ }
+ }
+ }
+ }
+ }
+ if(!endwasfound)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::SelectOnSteps"
+ << "Specified end step (" << aend << " was not found" << endm;
+ UnSelectAll();
+ return 0;
+ }
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::SelectOnSteps"
+ << "Unit is invalid" << endm;
+ return 0;
+ }
+
+ return selected;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SelectOnSteps
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::SelectOnSteps(const WOKAPI_SequenceOfUnit& units,
+ const Handle(TCollection_HAsciiString)& astart,
+ const Handle(TCollection_HAsciiString)& aend,
+ const Standard_Boolean selectflag)
+{
+ if(!myinit)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::Add"
+ << "Build process is not initialized" << endm;
+ return 0;
+ }
+
+ Standard_Integer selected = 0;
+
+ for(Standard_Integer i=1; i<=units.Length(); i++)
+ {
+ const WOKAPI_Unit& unit = units.Value(i);
+ if(!myprocess->IsUnitInProcess(unit.Name())) Add(unit);
+ selected += SelectOnSteps(unit, astart,aend,selectflag);
+ }
+
+ return selected;
+}
+
+//=======================================================================
+//function : SelectOnDefines
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::SelectOnDefines(const Handle(WOKTools_HSequenceOfDefine)& defines)
+{
+ if(!myinit)
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::SelectOnDefines"
+ << "Build process is not initialized" << endm;
+ return 0;
+ }
+
+ if(defines.IsNull()) return 0;
+ //if(defines->IsEmpty()) return 0;
+
+ UnSelectAll();
+ SetForceFlag(Standard_False);
+
+ for(Standard_Integer i=1; i<=defines->Length(); i++)
+ {
+ const WOKTools_Define& adefine = defines->Value(i);
+
+ if(!strcmp(adefine.Name()->ToCString(), "Force"))
+ {
+ if(!strcmp(adefine.Value()->ToCString(), "Yes"))
+ {
+ SetForceFlag(Standard_True);
+ }
+ else
+ {
+ SetForceFlag(Standard_False);
+ }
+ }
+ }
+
+ TColStd_SequenceOfHAsciiString groups;
+ TColStd_SequenceOfHAsciiString xgroups;
+
+ TColStd_SequenceOfHAsciiString types;
+ TColStd_SequenceOfHAsciiString xtypes;
+
+ WOKTools_MapOfHAsciiString amap;
+ WOKTools_MapOfHAsciiString axmap;
+
+ for( i=1; i<=defines->Length(); i++)
+ {
+ const WOKTools_Define& adefine = defines->Value(i);
+
+ if(!strcmp(adefine.Name()->ToCString(), "Groups"))
+ {
+ Standard_Integer j=1;
+ Handle(TCollection_HAsciiString) agroup = adefine.Value()->Token(" ", j);
+
+ while(!agroup->IsEmpty())
+ {
+ groups.Append(agroup);
+ j++;
+ agroup = adefine.Value()->Token(" ", j);
+ }
+ }
+ else if(!strcmp(adefine.Name()->ToCString(), "Units"))
+ {
+ Standard_Integer j=1;
+ Handle(TCollection_HAsciiString) aunit = adefine.Value()->Token(" ", j);
+
+ while(!aunit->IsEmpty())
+ {
+ if(!amap.Contains(aunit)) amap.Add(aunit);
+ j++;
+ aunit = adefine.Value()->Token(" ", j);
+ }
+ }
+ else if(!strcmp(adefine.Name()->ToCString(), "UnitTypes"))
+ {
+ Standard_Integer j=1;
+ Handle(TCollection_HAsciiString) atype = adefine.Value()->Token(" ", j);
+
+ while(!atype->IsEmpty())
+ {
+ types.Append(atype);
+ j++;
+ atype = adefine.Value()->Token(" ", j);
+ }
+ }
+ else if(!strcmp(adefine.Name()->ToCString(), "XGroups"))
+ {
+ Standard_Integer j=1;
+ Handle(TCollection_HAsciiString) agroup = adefine.Value()->Token(" ", j);
+
+ while(!agroup->IsEmpty())
+ {
+ xgroups.Append(agroup);
+ j++;
+ agroup = adefine.Value()->Token(" ", j);
+ }
+ }
+ else if(!strcmp(adefine.Name()->ToCString(), "XUnits"))
+ {
+ Standard_Integer j=1;
+ Handle(TCollection_HAsciiString) aunit = adefine.Value()->Token(" ", j);
+
+ while(!aunit->IsEmpty())
+ {
+ if(!axmap.Contains(aunit)) axmap.Add(aunit);
+ j++;
+ aunit = adefine.Value()->Token(" ", j);
+ }
+ }
+ else if(!strcmp(adefine.Name()->ToCString(), "XUnitTypes"))
+ {
+ Standard_Integer j=1;
+ Handle(TCollection_HAsciiString) atype = adefine.Value()->Token(" ", j);
+
+ while(!atype->IsEmpty())
+ {
+ xtypes.Append(atype);
+ j++;
+ atype = adefine.Value()->Token(" ", j);
+ }
+ }
+ }
+
+ WOKAPI_SequenceOfUnit units;
+ WOKAPI_SequenceOfUnit xunits;
+
+ if(!(amap.IsEmpty() || axmap.IsEmpty()) && !(types.IsEmpty() || xtypes.IsEmpty()))
+ {
+ ErrorMsg << "WOKAPI_BuildProcess::SelectOnDefines"
+ << "Cannot use Units or XUnits in conjunction with UnitTypes or XUnitTypes" << endm;
+ return 0;
+ }
+
+
+ if(amap.IsEmpty())
+ {
+ if(!types.IsEmpty())
+ {
+ WOKTools_MapOfHAsciiString typemap;
+
+ for(Standard_Integer i=1; i<=types.Length(); i++)
+ {
+ const Handle(TCollection_HAsciiString)& atype = types.Value(i);
+ if(!typemap.Contains(atype)) typemap.Add(atype);
+ }
+
+ WOKAPI_SequenceOfUnit wbunits;
+ mybench.Units(wbunits);
+
+ for(i=1; i<=wbunits.Length(); i++)
+ {
+ const WOKAPI_Unit& aunit = wbunits.Value(i);
+ const Handle(TCollection_HAsciiString)& atype = aunit.Type();
+
+ if(typemap.Contains(atype)) units.Append(aunit);
+ }
+ }
+ else if(!xtypes.IsEmpty())
+ {
+ WOKTools_MapOfHAsciiString typemap;
+
+ for(Standard_Integer i=1; i<=types.Length(); i++)
+ {
+ const Handle(TCollection_HAsciiString)& atype = types.Value(i);
+ if(!typemap.Contains(atype)) typemap.Add(atype);
+ }
+
+ WOKAPI_SequenceOfUnit wbunits;
+ mybench.Units(wbunits);
+ for(i=1; i<=wbunits.Length(); i++)
+ {
+ const WOKAPI_Unit& aunit = wbunits.Value(i);
+ const Handle(TCollection_HAsciiString)& atype = aunit.Type();
+
+ if(!typemap.Contains(atype)) units.Append(aunit);
+ }
+ }
+ else
+ mybench.Units(units);
+ }
+ else
+ {
+ WOKAPI_SequenceOfUnit wbunits;
+ mybench.Units(wbunits);
+ for(Standard_Integer i=1; i<=wbunits.Length(); i++)
+ {
+ const WOKAPI_Unit& aunit = wbunits.Value(i);
+ const Handle(TCollection_HAsciiString)& aname = aunit.Name();
+
+ if(amap.Contains(aname)) units.Append(aunit);
+ }
+ }
+
+ if(!axmap.IsEmpty())
+ {
+ WOKAPI_SequenceOfUnit wbunits;
+ mybench.Units(wbunits);
+
+ for(Standard_Integer i=1; i<=wbunits.Length(); i++)
+ {
+ const WOKAPI_Unit& aunit = wbunits.Value(i);
+ const Handle(TCollection_HAsciiString)& aname = aunit.Name();
+
+ if(axmap.Contains(aname)) xunits.Append(aunit);
+ }
+ }
+
+ Add(units);
+
+ if(groups.IsEmpty())
+ {
+ Standard_Integer j=1;
+
+ Handle(TCollection_HAsciiString) defaults = mybench.ParameterEval(new TCollection_HAsciiString("%WOKSteps_DefaultGroups"));
+
+ if(defaults.IsNull())
+ {
+ defaults = mybench.ParameterEval(new TCollection_HAsciiString("%WOKSteps_Groups"));
+ }
+
+ if(!defaults.IsNull())
+ {
+ Handle(TCollection_HAsciiString) agroup = defaults->Token(" ", j);
+
+ while(!agroup->IsEmpty())
+ {
+ groups.Append(agroup);
+ j++;
+ agroup = defaults->Token(" ", j);
+ }
+ }
+ }
+
+ Standard_Integer nbsteps = SelectOnGroups(units,groups);
+
+ if(!xunits.IsEmpty())
+ {
+ nbsteps -= SelectOnGroups(xunits,groups,Standard_False);
+ }
+ if(!xgroups.IsEmpty())
+ {
+ nbsteps -= SelectOnGroups(units,xgroups,Standard_False);
+ }
+
+ return nbsteps;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : UnSelectAll
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::UnSelectAll()
+{
+ Standard_Integer unselected = 0;
+
+ WOKMake_DataMapIteratorOfDataMapOfHAsciiStringOfStep anit(myprocess->Steps());
+
+ while(anit.More())
+ {
+ if(anit.Value()->IsToExecute())
+ {
+ unselected ++;
+ anit.Value()->DontExecute();
+ }
+ anit.Next();
+ }
+ myselect = 0;
+ return unselected;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : ApplyTargetsToSteps
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::ApplyTargetsToSteps(const Handle(TCollection_HAsciiString)& step,
+ const Handle(TColStd_HSequenceOfHAsciiString)& targets) const
+{
+ Standard_Integer targetted = 0;
+
+ WOKMake_DataMapIteratorOfDataMapOfHAsciiStringOfStep anit(myprocess->Steps());
+
+ while(anit.More())
+ {
+ const Handle(WOKMake_Step) astep = anit.Value();
+ if(astep->IsToExecute() && astep->IsOrIsSubStepOf(step))
+ {
+ targetted ++;
+ astep->SetTargets(targets);
+ }
+ anit.Next();
+ }
+ return targetted;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SelectedStepsNumber
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_BuildProcess::SelectedStepsNumber() const
+{
+ return myselect;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SelectedSteps
+//purpose :
+//=======================================================================
+void WOKAPI_BuildProcess::SelectedSteps(WOKAPI_SequenceOfMakeStep& aseq) const
+{
+ WOKMake_BuildProcessIterator anit(myprocess, Standard_False);
+ WOKAPI_MakeStep apistep;
+
+ while(anit.More())
+ {
+ const Handle(WOKMake_Step)& astep = anit.CurStep();
+
+ if(astep->IsToExecute())
+ {
+ apistep.Set(astep);
+ aseq.Append(apistep);
+ }
+ anit.Next();
+ }
+ return;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : UnitSteps
+//purpose :
+//=======================================================================
+void WOKAPI_BuildProcess::UnitSteps(const WOKAPI_Unit& aunit, WOKAPI_SequenceOfMakeStep& aseq) const
+{
+ const TColStd_SequenceOfHAsciiString& steps = myprocess->GetUnitSteps(aunit.Name());
+ WOKAPI_MakeStep apistep;
+
+ for(Standard_Integer i=1; i<=steps.Length(); i++)
+ {
+ const Handle(WOKMake_Step) astep = myprocess->Find(steps.Value(i));
+ apistep.Set(astep);
+ aseq.Append(apistep);
+ }
+ return;
+}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : PrintBanner
+//purpose :
+//=======================================================================
+void WOKAPI_BuildProcess::PrintBanner() const
+{
+ static Standard_Integer WIDTH = 80;
+ static Handle(TCollection_HAsciiString) TIRETS = new TCollection_HAsciiString(WIDTH, '-');
+ if(!mybench.IsValid()) return;
+
+ Handle(WOKernel_Session) asession = mybench.Entity()->Session();
+
+ if(asession.IsNull()) return;
+
+ InfoMsg.DontPrintHeader();
+
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner" << endm;
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner" << endm;
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << TIRETS << endm;
+
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Workbench : " << mybench.UserPath() << endm;
+
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Extraction mode : " << WOKernel_DBMSystem::GetName(asession->DBMSystem()) << endm;
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Station : " << WOKernel_Station::GetName(asession->Station()) << endm;
+
+ if(asession->DebugMode())
+ {
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Compile mode : Debug" << endm;
+ }
+ else
+ {
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Compile mode : Optimized" << endm;
+ }
+
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Step number : " << myselect << endm;
+
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << TIRETS << endm;
+
+ const WOKMake_DataMapOfHAsciiStringOfSequenceOfHAsciiString& units = myprocess->Units();
+ WOKMake_DataMapIteratorOfDataMapOfHAsciiStringOfSequenceOfHAsciiString anit(units);
+ WOKAPI_Unit aunit;
+
+ while(anit.More())
+ {
+ aunit.Set(myprocess->Locator()->LocateDevUnit(anit.Key()));
+
+ if(aunit.IsValid())
+ {
+ const TColStd_SequenceOfHAsciiString& steps = anit.Value();
+ TColStd_SequenceOfHAsciiString codes;
+
+ static Standard_Integer DEBUT = strlen("Step : ");
+
+ Standard_Integer len = DEBUT;
+
+ for(Standard_Integer i=1; i<=steps.Length(); i++)
+ {
+ const Handle(WOKMake_Step)& astep = myprocess->Find(steps.Value(i));
+ if(astep->IsToExecute())
+ {
+ codes.Append(astep->Code());
+ }
+ }
+
+ if(codes.Length())
+ {
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Unit : " << aunit.Type() << " " << aunit.Name() << endm;
+
+ if(codes.Length() > 1)
+ {
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Steps : " ;
+ }
+ else
+ {
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << "Step : " ;
+ }
+
+ for(Standard_Integer i=1; i<=codes.Length(); i++)
+ {
+ const Handle(TCollection_HAsciiString)& code = codes.Value(i);
+
+ len += code->Length() + 1;
+
+ if(len > WIDTH )
+ {
+ InfoMsg << endm;
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner" << " " ;
+ len = DEBUT;
+ }
+ InfoMsg << code << " ";
+ }
+
+ InfoMsg << endm;
+ InfoMsg << "WOKAPI_BuildProcess::PrintBanner"
+ << TIRETS << endm;
+ }
+ }
+ anit.Next();
+ }
+
+ InfoMsg.DoPrintHeader();
+ return;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Execute
+//purpose :
+//=======================================================================
+WOKAPI_BuildStatus WOKAPI_BuildProcess::Execute(const Standard_Boolean alogflag)
+{
+ WOKAPI_BuildStatus status = WOKAPI_Success;
+ WOKMake_BuildProcessIterator anit(myprocess, alogflag);
+
+ while(anit.More())
+ {
+ switch(anit.MakeStep())
+ {
+ case WOKMake_Uptodate:
+ case WOKMake_Success:
+ case WOKMake_Processed:
+ case WOKMake_Unprocessed:
+ break;
+ case WOKMake_Incomplete:
+ case WOKMake_Failed:
+ status = WOKAPI_Failed;
+ break;
+ }
+ anit.Next();
+ }
+
+ switch(anit.Terminate())
+ {
+ case WOKMake_Uptodate:
+ case WOKMake_Success:
+ case WOKMake_Processed:
+ case WOKMake_Unprocessed:
+ break;
+ case WOKMake_Incomplete:
+ case WOKMake_Failed:
+ status = WOKAPI_Failed;
+ break;
+ };
+
+ return status;
+}
+
+
+
--- /dev/null
+-- File: WOKAPI_Command.cdl
+-- Created: Wed Apr 3 16:05:14 1996
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1996
+
+
+class Command from WOKAPI
+
+ ---Purpose:
+
+uses
+
+ Session from WOKAPI,
+ Locator from WOKAPI,
+ ArgTable from WOKTools,
+ Return from WOKTools
+
+is
+
+
+ ---
+ -- SESSION COMMANDS
+ --
+
+ SessionInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Gives Information about Session
+ returns Integer from Standard;
+
+ MoveTo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: moves toward an entity
+ returns Integer from Standard;
+
+ EnvironmentMgr(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: moves toward an entity
+ returns Integer from Standard;
+
+ ProfileMgt(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Sets current DBMS System + Debug On/Off
+ returns Integer from Standard;
+
+ ---
+ -- GENERAL FEATURES
+ --
+
+ ParametersMgr(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose:
+ returns Integer from Standard;
+
+ EntityInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Info about entities
+ returns Integer from Standard;
+
+ EntityClose(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose:
+ returns Integer from Standard;
+
+ ---
+ -- FACTORY COMMANDS
+ --
+
+ FactoryCreate(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Creates a factory
+ returns Integer from Standard;
+
+ FactoryInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Gives Information about Factory
+ returns Integer from Standard;
+
+ FactoryDestroy(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Destroys a factory
+ returns Integer from Standard;
+
+ ---
+ -- WAREHOUSE COMMANDS
+ --
+
+ WarehouseCreate(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Creates a warehouse
+ returns Integer from Standard;
+
+ WarehouseInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Gives Information about Warehouse
+ returns Integer from Standard;
+
+ WarehouseDestroy(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Destroys a warehouse
+ returns Integer from Standard;
+
+ WarehouseDeclare(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Declares a parcel in a warehouse
+ returns Integer from Standard;
+
+ ---
+ -- PARCEL COMMANDS
+ --
+
+
+ ParcelInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Gives Information about parcel
+ returns Integer from Standard;
+
+
+ ---
+ -- WORKSHOP COMMANDS
+ --
+
+ WorkshopCreate(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: creates a workshop
+ returns Integer from Standard;
+
+ WorkshopInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Info about workshop
+ returns Integer from Standard;
+
+ WorkshopDestroy(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Destroys a workshop
+ returns Integer from Standard;
+
+ ---
+ -- WORKBENCH COMMANDS
+ --
+
+ WorkbenchCreate(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: creates a workbench
+ returns Integer from Standard;
+
+ WorkbenchInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: info about workbench
+ returns Integer from Standard;
+
+ WorkbenchMove(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: move workbench inheritence
+ returns Integer from Standard;
+
+ WorkbenchDestroy(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: destroys workbench
+ returns Integer from Standard;
+
+ WorkbenchProcess(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: processes a workbench
+ returns Integer from Standard;
+
+
+ ---
+ -- Locator commands
+ --
+
+ Locate(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Locates elements
+ returns Integer from Standard;
+
+
+ ---
+ -- UNIT COMMANDS
+ --
+
+ UnitCreate(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: creates a devunit
+ returns Integer from Standard;
+
+ UnitInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: info about devunit
+ returns Integer from Standard;
+
+ UnitMake(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: builds a devunit
+ returns Integer from Standard;
+
+ UnitMakeInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: builds a devunit
+ returns Integer from Standard;
+
+ UnitDestroy(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: destroys devunit
+ returns Integer from Standard;
+
+
+
+ ---
+ -- Triggered Steps related commands
+ --
+
+ AddInputFile(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: Adds a secondary Input File to step
+ returns Integer from Standard;
+
+ InputFileInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: gives info about an inputfile
+ returns Integer from Standard;
+
+ AddOutputFile(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: gives info about an inputfile
+ returns Integer from Standard;
+
+ OutputFileInfo(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: gives info about an inputfile
+ returns Integer from Standard;
+
+ AddExecDepItem(myclass; asession : Session from WOKAPI;
+ argc : Integer from Standard; argv : ArgTable from WOKTools;
+ retval : out Return from WOKTools)
+ ---Purpose: adds a dependence item to step
+ returns Integer from Standard;
+
+end Command;
--- /dev/null
+// File: WOKAPI_Command.cxx
+// Created: Wed Apr 3 18:02:42 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+#include <fstream.h>
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+#include <TColStd_HSequenceOfAsciiString.hxx>
+
+#include <OSD_Environment.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Messages.hxx>
+#include <WOKTools_MapOfHAsciiString.hxx>
+#include <WOKTools_EnvValue.hxx>
+#include <WOKTools_InterpFileValue.hxx>
+#include <WOKTools_ChDirValue.hxx>
+
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+#include <WOKUtils_Path.hxx>
+#include <WOKUtils_Trigger.hxx>
+#include <WOKUtils_Triggers.hxx>
+
+#include <WOKAPI_Session.hxx>
+#include <WOKAPI_SequenceOfFactory.hxx>
+#include <WOKAPI_Factory.hxx>
+#include <WOKAPI_Warehouse.hxx>
+#include <WOKAPI_Parcel.hxx>
+#include <WOKAPI_SequenceOfParcel.hxx>
+#include <WOKAPI_Workshop.hxx>
+#include <WOKAPI_Workbench.hxx>
+#include <WOKAPI_SequenceOfWorkbench.hxx>
+#include <WOKAPI_Unit.hxx>
+#include <WOKAPI_File.hxx>
+#include <WOKAPI_Locator.hxx>
+
+#include <WOKAPI_Command.ixx>
+
+//=======================================================================
+void WOKAPI_SessionInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << "-<option>\n";
+ cerr << endl;
+ cerr << " Options are :\n";
+ cerr << " -F : Factory list\n";
+ cerr << " -f : current factory\n";
+ cerr << " -s : current workshop\n";
+ cerr << " -w : current workbench\n";
+ cerr << " -u : current development unit\n";
+ cerr << endl;
+ return;
+}
+
+//=======================================================================
+//function : SessionInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::SessionInfo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ Handle(TCollection_HAsciiString) astr;
+ WOKTools_Options opts(argc, argv, "hFfswu", WOKAPI_SessionInfo_Usage, "hFfswu");
+ Standard_Boolean getfactories = Standard_False;
+ Standard_Boolean getfactory = Standard_False;
+ Standard_Boolean getshop = Standard_False;
+ Standard_Boolean getbench = Standard_False;
+ Standard_Boolean getunit = Standard_False;
+ Handle(TCollection_HAsciiString) ahpath;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'F':
+ getfactories = Standard_True;
+ break;
+ case 'f':
+ getfactory = Standard_True;
+ break;
+ case 's':
+ getshop = Standard_True;
+ break;
+ case 'w':
+ getbench = Standard_True;
+ break;
+ case 'u':
+ getunit = Standard_True;
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ default:
+ WOKAPI_SessionInfo_Usage(argv[0]);
+ return 1;
+ }
+
+ if(!asession.IsValid())
+ {
+ return 1;
+ }
+
+ Handle(TCollection_HAsciiString) nullhandle;
+
+ if(getfactories)
+ {
+ Standard_Integer i;
+ WOKAPI_SequenceOfFactory theseq;
+
+ asession.Factories(theseq);
+
+ for(i = 1 ; i <= theseq.Length() ; i++)
+ {
+ returns.AddStringValue(theseq.Value(i).Name());
+ }
+ return 0;
+ }
+ if(getfactory)
+ {
+ WOKAPI_Factory afact(asession,nullhandle);
+ if(afact.IsValid())
+ returns.AddStringValue(afact.Name());
+ return 0;
+ }
+ if(getshop)
+ {
+ WOKAPI_Workshop ashop(asession,nullhandle);
+ if(ashop.IsValid())
+ returns.AddStringValue(ashop.Name());
+ return 0;
+ }
+ if(getbench)
+ {
+ WOKAPI_Workbench abench(asession,nullhandle);
+ if(abench.IsValid())
+ returns.AddStringValue(abench.Name());
+ return 0;
+ }
+ if(getunit)
+ {
+ WOKAPI_Unit aunit(asession,nullhandle);
+ if(aunit.IsValid())
+ returns.AddStringValue(aunit.Name());
+ return 0;
+ }
+ return 0;
+}
+//=======================================================================
+void WOKAPI_MoveTo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [-P<param>] [-T t<ype>] [<apath>] " << endl;
+ cerr << " Options are :" << endl;
+ cerr << " -P : Move to directory pointed by %Entity_<param> parameter" << endl;
+ cerr << " -T : Move to directory pointed by <type> file type" << endl;
+ cerr << endl;
+ return;
+}
+
+//=======================================================================
+//function : MoveTo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::MoveTo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc,argv,"P:T:h", WOKAPI_MoveTo_Usage, "hPT");
+ Standard_Boolean gotoparam = Standard_False, gototype = Standard_False;
+ Standard_Boolean pwd = Standard_False;
+ Standard_Boolean move = Standard_False;
+ Handle(TCollection_HAsciiString) homedir;
+ Handle(TCollection_HAsciiString) GOTO, apath;
+ Handle(TCollection_HAsciiString) param, type;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'P':
+ param = opts.OptionArgument();
+ gotoparam = Standard_True;
+ break;
+ case 'T':
+ type = opts.OptionArgument();
+ gototype = Standard_True;
+ break;
+ default:
+ break;
+ }
+
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True)
+ return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ pwd = Standard_True;
+ break;
+ case 1:
+ move = Standard_True;
+ apath = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_MoveTo_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Entity anentity;
+
+ if(!asession.CWEntityName().IsNull())
+ {
+ if(!strcmp(asession.CWEntityName()->ToCString(), ":"))
+ anentity = asession;
+ else
+ anentity = asession.GetCWEntity();
+ }
+
+ if(move)
+ {
+ if(strcmp(apath->ToCString(), ":"))
+ {
+ anentity = WOKAPI_Entity(asession,apath,Standard_False);
+
+ if(!anentity.IsValid())
+ {
+ ErrorMsg << argv[0]
+ << "Could not move to entity : " << apath << endm;
+ return 1;
+ }
+
+ WOKAPI_Session* thesess = (WOKAPI_Session*)&asession;
+ thesess->SetCWEntity(anentity);
+ }
+ else
+ {
+ anentity = asession;
+ WOKAPI_Session* thesess = (WOKAPI_Session*)&asession;
+ thesess->SetCWEntity(anentity);
+
+ move = Standard_False;
+
+ }
+ pwd = Standard_True;
+ }
+
+ if(anentity.IsValid())
+ {
+ if(gotoparam == Standard_True)
+ {
+ homedir = anentity.ParameterEval(anentity.EntityParameterName(param));
+ }
+ else
+ {
+ if(gototype)
+ {
+ if(!anentity.IsSession())
+ {
+ homedir = anentity.GetFileTypeDirectory(type);
+ }
+ else
+ {
+ // Ignore movement!
+ homedir.Nullify();
+ }
+ }
+ else
+ {
+ if(move)
+ homedir = anentity.ParameterEval(anentity.EntityParameterName(new TCollection_HAsciiString("Home")));
+ }
+ }
+ if(!homedir.IsNull())
+ returns.AddChDir(homedir);
+ }
+
+ if(pwd)
+ {
+ anentity = asession.GetCWEntity();
+
+ if(anentity.IsValid())
+ {
+ if(anentity.IsSession())
+ {
+ returns.AddStringValue(":");
+ }
+ else
+ {
+ returns.AddStringValue(anentity.UserPath());
+ }
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_EnvironmentMgr_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -s -t [csh|emacs|tcl] -f <filename> [entity]" << endl;
+ cerr << endl;
+ cerr << " Options are :\n";
+ cerr << " -s : sets run environment for <entity>" << endl;
+ cerr << " -t : target interpretor format for env settings" << endl;
+ cerr << " -f : filename for interpretor script file for env settings" << endl;
+ cerr << endl;
+}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : EnvironmentMgr
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::EnvironmentMgr(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc,argv,"hsf:t:", WOKAPI_EnvironmentMgr_Usage, "hsf");
+ Handle(TCollection_HAsciiString) aname;
+ Handle(TCollection_HAsciiString) filename;
+ Handle(TCollection_HAsciiString) format;
+ Standard_Boolean set = Standard_False, file = Standard_False, target = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 's':
+ set = Standard_True;
+ break;
+ case 'f':
+ file = Standard_True;
+ filename = opts.OptionArgument();
+ break;
+ case 't':
+ target = Standard_True;
+ format = opts.OptionArgument();
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed()) return 1;
+
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ aname = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_EnvironmentMgr_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Entity theent(asession,aname);
+
+ if(!theent.IsValid())
+ {
+ ErrorMsg << argv[0] << "Could not determine entity to operate on." << endm;
+ return 1;
+ }
+
+ if(set)
+ {
+ return theent.GetEnvActions(asession, returns);
+ }
+ else
+ {
+ if(file || target)
+ {
+ if(filename.IsNull())
+ {
+ ErrorMsg << argv[0] << "Missing file name for test environnement settings" << endm;
+ return 1;
+ }
+ if(format.IsNull())
+ {
+ ErrorMsg << argv[0] << "Missing format for test environnement settings" << endm;
+ return 1;
+ }
+
+ WOKTools_Return actions;
+
+ if(theent.GetEnvActions(asession, actions))
+ {
+ ErrorMsg << argv[0]
+ << "Could not obtain informations for test environnement" << endm;
+ return 1;
+ }
+
+
+
+
+ {
+ ofstream stream(filename->ToCString());
+
+ if(!stream.good())
+ {
+ ErrorMsg << argv[0]
+ << "Could not open " << filename << " for writing" << endm;
+ return 1;
+ }
+
+ WOKTools_InterpFileType efmt = WOKTools_InterpFileValue::InterpType(format);
+ Handle(TCollection_HAsciiString) sfmt = WOKTools_InterpFileValue::InterpFormat(efmt);
+
+
+ for(Standard_Integer i=1; i<=actions.Length(); i++)
+ {
+ WOKUtils_Trigger trigger;
+ Handle(TCollection_HAsciiString) cmd;
+ Handle(WOKTools_ReturnValue) act = actions.Value(i);
+ Handle(TCollection_HAsciiString) fmt =
+ WOKTools_InterpFileValue::InterpFormat(WOKTools_InterpFileValue::InterpType(format));
+
+ switch(act->Type())
+ {
+ case WOKTools_Environment:
+ {
+ Handle(WOKTools_EnvValue) envval = Handle(WOKTools_EnvValue)::DownCast(act);
+
+ if(!envval.IsNull())
+ {
+ trigger("wok_setenv_cmd") << fmt << envval->Name() << envval->Value() << endt >> cmd;
+ }
+ }
+ break;
+ case WOKTools_ChDir:
+ {
+ Handle(WOKTools_ChDirValue) dirval = Handle(WOKTools_ChDirValue)::DownCast(act);
+
+ if(!dirval.IsNull())
+ {
+ trigger("wok_cd_cmd") << fmt << dirval->Path() << endt >> cmd;
+ }
+ }
+ break;
+ case WOKTools_InterpFile:
+ {
+ Handle(WOKTools_InterpFileValue) interpval =
+ Handle(WOKTools_InterpFileValue)::DownCast(act);
+
+ if(!interpval.IsNull())
+ {
+ if(efmt == interpval->InterpType())
+ {
+ trigger("wok_source_cmd") << fmt << interpval->File() << endt >> cmd;
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if(!cmd.IsNull())
+ {
+ stream << cmd->ToCString();
+ }
+
+ }
+ stream.close();
+ return 0;
+ }
+ }
+ }
+ return 0;
+}
+
+
+
+//=======================================================================
+void WOKAPI_ProfileMgt_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [-b|-m] [-D <adbms>] [-d|-o]" << endl;
+ cerr << endl;
+ cerr << " -s : returns current station type" << endl;
+ cerr << " -b : returns current DbMS system" << endl;
+ cerr << " -m : returns current compile mode" << endl;
+ cerr << endl;
+ cerr << " -B <adbms> = DFLT|OBJY|OBJS|O2" << endl;
+ cerr << " -S <astation> = sun|ao1|sil|hp|wnt|... (Warning use this option carefully)" << endl;
+ cerr << endl;
+ cerr << " -d : Set Debug Mode" << endl;
+ cerr << " -o : Set Optimized Mode" << endl;
+ cerr << endl;
+ cerr << " -v : displays current/changed profile" << endl;
+ cerr << " noargs displays current profile (as a message)" << endl;
+ cerr << endl;
+ return;
+}
+
+//=======================================================================
+//function : ProfileMgt
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::ProfileMgt(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc,argv,"hbsmS:B:dov", WOKAPI_ProfileMgt_Usage, "hbsm");
+ Handle(TCollection_HAsciiString) adbms, astation;
+ Standard_Boolean
+ getdbms = Standard_False,
+ getstation = Standard_False,
+ getmode = Standard_False,
+ setdbms = Standard_False,
+ setstation = Standard_False,
+ setdebug = Standard_False,
+ setoptim = Standard_False,
+ getprof = Standard_False;
+
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'b':
+ getdbms = Standard_True;
+ break;
+ case 's':
+ getstation = Standard_True;
+ break;
+ case 'm':
+ getmode = Standard_True;
+ break;
+ case 'B':
+ setdbms = Standard_True;
+ adbms = opts.OptionArgument();
+ break;
+ case 'S':
+ setstation = Standard_True;
+ astation = opts.OptionArgument();
+ break;
+ case 'd':
+ setdebug = Standard_True;
+ break;
+ case 'o':
+ setoptim = Standard_True;
+ break;
+ case 'v':
+ getprof = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed()) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ if(!(getdbms||getstation||getmode||setdbms||setstation||setdebug||setoptim) )
+ getprof = Standard_True;
+ break;
+ default:
+ WOKAPI_ProfileMgt_Usage(argv[0]);
+ return 1;
+ }
+
+ if(getdbms)
+ {
+ returns.AddStringValue(asession.DBMSystem());
+ return 0;
+ }
+ if(getstation)
+ {
+ returns.AddStringValue(asession.Station());
+ return 0;
+ }
+ if(getmode)
+ {
+ if(asession.DebugMode())
+ {
+ returns.AddStringValue("Debug");
+ }
+ else
+ {
+ returns.AddStringValue("Optimized");
+ }
+ return 0;
+ }
+ if(setdbms)
+ {
+ WOKAPI_Session sess = asession;
+ if(sess.SetDBMSystem(adbms)) return 1;
+ }
+ if(setstation)
+ {
+ WOKAPI_Session sess = asession;
+ if(sess.SetStation(astation)) return 1;
+ }
+ if(setdebug)
+ {
+ WOKAPI_Session sess = asession;
+ sess.SetDebugMode(Standard_True);
+ }
+ if(setoptim)
+ {
+ WOKAPI_Session sess = asession;
+ sess.SetDebugMode(Standard_False);
+ }
+
+ if(setstation)
+ {
+ WOKAPI_Session* sess = (WOKAPI_Session*)&asession;
+ sess->Close();
+ sess->Open(NULL,astation);
+ }
+
+ if(setdebug|setoptim|setdbms)
+ {
+ WOKAPI_Session* sess = (WOKAPI_Session*)&asession;
+ sess->Close();
+ sess->Open();
+ }
+
+ if(getprof)
+ {
+ InfoMsg << argv[0] << "Profile in : " << asession.GetCWEntity().UserPath() << endm;
+ InfoMsg << argv[0] << endm;
+ InfoMsg << argv[0] << "Extractor : " << asession.DBMSystem() << endm;
+ if(asession.DebugMode())
+ {
+ InfoMsg << argv[0] << "Compile Mode : Debug" << endm;
+ }
+ else
+ {
+ InfoMsg << argv[0] << "Compile Mode : Optimized" << endm;
+ }
+ InfoMsg << argv[0] << "Station Type : " << asession.Station() << endm;
+ return 0;
+ }
+ return 0;
+}
+//=======================================================================
+void WOKAPI_ParametersMgr_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [-s <Name>=<Value>|-u <Name>|-l <class>|-t <Name>|-L] [<name>]\n";
+ cerr << endl;
+ cerr << " -s <Name>=<Value> : sets variable <Name> to Value" << endl;
+ cerr << " -u <Name> : unsets variable <Name>" << endl;
+ cerr << " -l <class> : lists parameters concerning class (prefix) class" << endl;
+ cerr << " -t <Name> : tests if variable <Name> is setted" << endl;
+ cerr << " -v <Name> : get Name value" << endl;
+ cerr << " -e <Name> : eval Name" << endl;
+ cerr << " -a <Name> : get Name arguments" << endl;
+ cerr << " -L : gives the directory search list" << endl;
+ cerr << " -C : gives the subclasses list" << endl;
+ cerr << " -F <class> : gives the files paths used for class <class>" << endl;
+ cerr << " -S <afile> : searches file in directory search list" << endl;
+ cerr << endl;
+ cerr << " <name> is the path of entity you wish to operate on" << endl;
+ cerr << endl;
+}
+
+//=======================================================================
+//function : ParametersMgr
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::ParametersMgr(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc, argv, "hs:u:t:a:v:e:l:LS:F:C", WOKAPI_ParametersMgr_Usage, "hsultveLS:F:C");
+ Handle(TCollection_HAsciiString) aoptarg, aname;
+ Standard_Boolean set=Standard_False, unset=Standard_False, list=Standard_False, args = Standard_False,
+ test=Standard_False, eval=Standard_False, value=Standard_False, slist = Standard_False, sfile = Standard_False,
+ classes=Standard_False, files=Standard_False;
+ // Code of API for Parameters Management
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 's':
+ // Set Variable
+ set = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'u':
+ // Unset Variable
+ unset = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'l':
+ // List Variables
+ aoptarg = opts.OptionArgument();
+ list = Standard_True;
+ break;
+ case 't':
+ // Test Variable
+ test = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'e':
+ // eval Variable
+ eval = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'v':
+ // value of Variable
+ value = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'a':
+ // Arguments of parameter
+ args = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'L':
+ slist = Standard_True;
+ break;
+ case 'S':
+ sfile = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'F':
+ files = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'C':
+ classes=Standard_True;
+ break;
+ default:
+ return 1;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ aname = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_ParametersMgr_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Entity theent(asession,aname,Standard_False);
+
+ if(!theent.IsValid())
+ {
+ ErrorMsg << argv[0] << "Could not determine entity to operate on." << endm;
+ return 1;
+ }
+
+ if(set)
+ {
+ theent.ParameterSet(aoptarg->Token("=", 1), aoptarg->Token("=", 2));
+ }
+ if(unset)
+ {
+ theent.ParameterUnSet(aoptarg);
+ }
+ if(list)
+ {
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+ Standard_Integer i;
+
+ aseq = theent.ParameterClassValues(aoptarg);
+
+ for(i=1; i<=aseq->Length(); i++)
+ {
+ returns.AddStringParameter(aseq->Value(i).Name(), aseq->Value(i).Value());
+ }
+ }
+ if(test)
+ {
+ returns.AddBooleanValue(theent.IsParameterSet(aoptarg));
+ }
+ if(eval)
+ {
+ Handle(TCollection_HAsciiString) result;
+
+ result = theent.ParameterEval(aoptarg);
+
+ if(result.IsNull())
+ {
+ ErrorMsg << argv[0] << "Could not eval " << aoptarg << " in " << theent.UserPath() << endm;
+ return 1;
+ }
+
+ returns.AddStringValue(result);
+ }
+ if(value)
+ {
+
+ Handle(TCollection_HAsciiString) result;
+
+ result = theent.ParameterValue(aoptarg);
+
+ if(result.IsNull())
+ {
+ ErrorMsg << argv[0] << "No value for " << aoptarg << " in " << theent.UserPath() << endm;
+ return 1;
+ }
+
+ returns.AddStringValue(result);
+ }
+ if(args)
+ {
+ Handle(TColStd_HSequenceOfHAsciiString) aseq = theent.ParameterArguments(aoptarg);
+ Standard_Integer i;
+
+ for(i=1; i<=aseq->Length(); i++)
+ {
+ returns.AddStringValue(aseq->Value(i));
+ }
+ }
+ if(slist)
+ {
+ Handle(TColStd_HSequenceOfHAsciiString) aseq;
+ Standard_Integer i;
+
+ aseq = theent.ParameterSearchList();
+
+ for(i=1; i<=aseq->Length(); i++)
+ {
+ returns.AddStringValue(aseq->Value(i));
+ }
+ }
+ if(sfile)
+ {
+ Handle(TCollection_HAsciiString) afile = theent.FindParameterFile(aoptarg);
+
+ if(!afile.IsNull())
+ {
+ returns.AddStringValue(afile);
+ return 0;
+ }
+ else return 1;
+ }
+ if(classes)
+ {
+ Handle(TColStd_HSequenceOfHAsciiString) Classes = theent.ParameterClasses();
+
+ if(!Classes.IsNull())
+ {
+ for(Standard_Integer i=1; i<=Classes->Length(); i++)
+ {
+ returns.AddStringValue(Classes->Value(i));
+ }
+ }
+ }
+ if(files)
+ {
+ Handle(TColStd_HSequenceOfHAsciiString) files = theent.ParameterClassFiles(aoptarg);
+
+ if(!files.IsNull())
+ {
+ for(Standard_Integer i=1; i<=files->Length(); i++)
+ {
+ returns.AddStringValue(files->Value(i));
+ }
+ }
+ return 0;
+ }
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_EntityInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -[options] <WokPath>" << endl;
+ cerr << endl;
+ cerr << " -t : returns Entity Type" << endl;
+ cerr << " -T : list available types for entity" << endl;
+ cerr << " -d <type> : get type definition" << endl;
+ cerr << " -a <type> : get type arguments" << endl;
+ cerr << " -p <type:name> : get path (for a %File dependent type)" << endl;
+ cerr << " -p <type> : get path (for a non %File dependent type)" << endl;
+ cerr << " -n : get entity name" << endl;
+ cerr << " -N : get nesting path" << endl;
+ cerr << " -x : test if entity exists" << endl;
+ cerr << " -f : get factory from path" << endl;
+ cerr << " -W : get warehouse from path" << endl;
+ cerr << " -P : get parcel from path" << endl;
+ cerr << " -s : get workshop from path" << endl;
+ cerr << " -w : get workbench from path" << endl;
+ cerr << " -u : get dev.unit from path" << endl;
+ cerr << " -F : get entity files" << endl;
+ cerr << " -R : get entity directories" << endl;
+ cerr << endl;
+}
+
+//=======================================================================
+//function : EntityInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::EntityInfo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc, argv, "hxTtd:xa:p:nNfWPswuFR", WOKAPI_EntityInfo_Usage, "hTtdapnNxfWPswuFR");
+ Handle(TCollection_HAsciiString) aoptarg, aname;
+ Standard_Boolean
+ getenttype = Standard_False,
+ gettypes = Standard_False,
+ gettypedef = Standard_False,
+ gettypeargs = Standard_False,
+ getname = Standard_False,
+ getnesting = Standard_False,
+ getpath = Standard_False,
+ getfactory = Standard_False,
+ getwarehouse = Standard_False,
+ getparcel = Standard_False,
+ getworkshop = Standard_False,
+ getworkbench = Standard_False,
+ getdevunit = Standard_False,
+ entexists = Standard_False,
+ getfiles = Standard_False,
+ getdirs = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 't':
+ getenttype = Standard_True;
+ break;
+ case 'T':
+ gettypes = Standard_True;
+ break;
+ case 'd':
+ gettypedef = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'a':
+ gettypeargs = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'p':
+ getpath = Standard_True;
+ aoptarg = opts.OptionArgument();
+ break;
+ case 'n':
+ getname = Standard_True;
+ break;
+ case 'N':
+ getnesting = Standard_True;
+ break;
+ case 'x':
+ entexists = Standard_True;
+ break;
+ case 'f':
+ getfactory = Standard_True;
+ break;
+ case 'W':
+ getwarehouse = Standard_True;
+ break;
+ case 'P':
+ getparcel = Standard_True;
+ break;
+ case 's':
+ getworkshop = Standard_True;
+ break;
+ case 'w':
+ getworkbench = Standard_True;
+ break;
+ case 'u':
+ getdevunit = Standard_True;
+ break;
+ case 'F':
+ getfiles = Standard_True;
+ break;
+ case 'R':
+ getdirs = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ aname = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_EntityInfo_Usage(argv[0]);
+ return 1;
+ }
+
+ if(entexists)
+ {
+ if(asession.IsValidPath(aname))
+ returns.AddBooleanValue(Standard_True);
+ else
+ returns.AddBooleanValue(Standard_False);
+ return 0;
+ }
+
+ WOKAPI_Entity theent(asession,aname);
+
+ if(!theent.IsValid())
+ {
+ ErrorMsg << argv[0] << "Invalid Entity specification" << endm;
+ return 1;
+ }
+
+ if(getenttype)
+ {
+ returns.AddStringValue(theent.Code());
+ return 0;
+ }
+
+ if(gettypes)
+ {
+ Standard_Integer i;
+ TColStd_SequenceOfHAsciiString typeseq;
+
+ theent.FileTypes(typeseq);
+
+ for(i=1; i<=typeseq.Length(); i++)
+ {
+ returns.AddStringValue(typeseq.Value(i));
+ }
+
+ return 0;
+ }
+
+ if(gettypedef)
+ {
+ if(!theent.IsFileType(aoptarg))
+ {
+ ErrorMsg << argv[0] << aoptarg << " is not a valid type for entity : " << theent.UserPath() << endm;
+ return 1;
+ }
+ returns.AddStringValue(theent.GetFileTypeDefinition(aoptarg));
+ return 0;
+ }
+ if(gettypeargs)
+ {
+ if(!theent.IsFileType(aoptarg))
+ {
+ ErrorMsg << argv[0] << aoptarg << " is not a valid type for entity : " << theent.UserPath() << endm;
+ return 1;
+ }
+
+ TColStd_SequenceOfHAsciiString argseq;
+ Standard_Integer i;
+
+ theent.GetFileTypeArguments(aoptarg, argseq);
+
+ for(i=1; i<=argseq.Length(); i++)
+ {
+ returns.AddStringValue(argseq.Value(i));
+ }
+
+ return 0;
+ }
+ if(getpath)
+ {
+
+ Standard_Integer apos = aoptarg->Location(1, ':', 1, aoptarg->Length());
+
+ if(apos>1 && apos<aoptarg->Length())
+ {
+
+ Handle(TCollection_HAsciiString) type = aoptarg->SubString(1, apos-1);
+ Handle(TCollection_HAsciiString) name = aoptarg->SubString(apos+1, aoptarg->Length());
+
+ if(!theent.IsFileType(type))
+ {
+ ErrorMsg << argv[0] << aoptarg << " is not a valid type for entity : " << theent.UserPath() << endm;
+ return 1;
+ }
+
+ returns.AddStringValue(theent.GetFilePath(type, name));
+ }
+ else
+ {
+ if(!theent.IsFileType(aoptarg))
+ {
+ ErrorMsg << argv[0] << aoptarg << " is not a valid type for entity : " << theent.UserPath() << endm;
+ return 1;
+ }
+
+ if(theent.IsFileTypeFileDependent(aoptarg))
+ {
+ ErrorMsg << argv[0] << aoptarg << " is a FileDependant type for entity : " << theent.UserPath() << endm;
+ return 1;
+ }
+ returns.AddStringValue(theent.GetFilePath(aoptarg));
+ return 0;
+ }
+ return 0;
+ }
+ if(getname)
+ {
+ returns.AddStringValue(theent.Name());
+ return 0;
+ }
+
+ if(getnesting)
+ {
+ WOKAPI_Entity nesting = theent.NestingEntity();
+
+ if(!nesting.IsValid())
+ {
+ ErrorMsg << argv[0] << "Could not obtain nesting of " << theent.UserPath() << endm;
+ return 1;
+ }
+
+ Handle(TCollection_HAsciiString) result = nesting.UserPath();
+
+ if(result->IsEmpty())
+ {
+ static Handle(TCollection_HAsciiString) result = new TCollection_HAsciiString(":");
+ returns.AddStringValue(result);
+ }
+ else
+ {
+ returns.AddStringValue(result);
+ }
+
+ return 0;
+ }
+
+ if(getfiles)
+ {
+ TColStd_SequenceOfHAsciiString aseq;
+
+ theent.GetFiles(aseq);
+
+ for(Standard_Integer i=1; i<=aseq.Length(); i++)
+ {
+ returns.AddStringValue(aseq.Value(i));
+ }
+ return 0;
+ }
+ if(getdirs)
+ {
+ TColStd_SequenceOfHAsciiString aseq;
+
+ theent.GetDirs(aseq);
+
+ for(Standard_Integer i=1; i<=aseq.Length(); i++)
+ {
+ returns.AddStringValue(aseq.Value(i));
+ }
+ return 0;
+ }
+
+ if(getfactory || getwarehouse || getwarehouse || getparcel ||
+ getworkshop || getworkbench || getdevunit )
+ {
+ Handle(TCollection_HAsciiString) nullhandle;
+
+ if(getfactory)
+ {
+ WOKAPI_Factory fact(asession, aname, Standard_False, Standard_True);
+ if(fact.IsValid())
+ {
+ returns.AddStringValue(fact.UserPath());
+ }
+ }
+ if(getwarehouse)
+ {
+ WOKAPI_Warehouse ware(asession, aname, Standard_False, Standard_True);
+ if(ware.IsValid())
+ {
+ returns.AddStringValue(ware.UserPath());
+ }
+ }
+ if(getparcel)
+ {
+ WOKAPI_Parcel parcel(asession, aname, Standard_False, Standard_True);
+ if(parcel.IsValid())
+ {
+ returns.AddStringValue(parcel.UserPath());
+ }
+ }
+
+ if(getworkshop)
+ {
+ WOKAPI_Workshop shop(asession, aname, Standard_False, Standard_True);
+ if(shop.IsValid())
+ {
+ returns.AddStringValue(shop.UserPath());
+ }
+ }
+
+ if(getworkbench)
+ {
+ WOKAPI_Workbench bench(asession, aname, Standard_False, Standard_True);
+ if(bench.IsValid())
+ {
+ returns.AddStringValue(bench.UserPath());
+ }
+ }
+
+ if(getdevunit)
+ {
+ WOKAPI_Unit unit(asession, aname, Standard_False, Standard_True);
+ if(unit.IsValid())
+ {
+ returns.AddStringValue(unit.UserPath());
+ }
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_EntityClose_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -a [<apath>] " << endl;
+ cerr << endl;
+ cerr << " -a : Close all entities (Resets WOK) " << endl;
+ cerr << endl;
+}
+
+//=======================================================================
+//function : EntityClose
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::EntityClose(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc, argv, "ha", WOKAPI_EntityClose_Usage, "h");
+ Handle(TCollection_HAsciiString) aoptarg, aname;
+ Standard_Boolean all = Standard_False;
+
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'a':
+ all = Standard_True;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ WOKAPI_Session * modsess = (WOKAPI_Session *) &asession;
+ if(all) {modsess->Close();modsess->Open();return 0;}
+ else
+ {
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ aname = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_ParametersMgr_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Entity theent(asession,aname);
+
+ if(!theent.IsValid())
+ {
+ ErrorMsg << argv[0] << "Invalid Entity specification" << endm;
+ return 1;
+ }
+ theent.Close();
+ return 0;
+ }
+}
+
+
+//=======================================================================
+void WOKAPI_Locate_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -<options> [<Workbench>]" << endl;
+ cerr << endl;
+ cerr << " Options are : " << endl;
+ cerr << " -f <UD:type:File> : locates a file and gives its ID" << endl;
+ cerr << " -p <UD:type:File> : locates a file and gives its path" << endl;
+ cerr << " -u <Unit> : locates a dev unit" << endl;
+ cerr << " -V <UnitNesting> : Visibility Unit Nesting" << endl;
+ cerr << endl;
+}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Locate
+//purpose :
+//=======================================================================
+WOKAPI_Command::Locate(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc, argv, "hf:p:u:V:", WOKAPI_Locate_Usage, "hV");
+ Standard_Boolean
+ file = Standard_False,
+ path = Standard_False,
+ unit = Standard_False;
+ Handle(TCollection_HAsciiString) fileid, unitid, aname;
+ Handle(TColStd_HSequenceOfHAsciiString) visi;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'f':
+ file = Standard_True;
+ fileid = opts.OptionArgument();
+ break;
+ case 'p':
+ path = Standard_True;
+ fileid = opts.OptionArgument();
+ break;
+ case 'u':
+ unit = Standard_True;
+ unitid = opts.OptionArgument();
+ break;
+ case 'V':
+ if(visi.IsNull()) visi = new TColStd_HSequenceOfHAsciiString;
+ visi->Append(opts.OptionArgument());
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ aname = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_Locate_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Locator alocator;
+
+ if(visi.IsNull())
+ {
+ WOKAPI_Workbench bench(asession,aname);
+
+ if(!bench.IsValid())
+ {
+ ErrorMsg << argv[0]
+ << "Could not determine visibility : Specify workbench in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ alocator.Set(bench);
+ }
+ else
+ {
+ ErrorMsg << argv[0]
+ << "Option -V not yet implemented : use Workbench to determine visibility" << endm;
+ return 1;
+ }
+
+ if(alocator.IsValid())
+ {
+ if(file|path)
+ {
+ WOKAPI_File Thefile = alocator.Locate(fileid);
+
+ if(Thefile.IsValid())
+ {
+ if(path)
+ {
+ returns.AddStringValue(Thefile.Path());
+ }
+ else
+ {
+ returns.AddStringValue(Thefile.UserPath());
+ }
+ }
+ }
+ else if(unit)
+ {
+ WOKAPI_Unit Theunit = alocator.LocateUnit(unitid);
+ if(Theunit.IsValid()) returns.AddStringValue(Theunit.UserPath());
+ }
+ }
+ return 0;
+
+}
+
--- /dev/null
+// File: WOKAPI_Command_Factory.cxx
+// Created: Wed Oct 23 11:56:11 1996
+// Author: Jean GAUTIER
+// <jga@cobrax.paris1.matra-dtv.fr>
+
+
+
+#include <TCollection_AsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKAPI_Factory.hxx>
+#include <WOKAPI_SequenceOfWorkshop.hxx>
+#include <WOKAPI_Workshop.hxx>
+#include <WOKAPI_Warehouse.hxx>
+
+#include <WOKAPI_Command.jxx>
+
+
+//=======================================================================
+void WOKAPI_FactoryBuild_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << "-<options> -Dparameter=value,... -D... <name>\n" ;
+ cerr << endl;
+ cerr << " Options are : ";
+ cerr << " -P : propose default parameters value" << endl;
+ cerr << " -d : use default values for parameters (this is the default)" << endl;
+ cerr << " -n : don't use default values for parameters" << endl;
+ cerr << " -Dparam=Value : override default value for parameter %<FactoryName>_<param>" << endl;
+ return;
+}
+
+//=======================================================================
+//function : FactoryCreate
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::FactoryCreate(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ Standard_Integer i;
+ TCollection_AsciiString aname;
+ WOKTools_Options opts(argc, argv, "D:hdnP", WOKAPI_FactoryBuild_Usage);
+ Standard_Boolean querydefault = Standard_True;
+ Standard_Boolean proposedefault = Standard_False;
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+ Handle(TCollection_HAsciiString) path;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'd':
+ querydefault = Standard_True;
+ break;
+ case 'n':
+ querydefault = Standard_False;
+ break;
+ case 'P':
+ querydefault = Standard_True;
+ proposedefault = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ break;
+ default:
+ WOKAPI_FactoryBuild_Usage(argv[0]);
+ return 1;
+ }
+
+ Handle(TCollection_HAsciiString) name;
+ name = opts.Arguments()->Value(1);
+
+ WOKAPI_Factory afact;
+
+ if(proposedefault)
+ {
+ aseq = afact.BuildParameters(asession, name, opts.Defines(), querydefault);
+
+ for(i =1 ; i <= aseq->Length(); i++)
+ {
+ returns.AddStringParameter(aseq->Value(i).Name(), aseq->Value(i).Value());
+ }
+ }
+ else
+ {
+ return afact.Build(asession, name, opts.Defines(), querydefault);
+ }
+ return 0;
+}
+//=======================================================================
+void WOKAPI_FactoryInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << "[-s|-S|-W] [<name>]\n";
+ cerr << endl;
+ cerr << " Options are :\n";
+ cerr << " -s : Workshops in factory\n";
+ cerr << " -W : Warehouse name\n";
+}
+
+
+//=======================================================================
+//function : FactoryInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::FactoryInfo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ Handle(TCollection_HAsciiString) aname;
+ WOKTools_Options opts(argc, argv, "sSW", WOKAPI_FactoryInfo_Usage, "sSW");
+ Standard_Boolean getshops = Standard_False, getwarehouse = Standard_False;
+
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 's':
+ getshops = Standard_True;
+ break;
+ case 'W':
+ getwarehouse = Standard_True;
+ break;
+ default:
+ return 1;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ aname = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_FactoryInfo_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Factory afact(asession,aname);
+
+ if(!afact.IsValid())
+ {
+ ErrorMsg << argv[0]
+ << "Could not determine factory : Specify factory in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ if((!getshops) &&
+ (!getwarehouse) &&
+ (!opts.Arguments()->Length()))
+ {
+ returns.AddStringValue(afact.Name());
+ }
+ else
+ {
+ if(getshops)
+ {
+ Standard_Integer i;
+ WOKAPI_SequenceOfWorkshop aseq;
+
+ afact.Workshops(aseq);
+
+ for(i = 1 ; i <= aseq.Length() ; i++)
+ {
+ returns.AddStringValue(aseq.Value(i).Name());
+ }
+ }
+ if(getwarehouse)
+ {
+ returns.AddStringValue(afact.Warehouse().Name());
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_FactoryDestroy_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [-R] <name>\n";
+ cerr << endl;
+ cerr << " Options are : ";
+ cerr << " -R : Recursively remove Nestings\n";
+}
+
+
+//=======================================================================
+//function : FactoryDestroy
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::FactoryDestroy(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc, argv, "D:hdP", WOKAPI_FactoryDestroy_Usage);
+ Handle(TCollection_HAsciiString) name;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'R':
+ ErrorMsg << "WOKAPI_Command::FactoryDestroy" << "-R not yet implemented" << endm;
+ return 1;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_FactoryDestroy_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Factory afact(asession,name);
+
+ if(!afact.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::FactoryDestroy"
+ << "Could not determine factory : Specify factory in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ afact.Destroy();
+
+ return 0;
+}
--- /dev/null
+// File: WOKAPI_Command_Parcel.cxx
+// Created: Wed Oct 23 11:59:20 1996
+// Author: Jean GAUTIER
+// <jga@cobrax.paris1.matra-dtv.fr>
+
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKAPI_Parcel.hxx>
+#include <WOKAPI_Unit.hxx>
+#include <WOKAPI_SequenceOfUnit.hxx>
+
+#include <WOKAPI_Command.jxx>
+
+
+//=======================================================================
+void WOKAPI_ParcelInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [-d] [-l|-a]\n";
+ cerr << endl;
+ cerr << " Options are :\n";
+ cerr << " -d : delivery in parcel\n";
+ cerr << " -l : lists units in parcel\n";
+ cerr << " -a : lists units in parcel with their types\n";
+}
+
+//=======================================================================
+//function : ParcelInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::ParcelInfo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc, argv, "hdla", WOKAPI_ParcelInfo_Usage);
+ Handle(TCollection_HAsciiString) name;
+ Standard_Boolean getdelivery = Standard_False;
+ Standard_Boolean getunits = Standard_False;
+ Standard_Boolean gettypedunits = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'd':
+ getdelivery = Standard_True;
+ break;
+ case 'l':
+ getunits = Standard_True;
+ break;
+ case 'a':
+ gettypedunits = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ case 0:
+ break;
+ default:
+ WOKAPI_ParcelInfo_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Parcel aparcel(asession,name);
+
+ if(!aparcel.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::WarehouseInfo"
+ << "Could not determine Warehouse : Specify Warehouse in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ if(getdelivery)
+ {
+ WOKAPI_Unit aunit;
+
+ aparcel.Delivery(aunit);
+
+ if(aunit.IsValid())
+ {
+ returns.AddStringValue(aunit.Name());
+ return 0;
+ }
+ else
+ return 1;
+ }
+ if(getunits||gettypedunits)
+ {
+ WOKAPI_SequenceOfUnit aseq;
+ Standard_Integer i;
+
+ aparcel.Units(aseq);
+
+ if(getunits)
+ {
+ for(i=1;i<=aseq.Length(); i++)
+ {
+ returns.AddStringValue(aseq.Value(i).Name());
+ }
+ }
+ else
+ {
+ Handle(TCollection_HAsciiString) astr;
+
+ for(i=1;i<=aseq.Length(); i++)
+ {
+ astr = new TCollection_HAsciiString(aseq.Value(i).Type());
+ astr->AssignCat(" ");
+ astr->AssignCat(aseq.Value(i).Name());
+
+ returns.AddStringValue(astr);
+ }
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+// File: WOKAPI_Command_TriggeredMake.cxx
+// Created: Mon Nov 25 20:28:28 1996
+// Author: Jean GAUTIER
+// <jga@cobrax.paris1.matra-dtv.fr>
+
+
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_Path.hxx>
+
+#include <WOKBuilder_Entity.hxx>
+
+#include <WOKernel_Locator.hxx>
+#include <WOKernel_DevUnit.hxx>
+#include <WOKernel_File.hxx>
+
+#include <WOKMake_TriggerStep.hxx>
+#include <WOKMake_InputFile.hxx>
+#include <WOKMake_OutputFile.hxx>
+
+#include <WOKAPI_Command.jxx>
+
+void WOKAPI_AddInputFile_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <options> <InputFileID>" << endl;
+ cerr << " Options are :" << endl;
+ cerr << " -p <path> : the path for file" << endl;
+ cerr << " -L : input is locate able (default)" << endl;
+ cerr << " -N : !wok file (not locate able)" << endl;
+ cerr << " -P : physical file (on disk) (default)" << endl;
+ cerr << " -V : non physical file (i.e. MSEntity)" << endl;
+ cerr << " -S : <StepID>" << endl;
+
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : AddInputFile
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::AddInputFile(const WOKAPI_Session& ,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc,argv,"hp:LNFVS", WOKAPI_AddInputFile_Usage);
+
+ Handle(TCollection_HAsciiString) apath;
+ Standard_Boolean
+ locateable = Standard_True,
+ isphysical = Standard_True,
+ isstepid = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'p':
+ apath = opts.OptionArgument();
+ break;
+ case 'L':
+ locateable = Standard_True;
+ break;
+ case 'N':
+ locateable = Standard_False;
+ break;
+ case 'F':
+ isphysical = Standard_True;
+ break;
+ case 'V':
+ isphysical = Standard_False;
+ break;
+ case 'S':
+ isstepid = Standard_True;
+ isphysical = Standard_False;
+ locateable = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ Handle(TCollection_HAsciiString) anid;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ anid = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_AddInputFile_Usage(argv[0]);
+ return 1;
+ }
+
+ Handle(WOKMake_TriggerStep) thestep = WOKMake_TriggerStep::CurrentTriggerStep();
+
+ if(thestep.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "No Tiggered Step currently in run" << endm;
+ ErrorMsg << argv[0]
+ << argv[0] << " can only be called during a umake process" << endm;
+ return 1;
+ }
+
+ Handle(WOKernel_File) file;
+ Handle(WOKernel_Locator) locator = thestep->Locator();
+
+ if(isphysical && locateable)
+ {
+ file = locator->Locate(anid);
+
+ if(file.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "Cannot locate file (locateable and physical) : " << anid
+ << " while processing " << thestep->Unit()->UserPathName() << endm;
+ return 1;
+ }
+ }
+
+ Handle(WOKUtils_Path) thepath;
+
+ if(!apath.IsNull())
+ {
+ if(file.IsNull())
+ {
+ thepath = new WOKUtils_Path(apath);
+ }
+ else
+ {
+ WarningMsg << argv[0]
+ << "Ingnoring given path for locateable physical file" << endm;
+ }
+ }
+ else if(!file.IsNull())
+ {
+ thepath = file->Path();
+ }
+
+ Handle(WOKBuilder_Entity) anent;
+ Handle(WOKMake_InputFile) infile = new WOKMake_InputFile(anid, file, anent, thepath);
+
+ infile->SetDirectFlag(Standard_False);
+ infile->SetLocateFlag(locateable);
+ infile->SetPhysicFlag(isphysical);
+ infile->SetStepID(isstepid);
+
+ thestep->AddInputFile(infile);
+
+ return 0;
+}
+
+//=======================================================================
+
+void WOKAPI_InputFileInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <options> <InputFileID>" << endl;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : InputFileInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::InputFileInfo(const WOKAPI_Session& ,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc,argv,"Pph", WOKAPI_InputFileInfo_Usage);
+
+ Standard_Boolean
+ getpath = Standard_False,
+ isphysic = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'P':
+ isphysic = Standard_True;
+ break;
+ case 'p':
+ getpath = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ Handle(TCollection_HAsciiString) anid;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ anid = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_InputFileInfo_Usage(argv[0]);
+ return 1;
+ }
+
+
+ Handle(WOKMake_TriggerStep) thestep = WOKMake_TriggerStep::CurrentTriggerStep();
+
+ if(thestep.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "No Tiggered Step currently in run" << endm;
+ ErrorMsg << argv[0]
+ << argv[0] << " can only be called during a umake process" << endm;
+ return 1;
+ }
+
+ Handle(WOKMake_InputFile) infile = thestep->GetInputFile(anid);
+
+ if(infile.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << anid << " is not an input of step " << thestep->Code() << endm;
+ return 1;
+ }
+
+ if(isphysic)
+ {
+ if(infile->IsPhysic())
+ returns.AddBooleanValue(Standard_True);
+ else
+ returns.AddBooleanValue(Standard_False);
+ return 0;
+ }
+
+ if(getpath)
+ {
+ Handle(WOKUtils_Path) thepath = infile->BuilderEntity()->Path();
+ if(!thepath.IsNull())
+ {
+ returns.AddStringValue(thepath->Name());
+ return 0;
+ }
+ else
+ {
+ ErrorMsg << argv[0]
+ << "Cannot obtain path for ID : " << anid << endm;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_AddOutputFile_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <options> <OutputFileID>" << endl;
+ cerr << " Options are :" << endl;
+ cerr << " -p <path> : the path for file" << endl;
+ cerr << " -L : output is locate able (default)" << endl;
+ cerr << " -N : !wok file (not locate able)" << endl;
+ cerr << " -F : physical file (on disk) (default)" << endl;
+ cerr << " -V : non physical file (i.e. MSEntity)" << endl;
+ cerr << " -M : file is a member of unit (default)" << endl;
+ cerr << " -X : file is not a member of unit" << endl;
+ cerr << " -P : file is a production of step (default)" << endl;
+ cerr << " -R : step introduces a reference to file" << endl;
+ cerr << " -S : <StepID>" << endl;
+
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : AddOutputFile
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::AddOutputFile(const WOKAPI_Session& ,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc,argv,"hp:LNFVSMXPR", WOKAPI_AddOutputFile_Usage);
+
+ Handle(TCollection_HAsciiString) apath;
+ Standard_Boolean
+ locateable = Standard_True,
+ isphysical = Standard_True,
+ isproduction = Standard_True,
+ ismember = Standard_True,
+ isstepid = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'p':
+ apath = opts.OptionArgument();
+ break;
+ case 'L':
+ locateable = Standard_True;
+ break;
+ case 'N':
+ locateable = Standard_False;
+ break;
+ case 'F':
+ isphysical = Standard_True;
+ break;
+ case 'V':
+ isphysical = Standard_False;
+ break;
+ case 'M':
+ ismember = Standard_True;
+ break;
+ case 'X':
+ ismember = Standard_False;
+ break;
+ case 'P':
+ isproduction = Standard_True;
+ break;
+ case 'R':
+ isproduction = Standard_False;
+ break;
+ case 'S':
+ isstepid = Standard_True;
+ isphysical = Standard_False;
+ locateable = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ Handle(TCollection_HAsciiString) anid;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ anid = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_AddOutputFile_Usage(argv[0]);
+ return 1;
+ }
+
+ Handle(WOKMake_TriggerStep) thestep = WOKMake_TriggerStep::CurrentTriggerStep();
+
+ if(thestep.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "No Tiggered Step currently in run" << endm;
+ ErrorMsg << argv[0]
+ << argv[0] << " can only be called during a umake process" << endm;
+ return 1;
+ }
+
+ Handle(WOKernel_File) file;
+ Handle(WOKernel_Locator) locator = thestep->Locator();
+
+ if(isphysical && locateable)
+ {
+ file = locator->Locate(anid);
+
+ if(file.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "Cannot locate file (locateable and physical) : " << anid
+ << " while processing " << thestep->Unit()->UserPathName() << endm;
+ return 1;
+ }
+ }
+
+ Handle(WOKUtils_Path) thepath;
+
+ if(!apath.IsNull())
+ {
+ if(file.IsNull())
+ {
+ thepath = new WOKUtils_Path(apath);
+ }
+ else
+ {
+ WarningMsg << argv[0]
+ << "Ingnoring given path for locateable physical file" << endm;
+ }
+ }
+ else if(!file.IsNull())
+ {
+ thepath = file->Path();
+ }
+
+ Handle(WOKBuilder_Entity) anent;
+ Handle(WOKMake_OutputFile) outfile = new WOKMake_OutputFile(anid, file, anent, thepath);
+
+
+ outfile->SetLocateFlag(locateable);
+ outfile->SetPhysicFlag(isphysical);
+ outfile->SetStepID(isstepid);
+
+ if(isproduction)
+ outfile->SetProduction();
+ else
+ outfile->SetReference();
+
+ if(ismember)
+ outfile->SetMember();
+ else
+ outfile->SetExtern();
+
+ thestep->AddOutputFile(outfile);
+
+ return 0;
+}
+
+//=======================================================================
+
+void WOKAPI_OutputFileInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <options> <OutputFileID>" << endl;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : OutputFileInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::OutputFileInfo(const WOKAPI_Session& ,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc,argv,"Pph", WOKAPI_OutputFileInfo_Usage);
+
+ Standard_Boolean
+ getpath = Standard_False,
+ isphysic = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'P':
+ isphysic = Standard_True;
+ break;
+ case 'p':
+ getpath = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ Handle(TCollection_HAsciiString) anid;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ anid = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_OutputFileInfo_Usage(argv[0]);
+ return 1;
+ }
+
+
+ Handle(WOKMake_TriggerStep) thestep = WOKMake_TriggerStep::CurrentTriggerStep();
+
+ if(thestep.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "No Tiggered Step currently in run" << endm;
+ ErrorMsg << argv[0]
+ << argv[0] << " can only be called during a umake process" << endm;
+ return 1;
+ }
+
+ Handle(WOKMake_OutputFile) infile = thestep->GetOutputFile(anid);
+
+ if(infile.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << anid << " is not an Output of step " << thestep->Code() << endm;
+ return 1;
+ }
+
+ if(isphysic)
+ {
+ if(infile->IsPhysic())
+ returns.AddBooleanValue(Standard_True);
+ else
+ returns.AddBooleanValue(Standard_False);
+ return 0;
+ }
+
+ if(getpath)
+ {
+ Handle(WOKUtils_Path) thepath = infile->BuilderEntity()->Path();
+ if(!thepath.IsNull())
+ {
+ returns.AddStringValue(thepath->Name());
+ return 0;
+ }
+ else
+ {
+ ErrorMsg << argv[0]
+ << "Cannot obtain path for ID : " << anid << endm;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_AddExecDepItem_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <options> <InputFileID> <OutputFileID>" << endl;
+ cerr << " Options are :" << endl;
+ cerr << " -d : Add as a direct dependency (default)" << endl;
+ cerr << " -i : Add as an indirect dependency" << endl;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : AddExecDepItem
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::AddExecDepItem(const WOKAPI_Session& ,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc,argv,"hid", WOKAPI_AddExecDepItem_Usage, "id");
+
+ Handle(TCollection_HAsciiString) apath;
+ Standard_Boolean isdirect = Standard_True;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'd':
+ isdirect = Standard_True;
+ break;
+ case 'i':
+ isdirect = Standard_False;
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ Handle(TCollection_HAsciiString) inid;
+ Handle(TCollection_HAsciiString) outid;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 2:
+ inid = opts.Arguments()->Value(1);
+ outid = opts.Arguments()->Value(2);
+ break;
+ default:
+ WOKAPI_AddOutputFile_Usage(argv[0]);
+ return 1;
+ }
+
+ Handle(WOKMake_TriggerStep) thestep = WOKMake_TriggerStep::CurrentTriggerStep();
+
+ if(thestep.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "No Tiggered Step currently in run" << endm;
+ ErrorMsg << argv[0]
+ << argv[0] << " can only be called during a umake process" << endm;
+ return 1;
+ }
+
+
+ Handle(WOKMake_InputFile) infile = thestep->GetInputFile(inid);
+
+ if(infile.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "Input file ID : " << inid << " is not an input of this step" << endm;
+ return 1;
+ }
+
+ Handle(WOKMake_OutputFile) outfile = thestep->GetOutputFile(outid);
+
+ if(outfile.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "Output file ID : " << outid << " is not an output of this step" << endm;
+ return 1;
+ }
+
+ thestep->AddExecDepItem(infile, outfile, isdirect);
+
+ return 0;
+}
--- /dev/null
+// File: WOKAPI_Command_Unit.cxx
+// Created: Wed Oct 23 12:02:43 1996
+// Author: Jean GAUTIER
+// <jga@cobrax.paris1.matra-dtv.fr>
+
+
+
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+#include <WOKTools_DataMapIteratorOfDataMapOfHAsciiStringOfHSequenceOfHAsciiString.hxx>
+#include <WOKTools_DataMapOfHAsciiStringOfHSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKAPI_Workbench.hxx>
+#include <WOKAPI_Parcel.hxx>
+#include <WOKAPI_Unit.hxx>
+#include <WOKAPI_SequenceOfUnit.hxx>
+#include <WOKAPI_MakeStep.hxx>
+#include <WOKAPI_SequenceOfMakeStep.hxx>
+#include <WOKAPI_File.hxx>
+#include <WOKAPI_SequenceOfFile.hxx>
+#include <WOKAPI_Locator.hxx>
+#include <WOKAPI_BuildProcess.hxx>
+
+#include <WOKAPI_Command.jxx>
+
+#if defined( WNT ) && defined( _DEBUG )
+#include <OSD_Timer.hxx>
+extern "C" void _debug_break ( char* );
+#endif // WNT && _DEBUG
+
+//=======================================================================
+void WOKAPI_UnitBuild_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [-<typecode>|-T <TypeName>|-P] <name>" << endl;
+ cerr << endl;
+ cerr << " Options are :" << endl;
+ cerr << " -? : Type code for devunit (default is package if unit in other nesting cannot be found)" << endl;
+ cerr << " -P : " << cmd << " creation possibilities : <typecode> <typename>" << endl;
+ cerr << " -T <typename> : create with explicit type code" << endl;
+ cerr << endl;
+ return;
+}
+
+//=======================================================================
+//function : UnitCreate
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::UnitCreate(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+
+ // code of API for Workbench Creation
+ Handle(TCollection_HAsciiString) aname, unitname, benchname, typesstr;
+ WOKTools_Options opts(argc, argv, "hT:PabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", WOKAPI_UnitBuild_Usage,"hTPabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+ Standard_Character typecode = 0;
+ Standard_Boolean getpossibilities = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'T':
+ typesstr = opts.OptionArgument();
+ break;
+ case 'P':
+ getpossibilities = Standard_True;
+ break;
+ default:
+ typecode = opts.Option();
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ if(getpossibilities)
+ {
+ if(!opts.Arguments()->Length()) {
+ benchname = asession.CWEntityName();
+ }
+ else {
+ benchname = opts.Arguments()->Value(1);
+ }
+
+ WOKAPI_Workbench abench(asession,benchname,Standard_False);
+ TColStd_SequenceOfHAsciiString aseq;
+
+ abench.KnownTypeNames(aseq);
+ Handle(TCollection_HAsciiString) keys = abench.KnownTypeKeys();
+
+ for(Standard_Integer i=1; i <= aseq.Length(); i++)
+ {
+ Handle(TCollection_HAsciiString) astr = new TCollection_HAsciiString(keys->Value(i));
+
+ astr->AssignCat(" ");
+ astr->AssignCat(aseq.Value(i));
+
+ returns.AddStringValue(astr);
+ }
+ return 0;
+ }
+
+
+ if(opts.Arguments()->Length() != 1)
+ {
+ WOKAPI_UnitBuild_Usage(argv[0]);
+ return 1;
+ }
+
+
+ aname = opts.Arguments()->Value(1);
+ Standard_Integer i = aname->SearchFromEnd(":");
+
+ if(i != -1)
+ {
+ unitname = aname->SubString(i+1, aname->Length());
+ benchname = aname->SubString(1, i-1);
+ }
+ else
+ {
+ unitname = aname;
+ benchname = asession.CWEntityName();
+ }
+
+ if(typecode != 0 && !typesstr.IsNull())
+ {
+ ErrorMsg << argv[0]
+ << "Option -T cannot be used in conjunction with type key!" << endm;
+ return 1;
+ }
+
+ WOKAPI_Unit aunit;
+
+
+ // On verifie le type code
+ WOKAPI_Workbench abench(asession,benchname,Standard_False);
+
+ if(typecode == 0 && abench.IsValid() && !unitname.IsNull() && typesstr.IsNull())
+ {
+ WOKAPI_Locator alocator;
+
+ alocator.Set(abench);
+ WOKAPI_Unit aprev = alocator.LocateUnit(unitname);
+
+ if(aprev.IsValid())
+ {
+ typecode = aprev.TypeKey();
+ InfoMsg << argv[0]
+ << "No type specified : using type of " << aprev.UserPath() << " : " << aprev.Type() << " (eq : ucreate -" << typecode << ")" << endm;
+ }
+ else
+ {
+ InfoMsg << argv[0]
+ << "No type specified : using package (eq : ucreate -p)" << endm;
+ typecode = 'p';
+ }
+ }
+
+ if(!typesstr.IsNull())
+ {
+ TColStd_SequenceOfHAsciiString aseq;
+
+ abench.KnownTypeNames(aseq);
+ Handle(TCollection_HAsciiString) keys = abench.KnownTypeKeys();
+ Standard_Boolean found = Standard_False;
+
+ for(Standard_Integer i=1; i <= aseq.Length() && !found; i++)
+ {
+ if(typesstr->IsSameString(aseq.Value(i)))
+ {
+ found = Standard_True;
+ typecode = keys->Value(i);
+ }
+ }
+ if(!found)
+ {
+ ErrorMsg << argv[0]
+ << "Invalid type specification : " << typesstr << " (see ucreate -P for possibilities)" << endm;
+ return 1;
+ }
+ }
+
+ {
+ TColStd_SequenceOfHAsciiString aseq;
+
+ abench.KnownTypeNames(aseq);
+ Handle(TCollection_HAsciiString) keys = abench.KnownTypeKeys();
+
+ if(!keys.IsNull())
+ {
+ Standard_Boolean found = Standard_False;
+
+ for(Standard_Integer i=1; i <= aseq.Length() && !found; i++)
+ {
+ if(typecode == keys->Value(i))
+ {
+ InfoMsg << argv[0]
+ << "Creating " << aseq.Value(i) << " " << aname
+ << " in " << abench.UserPath() << endm;
+ found = Standard_True;
+ }
+ }
+ if(!found)
+ {
+ ErrorMsg << argv[0]
+ << "Invalid type key specified : " << typecode << endm;
+ return 1;
+ }
+ }
+ }
+
+ if(aunit.Build(asession, aname, typecode, opts.Defines(), Standard_False)) return 1;
+
+ return 0;
+}
+//=======================================================================
+void WOKAPI_UnitInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [-f|-p|-t|-c] [-m|-e] [-l] [-T <type>] [<name>]\n";
+ cerr << endl;
+ cerr << " Options are :\n";
+ cerr << " -f : list of file names\n";
+ cerr << " -F : list of file names with their types\n";
+ cerr << " -p : list of file pathes\n";
+ cerr << " -T : File Type filter\n";
+ cerr << " -i : File Type Station or DBMS independent filter\n";
+ cerr << " -s : File Type Station dependent filter\n";
+ cerr << " -b : File Type DBMS dependent filter\n";
+ cerr << " -B : File Type DBMS and Station (Both) dependent filter\n";
+ cerr << " -l : local file filter\n";
+ cerr << " -m : Only Missing files\n";
+ cerr << " -e : Only Existing files\n";
+ cerr << " -t : Unit Type\n";
+ cerr << " -c : Unit Type code\n";
+ cerr << endl;
+}
+
+//=======================================================================
+//function : UnitInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::UnitInfo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ Handle(TCollection_HAsciiString) aname, typefiltername;
+ WOKTools_Options opts(argc, argv, "hibsBfFptclT:me", WOKAPI_UnitInfo_Usage, "htcibsB");
+ Standard_Boolean getname = Standard_False;
+ Standard_Boolean getftype = Standard_False;
+ Standard_Boolean getpathes = Standard_False;
+ Standard_Boolean gettype = Standard_False;
+ Standard_Boolean gettypecode = Standard_False;
+ Standard_Boolean localfilter = Standard_False;
+ Standard_Boolean typefilter = Standard_False;
+ Standard_Boolean missingfilter = Standard_False;
+ Standard_Boolean existsfilter = Standard_False;
+ Standard_Boolean independant = Standard_False;
+ Standard_Boolean dbdependant = Standard_False;
+ Standard_Boolean stdependant = Standard_False;
+ Standard_Boolean bothdependant = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'i':
+ independant = Standard_True;
+ break;
+ case 's':
+ stdependant = Standard_True;
+ break;
+ case 'b':
+ dbdependant = Standard_True;
+ break;
+ case 'B':
+ bothdependant = Standard_True;
+ break;
+ case 'f':
+ getname = Standard_True;
+ break;
+ case 'F':
+ getname = Standard_True;
+ getftype = Standard_True;
+ break;
+ case 'p':
+ getpathes = Standard_True;
+ break;
+ case 't':
+ gettype = Standard_True;
+ break;
+ case 'c':
+ gettypecode = Standard_True;
+ break;
+ case 'l':
+ localfilter = Standard_True;
+ break;
+ case 'T':
+ typefilter = Standard_True;
+ typefiltername= opts.OptionArgument();
+ break;
+ case 'm':
+ missingfilter = Standard_True;
+ break;
+ case 'e':
+ existsfilter = Standard_True;
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed()) return 1;
+
+ if(missingfilter && localfilter)
+ {
+ ErrorMsg << argv[0] << "Mixing -l and -m is nonsense" << endm;
+ return 1;
+ }
+
+ if(missingfilter && existsfilter)
+ {
+ ErrorMsg << argv[0] << "Mixing -e and -m is nonsense" << endm;
+ return 1;
+ }
+
+ if(missingfilter && getpathes)
+ {
+ ErrorMsg << argv[0] << "Mixing -m and -p is nonsense" << endm;
+ return 1;
+ }
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ aname = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_UnitInfo_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Unit aunit(asession,aname,Standard_False);
+
+ if(!aunit.IsValid())
+ {
+ ErrorMsg << argv[0] << "Could not determine unit : Specify unit in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ if(getname||getftype||getpathes)
+ {
+ Standard_Integer i;
+ WOKAPI_SequenceOfFile fileseq;
+ WOKAPI_Locator locator;
+
+ WOKAPI_Entity nesting = aunit.NestingEntity();
+
+ if (nesting.IsWorkbench()) {
+
+ WOKAPI_Workbench abench(asession, nesting.UserPath());
+
+ if(!abench.IsValid())
+ {
+ ErrorMsg << argv[0] << "Could not determine workbench" << endm;
+ return 1;
+ }
+
+ locator.Set(abench);
+ }
+ else {
+ WOKAPI_Parcel aparcel(asession,nesting.UserPath());
+
+ if(!aparcel.IsValid())
+ {
+ ErrorMsg << argv[0] << "Could not determine parcel" << endm;
+ return 1;
+ }
+
+ Handle(TColStd_HSequenceOfHAsciiString) visib = new TColStd_HSequenceOfHAsciiString();
+ visib->Append(aparcel.UserPath());
+ locator.Set(asession,visib);
+ }
+
+ if(!locator.IsValid())
+ {
+ ErrorMsg << argv[0] << "Could not initialize locator with " << aunit.NestingEntity().UserPath() << endm;
+ return 1;
+ }
+
+ aunit.Files(locator,fileseq);
+
+ for(i=1; i<=fileseq.Length(); i++)
+ {
+ Standard_Boolean addfile = Standard_True;
+ WOKAPI_File& afile = fileseq.ChangeValue(i);
+
+ if(typefilter && addfile)
+ {
+ if(! afile.Type()->IsSameString(typefiltername)) addfile = Standard_False;
+ }
+ if(localfilter && addfile)
+ {
+ if(!afile.IsLocated()) afile.Locate(locator);
+ if(afile.IsLocated())
+ {if(! afile.IsLocalTo(aunit) ) addfile = Standard_False;}
+ else
+ {addfile = Standard_False;}
+ }
+ if(missingfilter && addfile)
+ {
+ if(!afile.IsLocated()) afile.Locate(locator);
+ if(afile.IsLocated()) addfile = Standard_False;
+ }
+ if(existsfilter && addfile)
+ {
+ if(!afile.IsLocated()) afile.Locate(locator);
+ if(!afile.IsLocated()) addfile = Standard_False;
+ }
+ if(independant && addfile)
+ {
+ if(afile.IsDBMSDependent() || afile.IsStationDependent()) addfile = Standard_False;
+ }
+ if(bothdependant && addfile)
+ {
+ if(!afile.IsDBMSDependent() || !afile.IsStationDependent()) addfile = Standard_False;
+ }
+ if(dbdependant && addfile)
+ {
+ if(!afile.IsDBMSDependent() || afile.IsStationDependent()) addfile = Standard_False;
+ }
+ if(stdependant && addfile)
+ {
+ if(!afile.IsStationDependent() || afile.IsDBMSDependent()) addfile = Standard_False;
+ }
+
+ if(addfile && afile.IsValid())
+ {
+ if( (getpathes && ( getname || getftype)) ||
+ (getname && ( getpathes || getftype)) ||
+ (getftype && ( getname || getpathes)) )
+ {
+ Handle(TCollection_HAsciiString) astr = new TCollection_HAsciiString;
+ if(getftype)
+ {
+ astr->AssignCat(afile.Type());
+ astr->AssignCat(" ");
+ }
+ if(getname)
+ {
+ astr->AssignCat(afile.Name());
+ astr->AssignCat(" ");
+ }
+ if(getpathes)
+ {
+ if(!afile.IsLocated()) afile.Locate(locator);
+ if(afile.IsLocated())
+ astr->AssignCat(afile.Path());
+ }
+ returns.AddStringValue(astr);
+ }
+ else if(getpathes)
+ {
+ if(!afile.IsLocated()) afile.Locate(locator);
+ if(afile.IsLocated())
+ returns.AddStringValue(afile.Path());
+ }
+ else if(getname)
+ {
+ returns.AddStringValue(afile.Name());
+ }
+ else if(getftype)
+ {
+ returns.AddStringValue(afile.Type());
+ }
+ }
+ }
+ return 0;
+ }
+ if(gettype)
+ {
+ returns.AddStringValue(aunit.Type());
+ }
+ if(gettypecode)
+ {
+ returns.AddStringValue(new TCollection_HAsciiString(aunit.TypeKey()));
+ }
+
+ return 0;
+}
+//=======================================================================
+void WOKAPI_UnitMake_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << "[<unit>] [-f] [-e|-s|-o] <step>] [-t <target>] \n";
+ cerr << endl;
+ cerr << " Options are :" << endl;
+ cerr << " -f : Force build (applies to all following steps)" << endl;
+ cerr << " -o <step> : Build only following step" << endl;
+ cerr << " -s <step> : Start build at following step" << endl;
+ cerr << " -e <step> : End build at following step" << endl;
+ cerr << endl;
+ cerr << " -t <target> : Build only specified target" << endl;
+ cerr << endl;
+}
+
+static void AddTargetToStep(WOKTools_DataMapOfHAsciiStringOfHSequenceOfHAsciiString& amap,
+ const Handle(TCollection_HAsciiString)& step,
+ const Handle(TCollection_HAsciiString)& atarget)
+{
+ Handle(TColStd_HSequenceOfHAsciiString) aseq;
+ if(amap.IsBound(step))
+ {
+ aseq = amap.Find(step);
+ }
+ else
+ {
+ aseq = new TColStd_HSequenceOfHAsciiString;
+ }
+
+ aseq->Append(atarget);
+ amap.Bind(step, aseq);
+}
+
+//=======================================================================
+//function : UnitMake
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::UnitMake(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+#if defined( WNT ) && defined( _DEBUG )
+ _debug_break ( "WOKAPI_Command :: UnitMake" );
+ OSD_Timer t;
+ t.Start ();
+#endif // WNT && _DEBUG
+ WOKTools_Options opts(argc, argv, "s:e:u:o:t:fhSL", WOKAPI_UnitMake_Usage, "hfS");
+ Standard_Boolean force = Standard_False;
+ Standard_Boolean hasonly = Standard_False;
+ Standard_Boolean hasstart = Standard_False;
+ Standard_Boolean hasend = Standard_False;
+ Standard_Boolean getsteps = Standard_False;
+ Standard_Boolean logmsgs = Standard_False;
+
+ Handle(TCollection_HAsciiString) astr;
+ Handle(TCollection_HAsciiString) astart;
+ Handle(TCollection_HAsciiString) aend;
+ TColStd_SequenceOfHAsciiString onlys;
+ WOKTools_DataMapOfHAsciiStringOfHSequenceOfHAsciiString targetmap;
+ Handle(TCollection_HAsciiString) curstepcode;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'o':
+ // only
+ if(hasstart||hasend)
+ {
+ ErrorMsg << "WOKAPI_Unit::Make" << "Only option associated with start, end or until option is illegal" << endm;
+ WOKAPI_UnitMake_Usage(argv[0]);
+ return 1;
+ }
+ hasonly = Standard_True;
+ onlys.Append(opts.OptionArgument());
+ curstepcode = opts.OptionArgument();
+ break;
+ case 's':
+ if(hasonly||hasstart)
+ {
+ ErrorMsg << "WOKAPI_Unit::Make" << "Start option associated with start, only or until option is illegal" << endm;
+ WOKAPI_UnitMake_Usage(argv[0]);
+ return 1;
+ }
+ hasstart = Standard_True;
+ astart = opts.OptionArgument();
+ curstepcode = opts.OptionArgument();
+ break;
+ case 'e':
+ if(hasonly||hasend)
+ {
+ ErrorMsg << "WOKAPI_Unit::Make" << "End option associated to only or until option is illegal" << endm;
+ WOKAPI_UnitMake_Usage(argv[0]);
+ return 1;
+ }
+ hasend = Standard_True;
+ aend = opts.OptionArgument();
+ curstepcode = opts.OptionArgument();
+ break;
+ case 'f':
+ // force
+ force = Standard_True;
+ break;
+ case 't':
+ // no targets for the moment
+ if(curstepcode.IsNull())
+ {
+ WarningMsg << argv[0] << "No step code to associate target " << opts.OptionArgument() << " with : target ignored" << endm;
+ }
+ else
+ {
+ AddTargetToStep(targetmap, curstepcode, opts.OptionArgument());
+ }
+ break;
+ case 'S':
+ getsteps = Standard_True;
+ break;
+ case 'L':
+ logmsgs = Standard_True;
+ break;
+ default:
+ return 1;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed()) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ astr = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_UnitMake_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Unit aunit(asession,astr,Standard_False);
+
+ if(!aunit.IsValid())
+ {
+ ErrorMsg << argv[0] << "Could not determine unit : Specify unit in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ WOKAPI_Workbench abench(asession,astr,Standard_False);
+
+
+ WOKAPI_BuildProcess aprocess;
+
+ if(!aprocess.Init(abench))
+ {
+ ErrorMsg << argv[0]
+ << "Could not initialize BuildProcess" << endm;
+ return 1;
+ }
+
+ aprocess.Add(aunit);
+
+ aprocess.SetForceFlag(force);
+
+ Standard_Integer status;
+ if(getsteps)
+ {
+ WOKAPI_SequenceOfMakeStep steps;
+ aprocess.UnitSteps(aunit, steps);
+ Standard_Integer i;
+
+ for(i=1; i<=steps.Length(); i++)
+ {
+ returns.AddStringValue(steps.Value(i).Code());
+ }
+ return 0;
+ }
+ else
+ {
+ Standard_Integer selected = 0;
+ if(hasstart || hasend)
+ {
+ // une seule selection a faire
+ selected += aprocess.SelectOnSteps(aunit, astart, aend);
+ }
+ else if( hasonly )
+ {
+ for(Standard_Integer i=1; i<=onlys.Length(); i++)
+ {
+ selected += aprocess.SelectOnSteps(aunit, onlys.Value(i), onlys.Value(i));
+ }
+ }
+ else
+ {
+ selected += aprocess.SelectOnSteps(aunit, astart, aend);
+ }
+
+ if(!targetmap.IsEmpty())
+ {
+ WOKTools_DataMapIteratorOfDataMapOfHAsciiStringOfHSequenceOfHAsciiString anit(targetmap);
+
+ while(anit.More())
+ {
+ aprocess.ApplyTargetsToSteps(anit.Key(), anit.Value());
+ anit.Next();
+ }
+ }
+
+
+
+ if(!aprocess.SelectedStepsNumber())
+ {
+ InfoMsg << argv[0] << "No step to execute : check command line" << endm;
+ }
+ else
+ {
+ aprocess.PrintBanner();
+ status= aprocess.Execute(logmsgs);
+ }
+
+ }
+
+
+ //
+#if defined( WNT ) && defined( _DEBUG )
+ t.Show ();
+#endif // WNT && _DEBUG
+
+ return status;
+}
+//=======================================================================
+void WOKAPI_UnitMakeInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << "[<unit>] [-f] [-e|-s|-o] <step>] [-t <target>] \n";
+ cerr << endl;
+ cerr << " Options are :" << endl;
+ cerr << " -S : unit steps" << endl;
+ cerr << " -i <stepcode> : step input" << endl;
+ cerr << " -o <stepcode> : step output" << endl;
+ cerr << " -O <stepcode> : out of date entities" << endl;
+ cerr << " -s <stepcode> : step status" << endl;
+ cerr << " -I <inputID> : impact of modification" << endl;
+ cerr << endl;
+}
+
+//=======================================================================
+//function : UnitMakeInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::UnitMakeInfo(const WOKAPI_Session& ,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc, argv, "", WOKAPI_UnitMakeInfo_Usage, "");
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'S':
+ break;
+ }
+ opts.Next();
+ }
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_UnitDestroy_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <name>\n";
+ cerr << endl;
+}
+
+
+//=======================================================================
+//function : UnitDestroy
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::UnitDestroy(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc, argv, "D:hdP", WOKAPI_UnitDestroy_Usage);
+ Handle(TCollection_HAsciiString) name;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_UnitDestroy_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Unit aunit(asession,name,Standard_False);
+
+ if(!aunit.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::UnitDestroy"
+ << "Could not determine unit : Specify unit in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ aunit.Destroy();
+
+ return 0;
+}
+
--- /dev/null
+// File: WOKAPI_Command_Warehouse.cxx
+// Created: Wed Oct 23 11:57:52 1996
+// Author: Jean GAUTIER
+// <jga@cobrax.paris1.matra-dtv.fr>
+
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKAPI_Session.hxx>
+#include <WOKAPI_Warehouse.hxx>
+#include <WOKAPI_SequenceOfParcel.hxx>
+#include <WOKAPI_Parcel.hxx>
+
+#include <WOKAPI_Command.jxx>
+
+//=======================================================================
+void WOKAPI_WarehouseBuild_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << "-<options> -Dparameter=value,... -D... <name>\n";
+ cerr << endl;
+ cerr << " Options are : ";
+ cerr << " -P : propose default parameters value" << endl;
+ cerr << " -d : use default values for parameters (this is the default)" << endl;
+ cerr << " -n : don't use default values for parameters" << endl;
+ cerr << " -Dparam=Value : override default value for parameter %<WarehouseName>_<param>" << endl;
+}
+
+//=======================================================================
+//function : WarehouseCreate
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WarehouseCreate(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ Standard_Integer i;
+ WOKTools_Options opts(argc, argv, "D:hdnP", WOKAPI_WarehouseBuild_Usage);
+ Handle(TCollection_HAsciiString) aname;
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) factname, shopname;
+ Standard_Boolean querydefault = Standard_True;
+ Standard_Boolean proposedefault = Standard_False;
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'd':
+ querydefault = Standard_True;
+ break;
+ case 'n':
+ querydefault = Standard_False;
+ break;
+ case 'P':
+ querydefault = Standard_True;
+ proposedefault = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WarehouseBuild_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Warehouse aware;
+
+ if(proposedefault)
+ {
+ aseq = aware.BuildParameters(asession, name, opts.Defines(), querydefault);
+
+ for(i =1 ; i <= aseq->Length(); i++)
+ {
+ returns.AddStringParameter(aseq->Value(i).Name(), aseq->Value(i).Value());
+ }
+ }
+ else
+ {
+ if(!aware.Build(asession, name, opts.Defines(), querydefault))
+ {
+ return 0;
+ }
+ else return 1;
+ }
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_WarehouseInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [-p] <name>\n";
+ cerr << endl;
+ cerr << " Options are : ";
+ cerr << " -p : Parcels available in warehouse\n";
+ cerr << endl;
+}
+
+
+
+//=======================================================================
+//function : WarehouseInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WarehouseInfo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc, argv, "hp", WOKAPI_WarehouseInfo_Usage);
+ Handle(TCollection_HAsciiString) name;
+ Standard_Boolean getparcels = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'p':
+ getparcels = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ case 0:
+ break;
+ default:
+ WOKAPI_WarehouseInfo_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Warehouse aware(asession,name);
+
+ if(!aware.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::WarehouseInfo"
+ << "Could not determine Warehouse : Specify Warehouse in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ if(getparcels)
+ {
+ Standard_Integer i;
+ WOKAPI_SequenceOfParcel parcels;
+
+ aware.Parcels(parcels);
+
+ for(i=1; i<=parcels.Length(); i++)
+ {
+ returns.AddStringValue(parcels.Value(i).Name());
+ }
+ }
+
+ return 0;
+}
+//=======================================================================
+void WOKAPI_WarehouseDestroy_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <name>\n";
+ cerr << endl;
+}
+
+
+//=======================================================================
+//function : WarehouseDestroy
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WarehouseDestroy(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc, argv, "D:hdP", WOKAPI_WarehouseDestroy_Usage);
+ Handle(TCollection_HAsciiString) name;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'R':
+ ErrorMsg << "WOKAPI_Command::WarehouseDestroy" << "-R not yet implemented" << endm;
+ return 1;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WarehouseBuild_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Warehouse aware(asession,name);
+
+ if(!aware.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::WarehouseDestroy"
+ << "Could not determine Warehouse : Specify Warehouse in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ aware.Destroy();
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_WarehouseDeclare_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -p <parcelname> -Dparameter=value,... <housename>\n";
+ cerr << endl;
+ cerr << " Options are : \n";
+ cerr << " -p <parcelname> : define name of parcel to declare (must be given)\n";
+ cerr << " -d : create using default behaviour query\n";
+ cerr << " -P : propose results of default behaviour query\n";
+ cerr << " Parameters are :\n";
+ cerr << " <parcelname>_Adm = for <parcelname> administration\n";
+ cerr << " <parcelname>_Home = for <parcelname> home directory\n";
+ cerr << " <parcelname>_Stations = for <parcelname> available stations\n";
+ cerr << " <parcelname>_DBMSystems = for <parcelname> available DBMS\n";
+ cerr << " <parcelname>_Delivery = for delivery name\n";
+}
+
+//=======================================================================
+//function : WarehouseDeclare
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WarehouseDeclare(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ WOKTools_Options opts(argc, argv, "D:hdp:P", WOKAPI_WarehouseDeclare_Usage);
+ Handle(TCollection_HAsciiString) name,parcelname;
+ Standard_Boolean getdefault = Standard_False;
+ Standard_Boolean propdefault = Standard_False;
+
+ if(opts.Failed()) return 1;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'p' :
+ parcelname = opts.OptionArgument();
+ break;
+ case 'd' :
+ getdefault = Standard_True;
+ break;
+ case 'P' :
+ propdefault = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if (parcelname.IsNull()) {
+ ErrorMsg << "WOKAPI_Command::WarehouseDeclare"
+ << "Parcel name is missing" << endm;
+ WOKAPI_WarehouseDeclare_Usage(argv[0]);
+ return 1;
+ }
+
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ case 0:
+ break;
+ default:
+ WOKAPI_WarehouseDeclare_Usage(argv[0]);
+ return 1;
+ }
+
+
+ WOKAPI_Warehouse aware(asession,name);
+
+ if(!aware.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::WarehouseDeclare"
+ << "Could not determine Warehouse : Specify Warehouse in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ if (propdefault)
+ {
+ WOKAPI_Parcel aparc;
+ Handle(TCollection_HAsciiString) aname = new TCollection_HAsciiString(aware.UserPath());
+
+ aname->AssignCat(":");
+ aname->AssignCat(parcelname);
+
+ Handle(WOKUtils_HSequenceOfParamItem) aseq = aparc.BuildParameters(asession,
+ aname,
+ opts.Defines(),
+ getdefault);
+ for(Standard_Integer i =1 ; i <= aseq->Length(); i++)
+ {
+ returns.AddStringParameter(aseq->Value(i).Name(), aseq->Value(i).Value());
+ }
+ return 0;
+ }
+
+ WOKAPI_Parcel aparcel(asession,parcelname,Standard_False);
+ if (aparcel.IsValid()) {
+ ErrorMsg << "WOKAPI_Command::WarehouseDeclare"
+ << "Parcel " << parcelname << " is already declared in Warehouse " << aware.Name() << endm;
+ return 1;
+ }
+
+ WOKAPI_Parcel aparc;
+ if (!aparc.Declare(asession,
+ parcelname,
+ aware,
+ opts.Defines(),
+ getdefault)) {
+ ErrorMsg << "WOKAPI_Command::WarehouseDeclare"
+ << "Unable to declare parcel " << parcelname << " in Warehouse " << aware.Name() << endm;
+ return 1;
+ }
+
+ return 0;
+}
--- /dev/null
+// File: WOKAPI_Command_Workbench.cxx
+// Created: Wed Oct 23 12:01:45 1996
+// Author: Jean GAUTIER
+// <jga@cobrax.paris1.matra-dtv.fr>
+
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_MapOfHAsciiString.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKAPI_Workbench.hxx>
+#include <WOKAPI_SequenceOfWorkbench.hxx>
+#include <WOKAPI_Unit.hxx>
+#include <WOKAPI_SequenceOfUnit.hxx>
+#include <WOKAPI_BuildProcess.hxx>
+#include <WOKAPI_SequenceOfMakeStep.hxx>
+#include <WOKAPI_MakeStep.hxx>
+#include <WOKAPI_Process.hxx>
+
+#include <WOKAPI_Command.jxx>
+
+//=======================================================================
+void WOKAPI_WorkbenchBuild_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -f <father> [-P] [-d|-n] [-D] <name>\n";
+ cerr << endl;
+ cerr << " Options are :\n";
+ cerr << " -f <father> : create workbench as son of <father>\n";
+ cerr << " -P : propose default parameters value" << endl;
+ cerr << " -d : use default values for parameters (this is the default)" << endl;
+ cerr << " -n : don't use default values for parameters" << endl;
+ cerr << " -Dparam=Value : override default value for parameter %<WorkshopName>_<param>" << endl;
+ cerr << endl;
+ return;
+}
+
+//=======================================================================
+//function : WorkbenchCreate
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WorkbenchCreate(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ Standard_Integer i;
+ WOKTools_Options opts(argc, argv, "D:hdPf:", WOKAPI_WorkbenchBuild_Usage, "dn");
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) fathername;
+ Standard_Boolean querydefault = Standard_True;
+ Standard_Boolean proposedefault = Standard_False;
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'd':
+ querydefault = Standard_True;
+ break;
+ case 'n':
+ querydefault = Standard_False;
+ break;
+ case 'f':
+ fathername = opts.OptionArgument();
+ break;
+ case 'P':
+ querydefault = Standard_True;
+ proposedefault = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WorkbenchBuild_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Workbench abench;
+
+
+ if(proposedefault)
+ {
+ aseq = abench.BuildParameters(asession, name, fathername, opts.Defines(), querydefault);
+
+ if (!aseq.IsNull())
+ {
+ for(i =1 ; i <= aseq->Length(); i++)
+ {
+ returns.AddStringParameter(aseq->Value(i).Name(), aseq->Value(i).Value());
+ }
+ }
+ }
+ else
+ {
+ if(!abench.Build(asession, name, fathername, opts.Defines(), querydefault))
+ {
+ return 0;
+ }
+ else return 1;
+ }
+ return 0;
+}
+//=======================================================================
+void WOKAPI_WorkbenchInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -<option> <aname>" << endl;
+ cerr << endl;
+ cerr << " Options are :\n";
+ cerr << " -l : list of units in WB\n";
+ cerr << " -a : list of units in WB with their types\n";
+ cerr << " -k : list of available toolkits from WB\n";
+ cerr << " -A : list of ancestors of WB\n";
+ cerr << " -f : father of WB\n";
+ cerr << " -C <unitname> : clients of unit in WB\n";
+ cerr << " -S <unitname> : suppliers of unit in WB\n";
+ cerr << " -S <execname:partname> : suppliers of executable in WB\n";
+ cerr << " -I <unitA,unitB,...> : list of units in WB sorted by implementation dependences\n";
+ cerr << " -T <typename1,...,typenameN> : lists units of types listed\n";
+ cerr << endl;
+}
+
+//=======================================================================
+//function : WorkbenchInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WorkbenchInfo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ Standard_Integer i;
+ Handle(TCollection_HAsciiString) astr, name, unitname;
+ Handle(TColStd_HSequenceOfHAsciiString) unitlist,sortedunitlist, typedunitlist;
+ WOKTools_Options opts(argc, argv, "halkAfS:C:I:T:", WOKAPI_WorkbenchInfo_Usage, "halkAfSCI:");
+ Standard_Boolean getuds = Standard_False;
+ Standard_Boolean gettypeduds = Standard_False;
+ Standard_Boolean typed = Standard_False;
+ Standard_Boolean getanc = Standard_False;
+ Standard_Boolean gettk = Standard_False;
+ Standard_Boolean getfather = Standard_False;
+ Standard_Boolean getsuppliers = Standard_False;
+ Standard_Boolean getclients = Standard_False;
+ Standard_Boolean getorder = Standard_False;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'a':
+ getuds = Standard_True;
+ typed = Standard_True;
+ break;
+ case 'A':
+ getanc = Standard_True;
+ break;
+ case 'l':
+ getuds = Standard_True;
+ break;
+ case 'k':
+ gettk = Standard_True;
+ break;
+ case 'f':
+ getfather = Standard_True;
+ break;
+ case 'S':
+ getsuppliers = Standard_True;
+ unitname = opts.OptionArgument();
+ break;
+ case 'C':
+ getclients = Standard_True;
+ unitname = opts.OptionArgument();
+ break;
+ case 'I':
+ getorder = Standard_True;
+ unitlist = opts.OptionListArgument();
+ break;
+ case 'T':
+ gettypeduds = Standard_True;
+ typedunitlist = opts.OptionListArgument();
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WorkbenchInfo_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Workbench abench(asession,name);
+
+
+ if(!abench.IsValid())
+ {
+ ErrorMsg << argv[0]
+ << "Could not determine workbench : Specify workbench in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ if(getuds)
+ {
+ WOKAPI_SequenceOfUnit unitseq;
+
+ abench.Units(unitseq);
+
+ for(i=1; i<= unitseq.Length() ; i++)
+ {
+ if(typed == Standard_True)
+ {
+ astr = new TCollection_HAsciiString(unitseq.Value(i).Type());
+ astr->AssignCat(" ");
+ astr->AssignCat(unitseq.Value(i).Name());
+
+ returns.AddStringValue(astr);
+ }
+ else
+ {
+ returns.AddStringValue(unitseq.Value(i).Name());
+ }
+ }
+ return 0;
+ }
+
+ if(gettypeduds)
+ {
+ WOKAPI_SequenceOfUnit unitseq;
+
+ if(typedunitlist.IsNull()) return 1;
+
+ for(Standard_Integer j=1; j<=typedunitlist->Length(); j++)
+ abench.UnitsOfType(typedunitlist->Value(j), unitseq, Standard_False);
+
+ for(i=1; i<= unitseq.Length() ; i++)
+ {
+ returns.AddStringValue(unitseq.Value(i).Name());
+ }
+ return 0;
+ }
+
+ if(getanc)
+ {
+ WOKAPI_SequenceOfWorkbench benchseq;
+
+ abench.Ancestors(benchseq);
+
+ for(i=1; i<= benchseq.Length(); i++)
+ {
+ returns.AddStringValue(benchseq.Value(i).Name());
+ }
+ return 0;
+ }
+ if(getfather)
+ {
+ WOKAPI_Workbench father = abench.Father();
+
+ if(father.IsValid())
+ {
+ returns.AddStringValue(father.Name());
+ }
+ }
+ if (gettk)
+ {
+ WOKAPI_SequenceOfUnit tkseq;
+ abench.Toolkits(tkseq);
+ for(i=1; i<= tkseq.Length(); i++)
+ {
+ returns.AddStringValue(tkseq.Value(i).Name());
+ }
+ return 0;
+ }
+ if(getsuppliers)
+ {
+ Standard_Integer i;
+ WOKAPI_SequenceOfUnit unitseq;
+
+ abench.ImplSuppliers(unitname,unitseq);
+
+ for(i=1; i<=unitseq.Length(); i++)
+ {
+ returns.AddStringValue(unitseq.Value(i).Name());
+ }
+ return 0;
+ }
+ if(getclients)
+ {
+ Standard_Integer i;
+ WOKAPI_SequenceOfUnit unitseq;
+
+ abench.ImplClients(unitname,unitseq);
+
+ for(i=1; i<=unitseq.Length(); i++)
+ {
+ returns.AddStringValue(unitseq.Value(i).Name());
+ }
+ return 0;
+ }
+ if(getorder)
+ {
+ abench.SortUnitList(unitlist,sortedunitlist);
+ if (!sortedunitlist.IsNull())
+ {
+ for(i=1; i<=sortedunitlist->Length(); i++)
+ {
+ returns.AddStringValue(sortedunitlist->Value(i));
+ }
+ }
+ else return 1;
+ }
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_WorkbenchMove_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -f <new_father> <name>" << endl;
+ cerr << endl;
+ cerr << " Options are : " << endl;
+ cerr << " -f : the new father of the workbench." << endl;
+ cerr << endl;
+}
+
+
+
+//=======================================================================
+//function : WorkbenchMove
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WorkbenchMove(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc, argv, "hf:", WOKAPI_WorkbenchMove_Usage);
+ Handle(TCollection_HAsciiString) name,father;
+
+ while(opts.More()) {
+ switch(opts.Option()) {
+ case 'f':
+ father = opts.OptionArgument();
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WorkbenchMove_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Workbench abench(asession,name);
+
+ if (!abench.IsValid()) {
+ ErrorMsg << "WOKAPI_Command::WorkbenchMove"
+ << "Could not determine workbench : Specify workbench in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ WOKAPI_Workbench afather(asession,father);
+
+ if (!abench.IsValid()) {
+ ErrorMsg << "WOKAPI_Command::WorkbenchMove"
+ << "Unable to find father workbench : Try to specify the complete workbench path in command line" << endm;
+ return 1;
+ }
+
+ return abench.ChangeFather(afather);
+}
+
+
+//=======================================================================
+void WOKAPI_WorkbenchDestroy_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <WorkbenchName>\n";
+ cerr << endl;
+}
+
+
+
+//=======================================================================
+//function : WorkbenchDestroy
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WorkbenchDestroy(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc, argv, "D:hdP", WOKAPI_WorkbenchDestroy_Usage);
+ Handle(TCollection_HAsciiString) name;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'R':
+ ErrorMsg << "WOKAPI_Command::WorkbenchDestroy" << "-R not yet implemented" << endm;
+ return 1;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WorkbenchDestroy_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Workbench abench(asession,name);
+
+ if(!abench.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::WorkbenchDestroy"
+ << "Could not determine workbench : Specify workbench in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ abench.Destroy();
+ return 0;
+}
+
+
+//=======================================================================
+void WOKAPI_WorkbenchProcess_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " [<WorkbenchName>]\n";
+ cerr << " Options are : " << endl;
+ cerr << " -DGroups=Obj,Dep,Lib,Exec : selects groups Obj, Lib, and Exec" << endl;
+ cerr << " -DUnits=MyUd1,MyUd2,.. : selects units MyUd1,MyUd2,.." << endl;
+ cerr << " -DXGroups=Src,Deliv : Excludes groups Obj and Deliv" << endl;
+ cerr << " -DXUnits=MyUd1,MyUd2,.. : Excludes units MyUd1,MyUd2,.." << endl;
+ cerr << " Available groups are Src Xcpp SchXcpp Obj Dep Lib Exec Deliv" << endl;
+ cerr << endl;
+ cerr << " -f : forces all selected steps" << endl;
+ cerr << " -d|-o : switches debug|optimized mode" << endl;
+ cerr << " -B <profile> : selects extraction profile" << endl;
+ cerr << endl;
+ cerr << " -P : prints out selected steps" << endl;
+ cerr << " -S : silent mode (does not print banner" << endl;
+ cerr << " -L : logs output to MyUD_<step code>.Log in step administration directory" << endl;
+ cerr << endl;
+ cerr << " -F <file> : " << cmd << " utilise alors un fichier de parametrage <file>" << endl;
+ cerr << endl;
+}
+
+
+//=======================================================================
+//function : WorkbenchProcess
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WorkbenchProcess(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+
+ WOKTools_Options opts(argc, argv, "odB:PSLD:fhF:", WOKAPI_WorkbenchProcess_Usage);
+ Handle(TCollection_HAsciiString) name;
+ Standard_Boolean logflag = Standard_False;
+ Standard_Boolean silent = Standard_False;
+ //Standard_Boolean force = Standard_False;
+ Standard_Boolean propose = Standard_False;
+ Standard_Boolean debug = Standard_False;
+ Standard_Boolean savedebug = Standard_False;
+ Standard_Boolean optim = Standard_False;
+ Standard_Boolean profile = Standard_False;
+ Standard_Boolean useconfig = Standard_False;
+ Handle(TCollection_HAsciiString) cfgfile;
+ Handle(TCollection_HAsciiString) profilename, saveprofile;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'L':
+ logflag = Standard_True;
+ break;
+ case 'S':
+ silent = Standard_True;
+ break;
+ case 'f':
+ //force = Standard_True;
+ opts.Define(new TCollection_HAsciiString("Force"), new TCollection_HAsciiString("Yes"));
+ break;
+ case 'o':
+ optim = Standard_True;
+ break;
+ case 'd':
+ debug = Standard_True;
+ break;
+ case 'B':
+ profile = Standard_True;
+ profilename = opts.OptionArgument();
+ break;
+ case 'P':
+ propose = Standard_True;
+ break;
+ case 'F':
+ useconfig = Standard_True;
+ cfgfile = opts.OptionArgument();
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WorkbenchProcess_Usage(argv[0]);
+ return 1;
+ }
+
+ if(useconfig)
+ {
+ WOKAPI_Process aprocess(asession);
+
+ aprocess.ExecuteFile(cfgfile);
+
+ return 0;
+ }
+ else
+ {
+ if(debug && optim)
+ {
+ ErrorMsg << "WOKAPI_Command::WorkbenchProcess"
+ << "Optimised and debug mode cannot be combined" << endm;
+ return 1;
+ }
+
+ if(debug||optim||profile)
+ {
+ savedebug = asession.DebugMode();
+ saveprofile = asession.DBMSystem();
+ }
+
+ if(debug)
+ {
+ WOKAPI_Session* sess = (WOKAPI_Session*)&asession;
+ sess->SetDebugMode(Standard_True);
+ }
+ if(optim)
+ {
+ WOKAPI_Session* sess = (WOKAPI_Session*)&asession;
+ sess->SetDebugMode(Standard_False);
+ }
+ if(profile)
+ {
+ WOKAPI_Session* sess = (WOKAPI_Session*)&asession;
+ sess->SetDBMSystem(profilename);
+ }
+
+ if(debug||optim||profile)
+ {
+ WOKAPI_Session* sess = (WOKAPI_Session*)&asession;
+ sess->Close();
+ sess->Open();
+ }
+
+ WOKAPI_Workbench abench(asession,name);
+
+ if(!abench.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::WorkbenchProcess"
+ << "Could not determine workbench : Specify workbench in command line or use wokcd" << endm;
+ return 1;
+ }
+
+
+ WOKAPI_BuildProcess aproc;
+
+ aproc.Init(abench);
+ //aproc.SetForceFlag(force);
+
+ aproc.SelectOnDefines(opts.Defines());
+
+ if(!aproc.SelectedStepsNumber())
+ {
+ InfoMsg << argv[0] << "No step to execute : check command line" << endm;
+ }
+ else
+ {
+ if(!propose)
+ {
+ if(!silent) aproc.PrintBanner();
+ aproc.Execute(logflag);
+ }
+ else
+ {
+ WOKAPI_SequenceOfMakeStep steps;
+
+ aproc.SelectedSteps(steps);
+
+ for(Standard_Integer i=1; i<=steps.Length(); i++)
+ {
+ const WOKAPI_MakeStep& step = steps.Value(i);
+
+ returns.AddStringValue(step.UniqueName());
+ }
+ }
+ }
+
+ if(debug||optim||profile)
+ {
+ WOKAPI_Session* sess = (WOKAPI_Session*)&asession;
+ sess->SetDebugMode(savedebug);
+ sess->SetDBMSystem(saveprofile);
+ sess->Close();
+ sess->Open();
+ }
+ }
+ return 0;
+}
+
+
+
--- /dev/null
+// File: WOKAPI_Command_Workshop.cxx
+// Created: Wed Oct 23 12:01:10 1996
+// Author: Jean GAUTIER
+// <jga@cobrax.paris1.matra-dtv.fr>
+
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKAPI_Workshop.hxx>
+#include <WOKAPI_Workbench.hxx>
+#include <WOKAPI_SequenceOfWorkbench.hxx>
+#include <WOKAPI_Parcel.hxx>
+#include <WOKAPI_SequenceOfParcel.hxx>
+
+#include <WOKAPI_Command.jxx>
+
+
+//=======================================================================
+void WOKAPI_WorkshopBuild_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " -d -Dparameter=value,... -D... <name>" << endl ;
+ cerr << endl;
+ cerr << " Options are :" << endl;
+ cerr << " -P : propose default parameters value" << endl;
+ cerr << " -d : use default values for parameters (this is the default)" << endl;
+ cerr << " -n : don't use default values for parameters" << endl;
+ cerr << " -Dparam=Value : override default value for parameter %<WorkshopName>_<param>" << endl;
+ cerr << endl;
+ return;
+}
+
+//=======================================================================
+//function : WorkshopCreate
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WorkshopCreate(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+
+ Standard_Integer i;
+ WOKTools_Options opts(argc, argv, "D:hdnP", WOKAPI_WorkshopBuild_Usage);
+ Handle(TCollection_HAsciiString) aname;
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) factname, shopname;
+ Standard_Boolean querydefault = Standard_True;
+ Standard_Boolean proposedefault = Standard_False;
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'd':
+ querydefault = Standard_True;
+ break;
+ case 'n':
+ querydefault = Standard_False;
+ break;
+ case 'P':
+ querydefault = Standard_True;
+ proposedefault = Standard_True;
+ break;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WorkshopBuild_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Workshop ashop;
+
+ if(proposedefault)
+ {
+ aseq = ashop.BuildParameters(asession, name, opts.Defines(), querydefault);
+
+ for(i =1 ; i <= aseq->Length(); i++)
+ {
+ returns.AddStringParameter(aseq->Value(i).Name(), aseq->Value(i).Value());
+ }
+ }
+ else
+ {
+ if(!ashop.Build(asession, name, opts.Defines(), querydefault))
+ {
+ return 0;
+ }
+ else return 1;
+ }
+ return 0;
+}
+//=======================================================================
+void WOKAPI_WorkshopInfo_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << "[-t|-l|-p] [<name>]\n";
+ cerr << endl;
+ cerr << " Options are :\n";
+ cerr << " -t : get tree of workbenches\n";
+ cerr << " -w : list of workbenches\n";
+ cerr << " -p : list of parcels in configuration\n";
+}
+
+//=======================================================================
+//function : WorkshopInfo
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WorkshopInfo(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& returns)
+{
+ Standard_Integer i;
+ Handle(TCollection_HAsciiString) aname;
+ WOKTools_Options opts(argc, argv, "htwp", WOKAPI_WorkshopInfo_Usage);
+ Standard_Boolean gettree = Standard_False, getwbs = Standard_False, getparcels = Standard_False;
+
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 't':
+ gettree = Standard_True;
+ break;
+ case 'w':
+ getwbs = Standard_True;
+ break;
+ case 'p':
+ getparcels = Standard_True;
+ break;
+ default:
+ return 1;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+
+ switch(opts.Arguments()->Length())
+ {
+ case 0:
+ break;
+ case 1:
+ aname = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WorkshopInfo_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Workshop ashop(asession,aname);
+
+ if(!ashop.IsValid())
+ {
+ ErrorMsg << argv[0]
+ << "Could not determine workshop : Specify workshop in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ if(gettree == Standard_True)
+ {
+ ErrorMsg << argv[0] << "Option -t not yet implemented\n";
+ return 1;
+ }
+
+ if(getwbs == Standard_True)
+ {
+ WOKAPI_SequenceOfWorkbench benchseq;
+
+ ashop.Workbenches(benchseq);
+
+ for(i=1; i<= benchseq.Length() ; i++)
+ {
+ returns.AddStringValue(benchseq.Value(i).Name());
+ }
+ return 0;
+ }
+ if(getparcels == Standard_True)
+ {
+ WOKAPI_SequenceOfParcel parcseq;
+
+ ashop.UsedParcels(parcseq);
+
+ for(i=1; i<= parcseq.Length() ; i++)
+ {
+ returns.AddStringValue(parcseq.Value(i).Name());
+ }
+ return 0;
+ }
+ return 0;
+}
+
+//=======================================================================
+void WOKAPI_WorkshopDestroy_Usage(char *cmd)
+{
+ cerr << "usage : " << cmd << " <name>\n";
+ cerr << endl;
+}
+
+
+
+//=======================================================================
+//function : WorkshopDestroy
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Command::WorkshopDestroy(const WOKAPI_Session& asession,
+ const Standard_Integer argc, const WOKTools_ArgTable& argv,
+ WOKTools_Return& )
+{
+ WOKTools_Options opts(argc, argv, "D:hdP", WOKAPI_WorkshopDestroy_Usage);
+ Handle(TCollection_HAsciiString) name;
+
+ while(opts.More())
+ {
+ switch(opts.Option())
+ {
+ case 'R':
+ ErrorMsg << "WOKAPI_Command::WorkshopDestroy" << "-R not yet implemented" << endm;
+ return 1;
+ default:
+ break;
+ }
+ opts.Next();
+ }
+
+ if(opts.Failed() == Standard_True) return 1;
+
+ switch(opts.Arguments()->Length())
+ {
+ case 1:
+ name = opts.Arguments()->Value(1);
+ break;
+ default:
+ WOKAPI_WorkshopDestroy_Usage(argv[0]);
+ return 1;
+ }
+
+ WOKAPI_Workshop ashop(asession,name);
+
+ if(!ashop.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Command::WorkshopDestroy"
+ << "Could not determine workshop : Specify workshop in command line or use wokcd" << endm;
+ return 1;
+ }
+
+ ashop.Destroy();
+ return 0;
+}
--- /dev/null
+-- File: WOKAPI_Entity.cdl
+-- Created: Mon Feb 5 15:07:30 1996
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1996
+
+
+class Entity from WOKAPI
+
+ ---Purpose:
+
+uses
+ Session from WOKAPI,
+ SequenceOfEntity from WOKAPI,
+ Entity from WOKernel,
+ Session from WOKernel,
+ HSequenceOfParamItem from WOKUtils,
+ HSequenceOfDefine from WOKTools,
+ HSequenceOfReturnValue from WOKTools,
+ ArgTable from WOKTools,
+ Return from WOKTools,
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd,
+ SequenceOfHAsciiString from TColStd
+is
+
+ Create returns Entity from WOKAPI;
+
+ Create(aent : Entity from WOKAPI)
+ returns Entity from WOKAPI;
+
+ Create(asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ verbose : Boolean from Standard = Standard_False;
+ getit : Boolean from Standard = Standard_True)
+ returns Entity from WOKAPI;
+
+
+ IsValid(me)
+ returns Boolean from Standard
+ is virtual;
+
+ IsAccessible(me)
+ returns Boolean from Standard
+ is virtual;
+
+ IsWriteAble(me)
+ returns Boolean from Standard
+ is virtual;
+
+ IsSession(me) returns Boolean from Standard;
+ IsFactory(me) returns Boolean from Standard;
+ IsWarehouse(me) returns Boolean from Standard;
+ IsParcel(me) returns Boolean from Standard;
+ IsWorkshop(me) returns Boolean from Standard;
+ IsWorkbench(me) returns Boolean from Standard;
+ IsUnit(me) returns Boolean from Standard;
+
+
+ NestedEntities(me; aseq : out SequenceOfEntity from WOKAPI)
+ returns Boolean from Standard
+ is virtual;
+
+ NestingEntity(me)
+ returns Entity from WOKAPI;
+
+ Name(me)
+ returns HAsciiString from TCollection;
+
+ Code(me)
+ returns HAsciiString from TCollection;
+
+ UserPath(me)
+ returns HAsciiString from TCollection;
+
+ -- Vie de l'entite
+
+ Open(me:out; aSession : Session from WOKAPI; aPath : HAsciiString from TCollection);
+
+ Close(me:out)
+ is virtual;
+
+ Destroy(me:out)
+ returns Boolean from Standard
+ is virtual;
+
+
+ -- Parameters de l'entite
+
+ IsParameterSet(me; aname : HAsciiString from TCollection)
+ returns Boolean from Standard;
+
+ EntityParameterName(me; aparam : HAsciiString from TCollection)
+ returns HAsciiString from TCollection;
+
+ ParameterValue(me; aname : HAsciiString from TCollection)
+ returns HAsciiString from TCollection;
+
+ ParameterEval(me; aname : HAsciiString from TCollection)
+ returns HAsciiString from TCollection;
+
+ ParameterArguments(me; aname : HAsciiString from TCollection)
+ returns HSequenceOfHAsciiString from TColStd;
+
+ ParameterClassValues(me; aclass : HAsciiString from TCollection)
+ returns HSequenceOfParamItem from WOKUtils;
+
+ ParameterClasses(me)
+ returns HSequenceOfHAsciiString from TColStd;
+
+ ParameterSearchList(me)
+ returns HSequenceOfHAsciiString from TColStd;
+
+ ParameterClassFiles(me; aclass : HAsciiString from TCollection)
+ returns HSequenceOfHAsciiString from TColStd;
+
+ FindParameterFile(me; afile : HAsciiString from TCollection)
+ returns HAsciiString from TCollection;
+
+ ParameterSet(me; aname, avalue : HAsciiString from TCollection);
+
+ ParameterUnSet(me; aname : HAsciiString from TCollection);
+
+ ParameterReset(me);
+
+ -- Types de l'unite
+
+ IsFileType(me; aname : HAsciiString from TCollection)
+ returns Boolean from Standard;
+
+ IsFileTypeFileDependent(me; aname : HAsciiString from TCollection)
+ returns Boolean from Standard;
+
+ GetFileTypeDefinition(me; aname : HAsciiString from TCollection)
+ returns HAsciiString from TCollection;
+
+ GetFileTypeDirectory(me; aname : HAsciiString from TCollection)
+ returns HAsciiString from TCollection;
+
+ GetFileTypeArguments(me; aname : HAsciiString from TCollection; argseq : out SequenceOfHAsciiString from TColStd);
+
+ FileTypes(me; typeseq : out SequenceOfHAsciiString from TColStd);
+
+ -- Definition des paths de l'entite
+
+ GetFiles(me; fileseq : out SequenceOfHAsciiString from TColStd);
+
+ GetDirs(me; dirseq : out SequenceOfHAsciiString from TColStd);
+
+ CheckDirs(me; createifmissing : Boolean from Standard = Standard_True; besilent : Boolean from Standard = Standard_False)
+ returns Boolean from Standard;
+
+ -- Fichiers de l'entite
+
+ GetFilePath(me; atype, aname : HAsciiString from TCollection)
+ returns HAsciiString from TCollection;
+
+ GetFilePath(me; atype : HAsciiString from TCollection)
+ returns HAsciiString from TCollection;
+
+ -- Scripts de l'entite
+ --
+ GetInterpFiles(me; files : out HSequenceOfReturnValue from WOKTools);
+
+ GetEnvActions(me; asession : Session from WOKAPI;
+ actions : out Return from WOKTools)
+ returns Integer from Standard;
+
+
+ -- HTML de l'entite
+ --
+ HomePage(me; astream : OStream from Standard)
+ returns Boolean from Standard is virtual;
+
+ ItemHRef(me; astream : OStream from Standard)
+ returns Boolean from Standard is virtual;
+
+ PageHeader(me; astream : OStream from Standard)
+ returns Boolean from Standard is virtual protected;
+
+ PageFooter(me; astream : OStream from Standard)
+ returns Boolean from Standard is virtual protected;
+
+ -------- Entity PRIVATE methods
+ --
+ --
+
+ Set(me:out; anentity : Entity from WOKernel)
+ is private;
+
+ Session(me)
+ returns Session from WOKernel
+ is private;
+
+ Entity(me)
+ ---C++: inline
+ ---C++: return const &
+ returns Entity from WOKernel
+ is private;
+
+ UpdateBeforeDestroy(me:out; anesting : Entity from WOKernel) is private;
+ UpdateBeforeBuild(me:out; anesting : Entity from WOKernel) is private;
+
+ -- Naissance et mort de l'entite
+
+ BuildName(me; path : HAsciiString from TCollection)
+ returns HAsciiString from TCollection
+ is private;
+
+ BuildNesting(me; path : HAsciiString from TCollection)
+ returns HAsciiString from TCollection
+ is private;
+
+
+ GetBuildParameters(me; asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ anesting : Entity from WOKAPI;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns HSequenceOfParamItem from WOKUtils
+ is private;
+
+ BuildEntity(me:out; asession : Session from WOKAPI;
+ name : HAsciiString from TCollection;
+ anesting : Entity from WOKAPI;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard;
+ checkhome : Boolean from Standard = Standard_False)
+ returns Boolean from Standard
+ is private;
+
+
+
+
+fields
+
+ myEntity : Entity from WOKernel is protected;
+
+friends
+
+ class Session from WOKAPI,
+ class Factory from WOKAPI,
+ class Warehouse from WOKAPI,
+ class Parcel from WOKAPI,
+ class Workshop from WOKAPI,
+ class Workbench from WOKAPI,
+ class Unit from WOKAPI,
+ class File from WOKAPI,
+ class Locator from WOKAPI,
+ class BuildProcess from WOKAPI
+
+end Entity;
--- /dev/null
+// File: WOKAPI_Entity.cxx
+// Created: Mon Apr 1 17:26:57 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+#include <OSD_Environment.hxx>
+
+#include <TColStd_HSequenceOfAsciiString.hxx>
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Messages.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+#include <WOKTools_InterpFileValue.hxx>
+#include <WOKTools_MapOfHAsciiString.hxx>
+
+#include <WOKUtils_ParamItem.hxx>
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_Path.hxx>
+#include <WOKUtils_PathIterator.hxx>
+
+#include <WOKernel_Entity.hxx>
+#include <WOKernel_Session.hxx>
+#include <WOKernel_File.hxx>
+#include <WOKernel_FileType.hxx>
+#include <WOKernel_FileTypeBase.hxx>
+#include <WOKernel_FileTypeIterator.hxx>
+#include <WOKernel_HSequenceOfDBMSID.hxx>
+#include <WOKernel_HSequenceOfStationID.hxx>
+
+#include <WOKAPI_Factory.hxx>
+#include <WOKAPI_Workshop.hxx>
+#include <WOKAPI_Warehouse.hxx>
+#include <WOKAPI_Parcel.hxx>
+#include <WOKAPI_SequenceOfParcel.hxx>
+#include <WOKAPI_Workbench.hxx>
+#include <WOKAPI_SequenceOfWorkbench.hxx>
+#include <WOKAPI_Unit.hxx>
+
+#include <WOKAPI_Session.hxx>
+
+#include <WOKAPI_Entity.ixx>
+
+#ifdef WNT
+static const Standard_CString PATH_SEPARATOR = ";";
+#else
+static const Standard_CString PATH_SEPARATOR = ":";
+#endif
+
+//=======================================================================
+//function : WOKAPI_Entity
+//purpose :
+//=======================================================================
+ WOKAPI_Entity::WOKAPI_Entity()
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Entity
+//purpose :
+//=======================================================================
+ WOKAPI_Entity::WOKAPI_Entity(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal, const Standard_Boolean )
+{
+ Set(asession.GetEntity(apath,fatal));
+}
+
+//=======================================================================
+//function : WOKAPI_Entity
+//purpose :
+//=======================================================================
+WOKAPI_Entity::WOKAPI_Entity(const WOKAPI_Entity& anent)
+{
+ myEntity = anent.Entity();
+ if(!IsValid()) {
+ myEntity.Nullify();
+ }
+}
+
+//=======================================================================
+//function : Session
+//purpose :
+//=======================================================================
+Handle(WOKernel_Session) WOKAPI_Entity::Session() const
+{
+ if(myEntity.IsNull()) return Handle(WOKernel_Session)();
+ return myEntity->Session();
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::Set(const Handle(WOKernel_Entity)& anent)
+{
+ myEntity = anent;
+ //if(!myEntity.IsNull()) myEntity->Open();
+}
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsValid() const
+{
+ return !myEntity.IsNull();
+}
+
+//=======================================================================
+//function : IsAccessible
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsAccessible() const
+{
+ if(!IsValid()) return Standard_False;
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : IsWriteAble
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsWriteAble() const
+{
+ if(!IsValid()) return Standard_False;
+ return Standard_True;
+}
+
+
+//=======================================================================
+//function : IsSession
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsSession() const
+{
+ if(!myEntity.IsNull())
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Session));
+ return Standard_False;
+}
+
+//=======================================================================
+//function : IsFactory
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsFactory() const
+{
+ if(!myEntity.IsNull())
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Factory));
+ return Standard_False;
+}
+
+//=======================================================================
+//function : IsWarehouse
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsWarehouse() const
+{
+ if(!myEntity.IsNull())
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Warehouse));
+ return Standard_False;
+}
+
+//=======================================================================
+//function : IsParcel
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsParcel() const
+{
+ if(!myEntity.IsNull())
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Parcel));
+ return Standard_False;
+}
+
+//=======================================================================
+//function : IsWorkshop
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsWorkshop() const
+{
+ if(!myEntity.IsNull())
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Workshop));
+ return Standard_False;
+}
+
+//=======================================================================
+//function : IsWorkbench
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsWorkbench() const
+{
+ if(!myEntity.IsNull())
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Workbench));
+ return Standard_False;
+}
+
+//=======================================================================
+//function : IsUnit
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsUnit() const
+{
+ if(!myEntity.IsNull())
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_DevUnit));
+ return Standard_False;
+}
+
+//=======================================================================
+//function : NestedEntities
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::NestedEntities(WOKAPI_SequenceOfEntity& aseq) const
+{
+ if(!IsValid()) return Standard_False;
+ aseq.Clear();
+ return Standard_True;
+}
+
+//=======================================================================
+//function : NestingEntity
+//purpose :
+//=======================================================================
+WOKAPI_Entity WOKAPI_Entity::NestingEntity() const
+{
+ WOKAPI_Entity result;
+
+ if(!IsValid()) return result;
+
+ Handle(WOKernel_Session) asession = myEntity->Session();
+
+ if(!myEntity->Nesting().IsNull())
+ {
+ Handle(WOKernel_Entity) thenesting;
+ thenesting = asession->GetEntity(myEntity->Nesting());
+
+ result.Set(thenesting);
+ }
+ else
+ result.Set(asession);
+
+ return result;
+}
+
+
+
+//=======================================================================
+//function : Code
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::Code() const
+{
+ Handle(TCollection_HAsciiString) result;
+ if(IsValid())
+ {
+ if(!myEntity->IsOpened()) myEntity->Open();
+ result = myEntity->EntityCode();
+ }
+ return result;
+}
+
+//=======================================================================
+//function : Name
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::Name() const
+{
+ Handle(TCollection_HAsciiString) result;
+ if(IsValid())
+ {
+ result = myEntity->Name();
+ }
+ return result;
+}
+
+//=======================================================================
+//function : UserPath
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::UserPath() const
+{
+ Handle(TCollection_HAsciiString) result;
+ if(IsValid())
+ {
+ result = myEntity->UserPathName();
+ }
+ return result;
+}
+
+
+//=======================================================================
+//function : BuildName
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::BuildName(const Handle(TCollection_HAsciiString)& apath) const
+{
+ Standard_Integer i;
+ Handle(TCollection_HAsciiString) name;
+
+ i = apath->SearchFromEnd(":");
+
+ if(i != -1)
+ {
+ name = apath->SubString(i+1, apath->Length());
+ }
+ else
+ {
+ name = apath;
+ }
+ return name;
+}
+
+
+//=======================================================================
+//function : BuildNesting
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::BuildNesting(const Handle(TCollection_HAsciiString)& apath) const
+{
+ Standard_Integer i;
+ Handle(TCollection_HAsciiString) name;
+
+ i = apath->SearchFromEnd(":");
+
+ if(i != -1)
+ {
+ name = apath->SubString(1, i-1);
+ }
+ return name;
+}
+
+//=======================================================================
+//function : BuildParameters
+//purpose :
+//=======================================================================
+Handle(WOKUtils_HSequenceOfParamItem) WOKAPI_Entity::GetBuildParameters(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& name,
+ const WOKAPI_Entity& anesting,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults) const
+{
+ Handle(WOKUtils_HSequenceOfParamItem) someparams = new WOKUtils_HSequenceOfParamItem;
+ Handle(WOKUtils_HSequenceOfParamItem) result;
+ Handle(TCollection_HAsciiString) aprefix = new TCollection_HAsciiString;
+ Handle(TCollection_HAsciiString) astr;
+ Standard_Integer i;
+
+ if(!anesting.IsValid())
+ {
+ return result;
+ }
+
+ WOKAPI_Entity anent(asession, myEntity->FullName(),Standard_False);
+
+ if(anent.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Entity::BuildParameters"
+ << "There is already an entity with name : " << myEntity->UserPathName() << endm;
+ return result;
+ }
+
+ aprefix->AssignCat("%");
+ aprefix->AssignCat(name);
+ aprefix->AssignCat("_");
+
+ for(i=1; i<= defines->Length() ; i++)
+ {
+ astr = new TCollection_HAsciiString(aprefix);
+ astr->AssignCat(defines->Value(i).Name());
+ someparams->Append(WOKUtils_ParamItem(astr, defines->Value(i).Value()));
+ }
+
+ result = myEntity->BuildParameters(someparams, usedefaults);
+
+ return result;
+}
+
+//=======================================================================
+//function : Build
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::BuildEntity(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& aname,
+ const WOKAPI_Entity& anesting,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults,
+ const Standard_Boolean checkhome)
+{
+ Handle(WOKUtils_HSequenceOfParamItem) someparams;
+ Standard_Integer i;
+ Standard_Boolean failed = Standard_False;
+
+ if(!anesting.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Entity::BuildParameters"
+ << "Invalid Nesting : " << anesting.Entity()->UserPathName() << endm;
+ return Standard_True;
+ }
+
+ WOKAPI_Entity anent(asession, myEntity->FullName(),Standard_False);
+
+ if(anent.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Entity::BuildParameters"
+ << "There is already an entity with name : " << myEntity->UserPathName() << endm;
+ return Standard_True;
+ }
+
+ someparams = GetBuildParameters(asession, aname, anesting, defines, usedefaults);
+
+ Handle(TCollection_HAsciiString) namehome = new TCollection_HAsciiString("%");
+ namehome->AssignCat(aname);
+ namehome->AssignCat("_Home");
+ for(i=1; i<=someparams->Length(); i++)
+ {
+ const WOKUtils_ParamItem& item = someparams->Value(i);
+
+ if(item.Value().IsNull())
+ {
+ ErrorMsg << "WOKAPI_Entity::Build"
+ << "Needed parameter : " << item.Name() << " is not setted" << endm;
+ failed = Standard_True;
+ }
+
+ if (checkhome) {
+ if (namehome->IsSameString(item.Name())) {
+ Handle(WOKUtils_Path) apathname = new WOKUtils_Path(item.Value());
+ if (!apathname->FileName()->IsSameString(aname)) {
+ failed = Standard_True;
+ ErrorMsg << "WOKAPI_Entity::Build"
+ << "Invalid home directory " << apathname->Name() << " for entity " << Name() << endm;
+ }
+ }
+ }
+ }
+
+ if (!myEntity->IsValidName()) {
+ ErrorMsg << "WOKAPI_Entity::Build"
+ << "Invalid name for entity : " << Name() << endm;
+ failed = Standard_True;
+ }
+ if(failed) return Standard_True;
+
+ myEntity->Build(someparams);
+ return Standard_False;
+}
+
+//=======================================================================
+//function : UpdateBeforeBuild
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::UpdateBeforeBuild(const Handle(WOKernel_Entity)& anesting)
+{
+ if(anesting.IsNull()) return;
+
+ anesting->Close();
+ anesting->Open();
+ return;
+}
+
+//=======================================================================
+//function : UpdateBeforeDestroy
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::UpdateBeforeDestroy(const Handle(WOKernel_Entity)& anesting)
+{
+ if(!IsValid()) return ;
+
+ Handle(WOKernel_Session) asession = myEntity->Session();
+
+ if (!anesting.IsNull())
+ {
+ Handle(TCollection_HAsciiString) afullname = myEntity->FullName();
+ Handle(TCollection_HAsciiString) ausername = myEntity->UserPathName();
+
+ myEntity.Nullify();
+
+ anesting->Close();
+ anesting->Open();
+
+ myEntity = asession->GetEntity(afullname);
+
+ if(!IsValid())
+ {
+ ErrorMsg << "WOKAPI_Entity::UpdateEntityList"
+ << "Entity " << ausername << " no longer exists" << endm;
+ return;
+ }
+ }
+
+ return;
+}
+
+//=======================================================================
+//function : Destroy
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::Destroy()
+{
+ if(!IsValid()) return Standard_True;
+
+ // mettre a jour la EntityList
+ Handle(WOKernel_Entity) anesting = myEntity->Session()->GetEntity(myEntity->Nesting());
+
+ UpdateBeforeDestroy(anesting);
+ if(!IsValid()) return Standard_True;
+
+ myEntity->Open();
+ myEntity->Destroy();
+
+ return Standard_False;
+}
+
+//=======================================================================
+//function : Open
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::Open(const WOKAPI_Session& aSession,
+ const Handle(TCollection_HAsciiString)& apath)
+{
+ WOKAPI_Entity anent(aSession, apath);
+
+ if(anent.IsValid())
+ {
+ myEntity = anent.Entity();
+ }
+ else
+ if(IsValid()) myEntity->Open();
+ return;
+}
+
+//=======================================================================
+//function : Close
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::Close()
+{
+ if(IsValid())
+ {
+ myEntity->Close();
+ }
+}
+
+//=======================================================================
+//function : IsParameterSet
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsParameterSet(const Handle(TCollection_HAsciiString)& aname) const
+{
+ if(aname.IsNull()) return Standard_False;
+ if(IsValid())
+ return myEntity->Params().IsSet(aname->ToCString());
+ return Standard_False;
+}
+//=======================================================================
+//function :
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::EntityParameterName(const Handle(TCollection_HAsciiString)& aname) const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(aname.IsNull() || !IsValid()) return result;
+ if(!myEntity->IsOpened()) myEntity->Open();
+ result = myEntity->ParameterName(aname->ToCString());
+ return result;
+}
+
+//=======================================================================
+//function : ParameterValue
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::ParameterValue(const Handle(TCollection_HAsciiString)& aname) const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(aname.IsNull() || !IsValid()) return result;
+ if(!myEntity->IsOpened()) myEntity->Open();
+ result = myEntity->Params().Value(aname->ToCString());
+ return result;
+}
+
+//=======================================================================
+//function : ParameterEval
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::ParameterEval(const Handle(TCollection_HAsciiString)& aname) const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(aname.IsNull() || !IsValid()) return result;
+ if(!myEntity->IsOpened()) myEntity->Open();
+ result = myEntity->Params().Eval(aname->ToCString());
+ return result;
+}
+
+//=======================================================================
+//function : ParameterArguments
+//purpose :
+//=======================================================================
+Handle(TColStd_HSequenceOfHAsciiString) WOKAPI_Entity::ParameterArguments(const Handle(TCollection_HAsciiString)& aname) const
+{
+ Handle(TColStd_HSequenceOfHAsciiString) aseq, result = new TColStd_HSequenceOfHAsciiString;
+ Standard_Integer i;
+
+ if(aname.IsNull() || !IsValid()) return result;
+ if(!myEntity->IsOpened()) myEntity->Open();
+ aseq = myEntity->Params().GetArguments(aname->ToCString());
+
+ for(i=1; i<=aseq->Length(); i++)
+ {
+ result->Append(aseq->Value(i));
+ }
+ return result;
+}
+
+
+//=======================================================================
+//function : ParameterClassValues
+//purpose :
+//=======================================================================
+Handle(WOKUtils_HSequenceOfParamItem) WOKAPI_Entity::ParameterClassValues(const Handle(TCollection_HAsciiString)& aclass) const
+{
+ Handle(WOKUtils_HSequenceOfParamItem) result = new WOKUtils_HSequenceOfParamItem;
+
+ if(aclass.IsNull() || !IsValid()) return result;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ const WOKUtils_Param& prm = myEntity->Params();
+
+ prm.LoadParamClass(aclass->ToCString(),prm.SubClasses());
+
+ result = prm.GetClassValues(aclass->ToCString());
+
+ return result;
+}
+
+//=======================================================================
+//function : ParameterSearchList
+//purpose :
+//=======================================================================
+Handle(TColStd_HSequenceOfHAsciiString) WOKAPI_Entity::ParameterSearchList() const
+{
+ Handle(TColStd_HSequenceOfHAsciiString) result;
+
+ if(!IsValid()) return result;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ WOKUtils_Param prm = myEntity->Params();
+
+ Handle(TColStd_HSequenceOfAsciiString) alist = prm.SearchDirectories();
+ Standard_Integer i;
+
+ result = new TColStd_HSequenceOfHAsciiString;
+
+ for(i=1; i<=alist->Length(); i++)
+ {
+ result->Append(new TCollection_HAsciiString(alist->Value(i)));
+ }
+
+ return result;
+}
+
+
+//=======================================================================
+//function : ParameterClasses
+//purpose :
+//=======================================================================
+Handle(TColStd_HSequenceOfHAsciiString) WOKAPI_Entity::ParameterClasses() const
+{
+ if(!IsValid()) return Handle(TColStd_HSequenceOfHAsciiString)();
+ if(!myEntity->IsOpened()) myEntity->Open();
+ const WOKUtils_Param& params = myEntity->Params();
+ Handle(TColStd_HSequenceOfHAsciiString) result = new TColStd_HSequenceOfHAsciiString;
+ Handle(TColStd_HSequenceOfAsciiString) Classes = params.SubClasses();
+
+ if(!Classes.IsNull())
+ {
+ for(Standard_Integer i=1; i<=Classes->Length(); i++)
+ {
+ result->Append(new TCollection_HAsciiString(Classes->Value(i)));
+ }
+ }
+ return result;
+}
+
+//=======================================================================
+//function : ParameterClassFiles
+//purpose :
+//=======================================================================
+Handle(TColStd_HSequenceOfHAsciiString) WOKAPI_Entity::ParameterClassFiles(const Handle(TCollection_HAsciiString)& aclass) const
+{
+ Handle(TColStd_HSequenceOfHAsciiString) result = new TColStd_HSequenceOfHAsciiString;
+
+ if(!IsValid()) return Handle(TColStd_HSequenceOfHAsciiString)();
+ if(!myEntity->IsOpened()) myEntity->Open();
+ const WOKUtils_Param& params = myEntity->Params();
+
+ Handle(WOKUtils_Path) apath;
+
+ apath = params.VisiblePath(params.ClassFile(aclass->ToCString()));
+
+ if(!apath.IsNull())
+ {
+ result->Append(apath->Name());
+ }
+
+ Handle(TColStd_HSequenceOfAsciiString) Classes = params.SubClasses();
+
+ if(!Classes.IsNull())
+ {
+ for(Standard_Integer i=1; i<=Classes->Length(); i++)
+ {
+ Handle(TCollection_HAsciiString) afile = params.ClassSubFile(aclass->ToCString(),Classes->Value(i).ToCString());
+
+ apath = new WOKUtils_Path(afile);
+ if (apath->Exists())
+ {
+ result->Append(apath->Name());
+ }
+ }
+ }
+ return result;
+}
+
+//=======================================================================
+//function : FindParameterFile
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::FindParameterFile(const Handle(TCollection_HAsciiString)& afile) const
+{
+ Handle(TCollection_HAsciiString) NULLRESULT;
+
+ if(afile.IsNull() || !IsValid()) return NULLRESULT;
+
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKUtils_Path) apath = myEntity->Params().SearchFile(afile);
+ if(!apath.IsNull()) return apath->Name();
+ else return NULLRESULT;
+}
+
+//=======================================================================
+//function : ParameterSet
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::ParameterSet(const Handle(TCollection_HAsciiString)& aname,
+ const Handle(TCollection_HAsciiString)& avalue) const
+{
+ if(!IsValid() || aname.IsNull() || avalue.IsNull()) return;
+
+ if(aname->Value(1) != '%')
+ {
+ ErrorMsg << "WOKAPI_Entity::ParameterSet" << "Variable name must begin with %" << endm;
+ return;
+ }
+ if(!myEntity->IsOpened()) myEntity->Open();
+ myEntity->Params().Set(aname->ToCString(), avalue->ToCString());
+ return;
+}
+
+//=======================================================================
+//function : ParameterUnSet
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::ParameterUnSet(const Handle(TCollection_HAsciiString)& aname) const
+{
+ if(!IsValid() || aname.IsNull()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+ if(aname->Value(1) != '%')
+ {
+ ErrorMsg << "WOKAPI_Entity::ParameterUnSet" << "Variable name must begin with %" << endm;
+ return;
+ }
+
+ myEntity->Params().UnSet(aname->ToCString());
+ return;
+}
+
+//=======================================================================
+//function : ParameterReset
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::ParameterReset() const
+{
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+ myEntity->ChangeParams() = WOKUtils_Param();
+ myEntity->GetParams();
+}
+
+//=======================================================================
+//function : FileTypes
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::FileTypes(TColStd_SequenceOfHAsciiString& typeseq) const
+{
+ typeseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_FileTypeBase) abase = myEntity->FileTypeBase();
+
+ if(abase.IsNull()) return;
+
+ WOKernel_FileTypeIterator theit = abase->TypeIterator();
+
+ while(theit.More())
+ {
+ typeseq.Append(theit.Key());
+ theit.Next();
+ }
+ return;
+}
+
+//=======================================================================
+//function : GetFiles
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::GetFiles(TColStd_SequenceOfHAsciiString& fileseq) const
+{
+ fileseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_FileTypeBase) abase = myEntity->FileTypeBase();
+
+ if(abase.IsNull()) return;
+
+ Handle(WOKernel_Entity) nesting = myEntity->Session()->GetEntity(myEntity->Nesting());
+
+ Handle(TColStd_HSequenceOfHAsciiString) Kfileseq =
+ abase->GetFiles(myEntity,
+ myEntity->DBMSystems(), myEntity->Stations(), Standard_True);
+
+ if(!Kfileseq.IsNull())
+
+ for(Standard_Integer i=1; i<=Kfileseq->Length(); i++)
+ {
+ fileseq.Append(Kfileseq->Value(i));
+ }
+
+ return;
+}
+
+//=======================================================================
+//function : GetDirs
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::GetDirs(TColStd_SequenceOfHAsciiString& dirseq) const
+{
+ dirseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_FileTypeBase) abase = myEntity->FileTypeBase();
+
+ if(abase.IsNull()) return;
+
+ Handle(WOKernel_Entity) nesting = myEntity->Session()->GetEntity(myEntity->Nesting());
+
+ Handle(TColStd_HSequenceOfHAsciiString) Kdirseq =
+ abase->GetDirectories(myEntity, myEntity->DBMSystems(), myEntity->Stations(),Standard_True);
+
+ myEntity->Close();
+ myEntity->Open();
+
+ if(!Kdirseq.IsNull())
+
+ for(Standard_Integer i=1; i<=Kdirseq->Length(); i++)
+ {
+ dirseq.Append(Kdirseq->Value(i));
+ }
+
+ return;
+}
+//=======================================================================
+//function : CheckDirs
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::CheckDirs(const Standard_Boolean createifmissing, const Standard_Boolean besilent) const
+{
+ Standard_Boolean status = Standard_True;
+
+ if(!IsValid()) return Standard_False;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_FileTypeBase) abase = myEntity->FileTypeBase();
+
+ if(abase.IsNull()) return Standard_False;
+
+ Handle(WOKernel_Entity) nesting = myEntity->Session()->GetEntity(myEntity->Nesting());
+
+ Handle(WOKernel_HSequenceOfDBMSID) bd = new WOKernel_HSequenceOfDBMSID;
+ bd->Append(myEntity->Session()->DBMSystem());
+
+ Handle(WOKernel_HSequenceOfStationID) st = new WOKernel_HSequenceOfStationID;
+ st->Append(myEntity->Session()->Station());
+
+
+ Handle(TColStd_HSequenceOfHAsciiString) Kdirseq =
+ abase->GetDirectories(myEntity, bd, st,Standard_True);
+
+ myEntity->Close();
+ myEntity->Open();
+
+ if(!Kdirseq.IsNull())
+ for(Standard_Integer i=1; i<=Kdirseq->Length(); i++)
+ {
+ Handle(WOKUtils_Path) apath = new WOKUtils_Path(Kdirseq->Value(i));
+
+ if(!apath->IsDirectory())
+ {
+ if(!apath->Exists())
+ {
+ if(!besilent)
+ {
+ if(createifmissing)
+ {
+ WarningMsg << "WOKAPI_Entity::CheckDirs"
+ << "Creating missing directory " << Kdirseq->Value(i) << " in " << UserPath() << endm;
+ }
+ else
+ {
+ WarningMsg << "WOKAPI_Entity::CheckDirs"
+ << "Missing directory " << Kdirseq->Value(i) << " in " << UserPath() << endm;
+ }
+ }
+ if(createifmissing)
+ {
+ if(!apath->CreateDirectory(Standard_True))
+ status = Standard_False;
+ }
+ else
+ status = Standard_False;
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Entity::CheckDirs"
+ << Kdirseq->Value(i) << " exists and is not a directory" << endm;
+ status = Standard_False;
+ }
+ }
+ }
+
+ return status;
+}
+
+//=======================================================================
+//function : IsFileType
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsFileType(const Handle(TCollection_HAsciiString)& aname) const
+{
+ if(aname.IsNull() || !IsValid()) return Standard_False;
+ if(!myEntity->IsOpened()) myEntity->Open();
+ return !myEntity->GetFileType(aname).IsNull();
+}
+
+//=======================================================================
+//function : IsFileTypeFileDependent
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Entity::IsFileTypeFileDependent(const Handle(TCollection_HAsciiString)& aname) const
+{
+ if(aname.IsNull()) return Standard_False;
+ if(!IsValid()) return Standard_False;
+ if(!myEntity->IsOpened()) myEntity->Open();
+ Handle(WOKernel_FileType) afiletype = myEntity->GetFileType(aname);
+
+ if(afiletype.IsNull())
+ return Standard_False;
+ else
+ return (afiletype->IsFileDependent());
+}
+
+//=======================================================================
+//function : GetFileTypeDefinition
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::GetFileTypeDefinition(const Handle(TCollection_HAsciiString)& aname) const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(IsValid() && !aname.IsNull())
+ {
+ if(!myEntity->IsOpened()) myEntity->Open();
+ Handle(WOKernel_FileType) atype = myEntity->GetFileType(aname);
+ if(!atype.IsNull())
+ {
+ result = atype->GetDefinition();
+ }
+ }
+ return result;
+}
+
+//=======================================================================
+//function : GetFileTypeDirectory
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::GetFileTypeDirectory(const Handle(TCollection_HAsciiString)& aname) const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(IsValid() && !aname.IsNull())
+ {
+ if(!myEntity->IsOpened()) myEntity->Open();
+ if(IsFileType(aname))
+ {
+ Handle(WOKernel_FileType) atype = myEntity->GetFileType(aname);
+ if(!atype.IsNull())
+ {
+ result = atype->GetDirectory(myEntity->Params());
+ }
+ }
+ }
+ return result;
+}
+
+//=======================================================================
+//function : GetFileTypeArguments
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::GetFileTypeArguments(const Handle(TCollection_HAsciiString)& aname,
+ TColStd_SequenceOfHAsciiString& argseq) const
+{
+ argseq.Clear();
+
+ if(IsValid() && !aname.IsNull())
+ {
+ if(!myEntity->IsOpened()) myEntity->Open();
+ Handle(TColStd_HSequenceOfHAsciiString) aseq;
+ Handle(WOKernel_FileType) atype = myEntity->GetFileType(aname);
+
+ if(!atype.IsNull())
+ {
+ Standard_Integer i;
+
+ aseq = atype->GetArguments();
+
+ for(i=1; i<=aseq->Length(); i++)
+ {
+ argseq.Append(aseq->Value(i));
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : GetFilePath
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::GetFilePath(const Handle(TCollection_HAsciiString)& atype,
+ const Handle(TCollection_HAsciiString)& aname) const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(!IsValid() || aname.IsNull() || atype.IsNull()) return result;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_FileType) thetype = myEntity->GetFileType(atype);
+
+ if(!thetype.IsNull())
+ {
+ Handle(WOKernel_File) afile = new WOKernel_File(aname, myEntity, thetype);
+ afile->GetPath();
+ result = afile->Path()->Name();
+ }
+ return result;
+}
+
+
+//=======================================================================
+//function : GetFilePath
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Entity::GetFilePath(const Handle(TCollection_HAsciiString)& atype) const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(!IsValid() || atype.IsNull()) return result;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_FileType) thetype = myEntity->GetFileType(atype);
+
+ if(!thetype.IsNull())
+ {
+ Handle(WOKernel_File) afile = new WOKernel_File( myEntity, thetype);
+ afile->GetPath();
+ result = afile->Path()->Name();
+ }
+ return result;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetInterpFiles
+//purpose :
+//=======================================================================
+void WOKAPI_Entity::GetInterpFiles(Handle(WOKTools_HSequenceOfReturnValue)& scripts) const
+{
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ static Handle(TCollection_HAsciiString) admfile = new TCollection_HAsciiString("admfile");
+ Handle(TCollection_HAsciiString) script;
+ Handle(TCollection_HAsciiString) scrpath;
+ Handle(WOKUtils_Path) path;
+
+ if(scripts.IsNull()) scripts = new WOKTools_HSequenceOfReturnValue;
+
+ // CSHELL
+ script = WOKTools_InterpFileValue::FileName(WOKTools_CShell, Name());
+ scrpath = GetFilePath(admfile, script);
+
+ path = new WOKUtils_Path(scrpath);
+
+ if(path->Exists())
+ scripts->Append(new WOKTools_InterpFileValue(path->Name(), WOKTools_CShell));
+
+
+ // BOURNESHELL
+ script = WOKTools_InterpFileValue::FileName(WOKTools_BourneShell, Name());
+ scrpath = GetFilePath(admfile, script);
+
+ path = new WOKUtils_Path(scrpath);
+
+ if(path->Exists())
+ scripts->Append(new WOKTools_InterpFileValue(path->Name(), WOKTools_BourneShell));
+
+ // KornShell
+ script = WOKTools_InterpFileValue::FileName(WOKTools_KornShell, Name());
+ scrpath = GetFilePath(admfile, script);
+
+ path = new WOKUtils_Path(scrpath);
+
+ if(path->Exists())
+ scripts->Append(new WOKTools_InterpFileValue(path->Name(), WOKTools_KornShell));
+
+ // Tcl
+ script = WOKTools_InterpFileValue::FileName(WOKTools_TclInterp, Name());
+ scrpath = GetFilePath(admfile, script);
+
+ path = new WOKUtils_Path(scrpath);
+
+ if(path->Exists())
+ scripts->Append(new WOKTools_InterpFileValue(path->Name(), WOKTools_TclInterp));
+
+ // Emacs Lisp
+ script = WOKTools_InterpFileValue::FileName(WOKTools_EmacsLisp, Name());
+ scrpath = GetFilePath(admfile, script);
+
+ path = new WOKUtils_Path(scrpath);
+
+ if(path->Exists())
+ scripts->Append(new WOKTools_InterpFileValue(path->Name(), WOKTools_EmacsLisp));
+
+ // WNT
+ script = WOKTools_InterpFileValue::FileName(WOKTools_WNTCmd, Name());
+ scrpath = GetFilePath(admfile, script);
+
+ path = new WOKUtils_Path(scrpath);
+
+ if(path->Exists())
+ scripts->Append(new WOKTools_InterpFileValue(path->Name(), WOKTools_WNTCmd));
+
+ return;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetEnvActions
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Entity::GetEnvActions(const WOKAPI_Session& asession,
+ WOKTools_Return& returns) const
+{
+ WOKAPI_Factory thefact(asession,UserPath());
+
+ if(!thefact.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Entity::GetEnvActions"
+ << "Could not determine factory : Nothing done" << endm;
+ return 1;
+ }
+
+ WOKAPI_Workshop theshop(asession,UserPath());
+
+ if(!theshop.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Entity::GetEnvActions"
+ << "Could not determine workshop : Nothing done" << endm;
+ return 1;
+ }
+
+ WOKAPI_Workbench thebench(asession,UserPath());
+
+ if(!thebench.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Entity::GetEnvActions"
+ << "Could not determine workbench : Nothing done" << endm;
+ return 1;
+ }
+
+ WOKAPI_SequenceOfWorkbench ancestors;
+
+ thebench.Ancestors(ancestors);
+
+ returns.AddSetEnvironment("STATION", asession.Station()->ToCString());
+ returns.AddSetEnvironment("TARGET_DBMS", asession.DBMSystem()->ToCString());
+
+
+ WOKAPI_SequenceOfParcel parseq;
+ Standard_Integer i;
+
+ theshop.UsedParcels(parseq);
+
+ for(i=1; i<=parseq.Length(); i++)
+ {
+ const WOKAPI_Parcel& parcel = parseq.Value(i);
+
+ WOKAPI_Unit deliv;
+
+ parcel.Delivery(deliv);
+
+ static Handle(TCollection_HAsciiString) hometype = new TCollection_HAsciiString("HomeDir");
+
+ Handle(TCollection_HAsciiString) homedir = parcel.GetFilePath(hometype);
+
+ if(homedir.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Entity::GetEnvActions"
+ << "Could not determine HomeDir of parcel : " << parcel.UserPath() << endm;
+ return 1;
+ }
+
+ if(deliv.IsValid())
+ {
+ const WOKAPI_Unit& unit = deliv;
+
+ if(unit.IsValid())
+ {
+ Handle(TCollection_HAsciiString) pname = new TCollection_HAsciiString(unit.Name());
+
+ pname->UpperCase();
+ pname->AssignCat("HOME");
+
+ returns.AddSetEnvironment(pname, homedir);
+ }
+ }
+ }
+
+ // Calcul du Path
+ static Handle(TCollection_HAsciiString) pathparamname = new TCollection_HAsciiString("%ENV_PATH");
+ Handle(TCollection_HAsciiString) pathvarname = ParameterEval(pathparamname);
+
+ if(pathvarname.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Entity::GetEnvActions"
+ << "Could not eval %ENV_PATH (path environment variable name)" << endm;
+ return 1;
+ }
+
+ OSD_Environment PATH(pathvarname->String());
+ WOKTools_MapOfHAsciiString pathmap;
+ Handle(TCollection_HAsciiString) prev_pathvalue = new TCollection_HAsciiString(PATH.Value());
+
+ prev_pathvalue->ChangeAll('\\', '/');
+
+ if(PATH.Value().IsEmpty())
+ {
+ WarningMsg << "WOKAPI_Entity::GetEnvActions"
+ << "Environment variable " << pathvarname << " is not setted" << endm;
+ }
+ else
+ {
+ Handle(TCollection_HAsciiString) pathitem;
+
+ i=1;
+ pathitem = prev_pathvalue->Token(PATH_SEPARATOR,i);
+
+ while(!pathitem->IsEmpty())
+ {
+ if(!pathmap.Contains(pathitem))
+ pathmap.Add(pathitem);
+ i++;
+ pathitem = prev_pathvalue->Token(PATH_SEPARATOR,i);
+ }
+ }
+
+ // Calcul du LD_LIBRARY_PATH
+ static Handle(TCollection_HAsciiString) ldpathparamname = new TCollection_HAsciiString("%ENV_LDPATH");
+ Handle(TCollection_HAsciiString) ldpathvarname = ParameterEval(ldpathparamname);
+
+ ldpathvarname->ChangeAll('\\', '/');
+
+ if(ldpathvarname.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Entity::GetEnvActions"
+ << "Could not eval %ENV_LDPATH (library path environment variable name)" << endm;
+ return 1;
+ }
+
+ Standard_Boolean samevars = Standard_False;
+
+ if(!strcmp(ldpathvarname->ToCString(), pathvarname->ToCString()))
+ {
+ samevars = Standard_True;
+ }
+
+ OSD_Environment LDPATH(ldpathvarname->String());
+ WOKTools_MapOfHAsciiString ldmap;
+ Handle(TCollection_HAsciiString) prev_ldpathvalue = new TCollection_HAsciiString(LDPATH.Value());
+
+ if(LDPATH.Value().IsEmpty())
+ {
+ WarningMsg << "WOKAPI_Entity::GetEnvActions"
+ << "Environment variable " << ldpathvarname << " is not setted" << endm;
+ }
+ else if(!samevars)
+ {
+ Handle(TCollection_HAsciiString) lditem;
+
+ i=1;
+ lditem = prev_ldpathvalue->Token(PATH_SEPARATOR,i);
+
+ while(!lditem->IsEmpty())
+ {
+ if(!ldmap.Contains(lditem))
+ ldmap.Add(lditem);
+ i++;
+ lditem = prev_ldpathvalue->Token(PATH_SEPARATOR,i);
+ }
+ }
+
+ // Ajout des WBs au PATH et LD_LIBRARY_PATH
+ Handle(TCollection_HAsciiString) pathvalue = new TCollection_HAsciiString;
+ Handle(TCollection_HAsciiString) ldpathvalue = new TCollection_HAsciiString;
+
+ for(i=1; i<=ancestors.Length(); i++)
+ {
+ const WOKAPI_Workbench& anancestor = ancestors.Value(i);
+
+ if(anancestor.IsValid())
+ {
+ // pour l'instant j'ajoute le bin et le lib
+ static Handle(TCollection_HAsciiString) bindirtype = new TCollection_HAsciiString("bindir");
+ Handle(TCollection_HAsciiString) bindir = anancestor.GetFilePath(bindirtype);
+
+ Handle(WOKUtils_Path) binpath = new WOKUtils_Path(bindir);
+
+ WOKUtils_PathIterator anit(binpath);
+
+ if(!pathmap.Contains(binpath->Name()) && anit.More())
+ {
+ pathvalue->AssignCat(PATH_SEPARATOR);
+ pathvalue->AssignCat(binpath->Name());
+ pathmap.Add(binpath->Name());
+ }
+
+ static Handle(TCollection_HAsciiString) libdirtype = new TCollection_HAsciiString("libdir");
+ Handle(TCollection_HAsciiString) libdir = anancestor.GetFilePath(libdirtype);
+
+ Handle(WOKUtils_Path) libpath = new WOKUtils_Path(libdir);
+
+ if(!samevars)
+ {
+ WOKUtils_PathIterator anit(libpath);
+ if(!ldmap.Contains(libpath->Name()) && anit.More())
+ {
+ if (ldpathvalue->Length() > 0) {
+ ldpathvalue->AssignCat(PATH_SEPARATOR);
+ }
+ ldpathvalue->AssignCat(libpath->Name());
+ ldmap.Add(libpath->Name());
+ }
+ }
+ else
+ {
+ WOKUtils_PathIterator anit(libpath);
+ if(!pathmap.Contains(libpath->Name()) && anit.More())
+ {
+ pathvalue->AssignCat(PATH_SEPARATOR);
+ pathvalue->AssignCat(libpath->Name());
+ pathmap.Add(libpath->Name());
+ }
+ }
+
+ }
+ }
+
+ // Eventuel Ajout des ULs au PATH et LD_LIBRARY_PATH
+ for(i=1; i<=parseq.Length(); i++)
+ {
+ const WOKAPI_Parcel& parcel = parseq.Value(i);
+
+ if(parcel.IsValid())
+ {
+ // pour l'instant j'ajoute le bin et le lib
+ static Handle(TCollection_HAsciiString) libdirtype = new TCollection_HAsciiString("libdir");
+ Handle(TCollection_HAsciiString) libdir = parcel.GetFilePath(libdirtype);
+ // pour l'instant j'ajoute le bin et le lib
+ static Handle(TCollection_HAsciiString) bindirtype = new TCollection_HAsciiString("bindir");
+ Handle(TCollection_HAsciiString) dir = parcel.GetFilePath(bindirtype);
+
+ Handle(WOKUtils_Path) libpath = new WOKUtils_Path(libdir);
+ Handle(WOKUtils_Path) path = new WOKUtils_Path(dir);
+
+ WOKUtils_PathIterator alibit(libpath);
+ WOKUtils_PathIterator abinit(path);
+
+ if(!samevars)
+ {
+ if(!ldmap.Contains(libpath->Name()) && alibit.More())
+ {
+ if (ldpathvalue->Length() > 0) {
+ ldpathvalue->AssignCat(PATH_SEPARATOR);
+ }
+ ldpathvalue->AssignCat(libpath->Name());
+ ldmap.Add(libpath->Name());
+ }
+ }
+ else
+ {
+ if(!pathmap.Contains(libpath->Name()) && alibit.More())
+ {
+ pathvalue->AssignCat(PATH_SEPARATOR);
+ pathvalue->AssignCat(libpath->Name());
+ pathmap.Add(libpath->Name());
+ }
+ }
+
+ if(!pathmap.Contains(path->Name()) && abinit.More())
+ {
+ pathvalue->AssignCat(PATH_SEPARATOR);
+ pathvalue->AssignCat(path->Name());
+ pathmap.Add(path->Name());
+ }
+
+
+ }
+ }
+
+ ldpathvalue->AssignCat(PATH_SEPARATOR);
+ ldpathvalue->AssignCat(prev_ldpathvalue);
+
+ pathvalue->AssignCat(PATH_SEPARATOR);
+ pathvalue->AssignCat(prev_pathvalue);
+
+
+
+ if(!samevars) returns.AddSetEnvironment(ldpathvarname, ldpathvalue);
+
+ returns.AddSetEnvironment(pathvarname, pathvalue);
+
+ // C'est fini pour les setenvs : commencer les source Toto.csh
+
+ Handle(WOKTools_HSequenceOfReturnValue) values = returns.Values();
+
+ thefact.GetInterpFiles(values);
+ theshop.GetInterpFiles(values);
+
+ for(i=1; i<=parseq.Length(); i++)
+ {
+ WOKAPI_Unit delivery;
+
+ parseq.Value(i).Delivery(delivery);
+
+ delivery.GetInterpFiles(values);
+ }
+
+ for(i=ancestors.Length(); i>=1; i--)
+ {
+ ancestors.Value(i).GetInterpFiles(values);
+ }
+
+ return 0;
+}
+
+
+Standard_Boolean WOKAPI_Entity::HomePage(const Standard_OStream& astream) const
+{
+ return Standard_True;
+}
+
+Standard_Boolean WOKAPI_Entity::ItemHRef(const Standard_OStream& astream) const
+{
+ return Standard_True;
+}
+
+Standard_Boolean WOKAPI_Entity::PageHeader(const Standard_OStream& astream) const
+{
+ return Standard_True;
+}
+
+Standard_Boolean WOKAPI_Entity::PageFooter(const Standard_OStream& astream) const
+{
+ return Standard_True;
+}
--- /dev/null
+// File: WOKAPI_Entity.lxx
+// Created: Thu Oct 2 13:59:48 1997
+// Author: Jean GAUTIER
+// <jga@hourax.paris1.matra-dtv.fr>
+
+//=======================================================================
+//function : Entity
+//purpose :
+//=======================================================================
+const Handle(WOKernel_Entity)& WOKAPI_Entity::Entity() const
+{
+ return myEntity;
+}
+
--- /dev/null
+-- File: WOKAPI_Factory.cdl
+-- Created: Tue Aug 1 15:54:41 1995
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1995
+
+
+class Factory from WOKAPI
+inherits Entity from WOKAPI
+
+ ---Purpose:
+
+uses
+
+ Session from WOKAPI,
+ Warehouse from WOKAPI,
+ Workshop from WOKAPI,
+ SequenceOfWorkshop from WOKAPI,
+ SequenceOfEntity from WOKAPI,
+ Factory from WOKernel,
+ HSequenceOfParamItem from WOKUtils,
+ ArgTable from WOKTools,
+ Return from WOKTools,
+ HSequenceOfDefine from WOKTools,
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd
+
+is
+
+ Create returns Factory from WOKAPI;
+
+ Create(aent : Entity from WOKAPI)
+ returns Factory from WOKAPI;
+
+ Create(asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ verbose,getit : Boolean from Standard = Standard_True)
+ returns Factory from WOKAPI;
+
+
+ BuildParameters(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns HSequenceOfParamItem from WOKUtils;
+
+ Build(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns Boolean from Standard;
+
+ Destroy(me:out)
+ returns Boolean from Standard
+ is redefined;
+
+ IsValid(me)
+ returns Boolean from Standard
+ is redefined;
+
+ NestedEntities(me; aseq : out SequenceOfEntity from WOKAPI)
+ returns Boolean from Standard
+ is redefined;
+
+ Workshops(me; shopseq : out SequenceOfWorkshop from WOKAPI);
+
+ Warehouse(me)
+ returns Warehouse from WOKAPI;
+
+end Factory;
+
+
+
--- /dev/null
+// File: WOKAPI_Factory.cxx
+// Created: Tue Aug 1 18:52:43 1995
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+#include <Standard_ErrorHandler.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Messages.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+
+#include <WOKUtils_Path.hxx>
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKernel_Session.hxx>
+#include <WOKernel_Factory.hxx>
+#include <WOKernel_Workshop.hxx>
+#include <WOKernel_Warehouse.hxx>
+
+#include <WOKAPI_Session.hxx>
+#include <WOKAPI_Workshop.hxx>
+#include <WOKAPI_SequenceOfWorkshop.hxx>
+
+#include <WOKAPI_Factory.ixx>
+
+
+//=======================================================================
+//function : WOKAPI_Factory
+//purpose :
+//=======================================================================
+WOKAPI_Factory::WOKAPI_Factory()
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Factory
+//purpose :
+//=======================================================================
+WOKAPI_Factory::WOKAPI_Factory(const WOKAPI_Entity& anent)
+ : WOKAPI_Entity(anent)
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Factory
+//purpose :
+//=======================================================================
+WOKAPI_Factory::WOKAPI_Factory(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal, const Standard_Boolean getit)
+{
+ Set(asession.GetFactory(apath,fatal,getit));
+}
+
+//=======================================================================
+//function : Build
+//purpose :
+//=======================================================================
+Handle(WOKUtils_HSequenceOfParamItem) WOKAPI_Factory::BuildParameters(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+{
+ Handle(TCollection_HAsciiString) name;
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+
+ name = BuildName(apath);
+
+ Handle(WOKernel_Factory) Kfact = new WOKernel_Factory(name, asession.Session());
+
+ Set(Kfact);
+
+ aseq = GetBuildParameters(asession, name, asession, defines, usedefaults);
+
+ return aseq;
+}
+
+//=======================================================================
+//function : Build
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Factory::Build(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+
+{
+ Handle(TCollection_HAsciiString) name;
+ Handle(WOKernel_Session) Ksession = Handle(WOKernel_Session)::DownCast(asession.Entity());
+
+ name = BuildName(apath);
+
+ if(!asession.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Factory::Build"
+ << "Invalid session to create factory : " << name << endm;
+ return Standard_True;
+ }
+ Handle(WOKernel_Factory) Kfact = new WOKernel_Factory(name, Ksession);
+
+ Set(Kfact);
+
+ if(!BuildEntity(asession, name, asession, defines, usedefaults))
+ {
+ Ksession->AddFactory(Kfact);
+ Kfact->Open();
+ }
+ else return Standard_True;
+ return Standard_False;
+}
+
+//=======================================================================
+//function : Destroy
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Factory::Destroy()
+{
+ if(!IsValid()) return Standard_True;
+
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Factory) afact = Handle(WOKernel_Factory)::DownCast(myEntity);
+ Handle(WOKernel_Session) asession = afact->Session();
+
+ if(afact->Workshops()->Length())
+ {
+ ErrorMsg << "WOKAPI_Factory::Destroy"
+ << "Cannot destroy not empty factory" << endm;
+ return Standard_True;
+ }
+
+ afact->Destroy();
+
+ asession->RemoveFactory(afact);
+ myEntity.Nullify();
+ return Standard_False;
+}
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Factory::IsValid() const
+{
+ if(myEntity.IsNull()) return Standard_False;
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Factory));
+}
+
+//=======================================================================
+//function : NestedEntities
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Factory::NestedEntities(WOKAPI_SequenceOfEntity& aseq) const
+{
+ if(!IsValid()) return Standard_False;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ aseq.Clear();
+
+ Handle(WOKernel_Factory) afact = Handle(WOKernel_Factory)::DownCast(myEntity);
+ Handle(WOKernel_Workshop) ashop;
+ Handle(WOKernel_Session) asession;
+ Handle(TCollection_HAsciiString) astr;
+ Handle(TColStd_HSequenceOfHAsciiString) aKseq;
+ Standard_Integer len, i;
+
+ asession = afact->Session();
+ aKseq = afact->Workshops();
+ len = aKseq->Length();
+
+ WOKAPI_Workshop apishop;
+
+ for(i=1; i<=len; i++)
+ {
+ astr = aKseq->Value(i);
+
+ apishop.Set(asession->GetWorkshop(astr));
+
+ aseq.Append(apishop);
+ }
+ return Standard_True;
+}
+
+
+//=======================================================================
+//function : Workshops
+//purpose :
+//=======================================================================
+void WOKAPI_Factory::Workshops(WOKAPI_SequenceOfWorkshop& shopseq) const
+{
+
+ shopseq.Clear();
+
+ if(IsValid())
+ {
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Factory) afact = Handle(WOKernel_Factory)::DownCast(myEntity);
+ Handle(WOKernel_Workshop) ashop;
+ Handle(WOKernel_Session) asession;
+ Handle(TCollection_HAsciiString) astr;
+ Handle(TColStd_HSequenceOfHAsciiString) aseq;
+ Standard_Integer len, i;
+
+ asession = afact->Session();
+ aseq = afact->Workshops();
+ len = aseq->Length();
+
+
+ WOKAPI_Workshop apishop;
+
+ for(i=1; i<=len; i++)
+ {
+ astr = aseq->Value(i);
+
+ apishop.Set(asession->GetWorkshop(astr));
+
+ shopseq.Append(apishop);
+ }
+ }
+ return;
+}
+
+//=======================================================================
+//function : Warehouse
+//purpose :
+//=======================================================================
+WOKAPI_Warehouse WOKAPI_Factory::Warehouse() const
+{
+ WOKAPI_Warehouse aware;
+
+ if(IsValid())
+ {
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Warehouse) KWare;
+ Handle(WOKernel_Factory) afact = Handle(WOKernel_Factory)::DownCast(myEntity);
+ Handle(WOKernel_Session) asession = afact->Session();
+
+ aware.Set(asession->GetWarehouse(afact->Warehouse()));
+ }
+ return aware;
+}
--- /dev/null
+-- File: WOKAPI_File.cdl
+-- Created: Wed Apr 3 22:47:41 1996
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1996
+
+
+class File from WOKAPI
+
+ ---Purpose:
+
+uses
+ Entity from WOKAPI,
+ Locator from WOKAPI,
+ File from WOKernel,
+ HAsciiString from TCollection
+
+is
+
+ Create returns File from WOKAPI;
+
+ NestingEntity(me)
+ returns Entity from WOKAPI;
+
+ Type(me)
+ returns HAsciiString from TCollection;
+
+ Name(me)
+ returns HAsciiString from TCollection;
+
+ LocatorName(me)
+ returns HAsciiString from TCollection;
+
+ UserPath(me)
+ returns HAsciiString from TCollection;
+
+ Exists(me)
+ returns Boolean from Standard;
+
+ IsLocalTo(me; aent : Entity from WOKAPI)
+ returns Boolean from Standard;
+
+ IsFile(me)
+ returns Boolean from Standard;
+
+ IsDirectory(me)
+ returns Boolean from Standard;
+
+ IsValid(me)
+ returns Boolean from Standard;
+
+ IsLocated(me)
+ returns Boolean from Standard;
+
+ IsDBMSDependent(me)
+ returns Boolean from Standard;
+
+ IsStationDependent(me)
+ returns Boolean from Standard;
+
+ Path(me)
+ returns HAsciiString from TCollection;
+
+ Locate(me:out; alocator : Locator from WOKAPI);
+
+ Located(me:out);
+ UnLocated(me:out);
+
+ ---- UNIT PRIVATE METHODS
+
+ Set(me:out; afile : File from WOKernel)
+ is private;
+
+
+fields
+
+ myfile : File from WOKernel;
+ mylocated : Boolean from Standard;
+
+friends
+
+ class Unit from WOKAPI,
+ class Session from WOKAPI,
+ class Entity from WOKAPI,
+ class Locator from WOKAPI
+
+end File;
--- /dev/null
+// File: WOKAPI_File.cxx
+// Created: Wed Apr 3 23:01:03 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+#include <WOKUtils_Path.hxx>
+
+#include <WOKernel_FileType.hxx>
+#include <WOKernel_File.hxx>
+#include <WOKernel_Session.hxx>
+
+#include <WOKAPI_Entity.hxx>
+
+#include <WOKAPI_File.ixx>
+
+//=======================================================================
+//function : WOKAPI_File
+//purpose :
+//=======================================================================
+ WOKAPI_File::WOKAPI_File()
+ : mylocated(Standard_False)
+{
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+void WOKAPI_File::Set(const Handle(WOKernel_File)& afile)
+{
+ myfile = afile;
+ mylocated = Standard_False;
+}
+
+//=======================================================================
+//function : NestingEntity
+//purpose :
+//=======================================================================
+WOKAPI_Entity WOKAPI_File::NestingEntity() const
+{
+ WOKAPI_Entity result;
+
+ if(myfile.IsNull()) return result;
+
+ Handle(WOKernel_Entity) thenesting = myfile->Session()->GetEntity(myfile->Nesting());
+
+ if(!thenesting.IsNull())
+ {
+ result.Set(thenesting);
+ }
+ return result;
+}
+
+//=======================================================================
+//function : Type
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_File::Type() const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(myfile.IsNull()) return result;
+
+ result = myfile->TypeName();
+ return result;
+}
+
+//=======================================================================
+//function : Name
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_File::Name() const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(myfile.IsNull()) return result;
+
+ result = myfile->Name();
+ return result;
+}
+
+//=======================================================================
+//function : LocatorName
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_File::LocatorName() const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(myfile.IsNull()) return result;
+
+ result = myfile->LocatorName();
+ return result;
+}
+
+//=======================================================================
+//function : UserPath
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_File::UserPath() const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(myfile.IsNull()) return result;
+
+ result = myfile->UserPathName();
+ return result;
+}
+
+//=======================================================================
+//function : Exists
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_File::Exists() const
+{
+ if(myfile.IsNull()) return Standard_False;
+ myfile->GetPath();
+ return myfile->Path()->Exists();
+}
+
+//=======================================================================
+//function : IsLocalTo
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_File::IsLocalTo(const WOKAPI_Entity& aent) const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(myfile.IsNull()) return Standard_False;
+
+ if(NestingEntity().UserPath()->IsSameString(aent.UserPath())) return Standard_True;
+ else return Standard_False;
+}
+
+//=======================================================================
+//function : IsFile
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_File::IsFile() const
+{
+ if(myfile.IsNull()) return Standard_False;
+
+ return myfile->Type()->IsFile();
+}
+
+//=======================================================================
+//function : IsDirectory
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_File::IsDirectory() const
+{
+ if(myfile.IsNull()) return Standard_False;
+
+ return myfile->Type()->IsDirectory();
+}
+
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_File::IsValid() const
+{
+ if(myfile.IsNull()) return Standard_False;
+ return Standard_True;
+}
+
+//=======================================================================
+//function : IsDirectory
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_File::IsLocated() const
+{
+ if(myfile.IsNull()) return Standard_False;
+
+ return mylocated;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : IsDBMSDependent
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_File::IsDBMSDependent() const
+{
+ if(myfile.IsNull()) return Standard_False;
+
+ const Handle(WOKernel_FileType)& atype = myfile->Type();
+
+ if(atype.IsNull()) return Standard_False;
+
+ return atype->IsDBMSDependent();
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : IsStationDependent
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_File::IsStationDependent() const
+{
+ if(myfile.IsNull()) return Standard_False;
+
+ const Handle(WOKernel_FileType)& atype = myfile->Type();
+
+ if(atype.IsNull()) return Standard_False;
+
+ return atype->IsStationDependent();
+}
+
+//=======================================================================
+//function : Path
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_File::Path() const
+{
+ Handle(TCollection_HAsciiString) path;
+ if(myfile.IsNull()) return path;
+ if(myfile->Path().IsNull()) return path;
+ return myfile->Path()->Name();
+}
+
+//=======================================================================
+//function : Locate
+//purpose :
+//=======================================================================
+void WOKAPI_File::Locate(const WOKAPI_Locator& alocator)
+{
+ if(!alocator.IsValid()) {mylocated=Standard_False; return;}
+
+ if(!IsValid()) {mylocated=Standard_False; return;}
+ if(IsLocated()) return;
+
+ alocator.Locate(*this);
+}
+
+//=======================================================================
+//function : Located
+//purpose :
+//=======================================================================
+void WOKAPI_File::Located()
+{
+ mylocated=Standard_True;
+}
+
+//=======================================================================
+//function : UnLocated
+//purpose :
+//=======================================================================
+void WOKAPI_File::UnLocated()
+{
+ mylocated=Standard_False;
+}
--- /dev/null
+-- File: WOKAPI_Locator.cdl
+-- Created: Wed Apr 10 20:40:57 1996
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1996
+
+
+class Locator from WOKAPI
+
+ ---Purpose:
+
+uses
+ Entity from WOKAPI,
+ Workbench from WOKAPI,
+ Unit from WOKAPI,
+ File from WOKAPI,
+ Session from WOKAPI,
+ Locator from WOKernel,
+ HSequenceOfHAsciiString from TColStd,
+ HAsciiString from TCollection
+
+is
+
+ Create returns Locator from WOKAPI;
+
+ Create(alocator : Locator from WOKernel) returns Locator from WOKAPI;
+
+ IsValid(me) returns Boolean from Standard;
+
+ Set(me:out; alocator : Locator from WOKernel);
+ Set(me:out; awb : Workbench from WOKAPI);
+ Set(me:out; asession : Session from WOKAPI; avisibility : HSequenceOfHAsciiString from TColStd);
+
+ Reset(me);
+ Check(me);
+
+ Locator(me)
+ returns Locator from WOKernel;
+
+ Locate(me; alocatorname : HAsciiString from TCollection)
+ returns File from WOKAPI;
+
+ Locate(me; anent : Entity from WOKAPI; atype, aname : HAsciiString from TCollection)
+ returns File from WOKAPI;
+
+ Locate(me; anent : Entity from WOKAPI; atype : HAsciiString from TCollection)
+ returns File from WOKAPI;
+
+ Locate(me; afile : out File from WOKAPI);
+
+ LocateUnit(me; alocatorname : HAsciiString from TCollection)
+ returns Unit from WOKAPI;
+
+fields
+
+ mylocator : Locator from WOKernel;
+
+end Locator;
--- /dev/null
+// File: WOKAPI_Locator.cxx
+// Created: Wed Apr 10 20:51:58 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+
+#include <WOKernel_Entity.hxx>
+#include <WOKernel_File.hxx>
+
+#include <WOKAPI_Entity.hxx>
+#include <WOKAPI_File.hxx>
+
+#include <WOKAPI_Locator.ixx>
+
+//=======================================================================
+//function : WOKAPI_Locator
+//purpose :
+//=======================================================================
+WOKAPI_Locator::WOKAPI_Locator()
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Locator
+//purpose :
+//=======================================================================
+WOKAPI_Locator::WOKAPI_Locator(const Handle(WOKernel_Locator)& alocator)
+{
+ mylocator = alocator;
+}
+
+
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+void WOKAPI_Locator::Set(const WOKAPI_Workbench& awb)
+{
+ if(awb.IsValid())
+ mylocator = new WOKernel_Locator(Handle(WOKernel_Workbench)::DownCast(awb.Entity()));
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+void WOKAPI_Locator::Set(const WOKAPI_Session& asession,
+ const Handle(TColStd_HSequenceOfHAsciiString)& avisibility)
+{
+ Handle(TColStd_HSequenceOfHAsciiString) thevisibility = new TColStd_HSequenceOfHAsciiString;
+ Standard_Integer i;
+
+ if(!asession.IsValid()) return;
+
+ for(i=1; i<=avisibility->Length(); i++)
+ {
+ WOKAPI_Entity anent(asession,avisibility->Value(i));
+
+ if(anent.IsValid())
+ {
+ thevisibility->Append(anent.UserPath());
+ }
+ else return;
+ }
+ mylocator = new WOKernel_Locator(asession.Session(), thevisibility);
+ return;
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+void WOKAPI_Locator::Set(const Handle(WOKernel_Locator)& alocator)
+{
+ mylocator = alocator;
+}
+
+Handle(WOKernel_Locator) WOKAPI_Locator::Locator() const
+{
+ return mylocator;
+}
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Locator::IsValid() const
+{
+ return !mylocator.IsNull();
+}
+
+//=======================================================================
+//function : Reset
+//purpose :
+//=======================================================================
+void WOKAPI_Locator::Reset() const
+{
+ if(IsValid()) mylocator->Reset();
+}
+
+//=======================================================================
+//function : Check
+//purpose :
+//=======================================================================
+void WOKAPI_Locator::Check() const
+{
+ if(IsValid()) mylocator->Check();
+}
+
+//=======================================================================
+//function : Locate
+//purpose :
+//=======================================================================
+WOKAPI_File WOKAPI_Locator::Locate(const Handle(TCollection_HAsciiString)& alocatorname) const
+{
+ WOKAPI_File afile;
+
+ if(!IsValid()) return afile ;
+ else afile.Set(mylocator->Locate(alocatorname));
+ if(afile.IsValid()) afile.Located();
+ return afile;
+}
+
+//=======================================================================
+//function : Locate
+//purpose :
+//=======================================================================
+WOKAPI_File WOKAPI_Locator::Locate(const WOKAPI_Entity& anent,
+ const Handle(TCollection_HAsciiString)& atype,
+ const Handle(TCollection_HAsciiString)& aname) const
+{
+ WOKAPI_File afile;
+ if(IsValid())
+ afile.Set(mylocator->Locate(anent.Name(), atype, aname));
+ if(afile.IsValid()) afile.Located();
+ return afile;
+}
+
+//=======================================================================
+//function : Locate
+//purpose :
+//=======================================================================
+WOKAPI_File WOKAPI_Locator::Locate(const WOKAPI_Entity& anent,
+ const Handle(TCollection_HAsciiString)& atype) const
+{
+ WOKAPI_File afile;
+ if(IsValid())
+ afile.Set(mylocator->Locate(anent.Name(), atype, Handle(TCollection_HAsciiString)()));
+ if(afile.IsValid()) afile.Located();
+ return afile;
+}
+
+//=======================================================================
+//function : Locate
+//purpose :
+//=======================================================================
+void WOKAPI_Locator::Locate(WOKAPI_File& file) const
+{
+ Handle(WOKernel_File) afile;
+
+ if(!file.IsValid()) return;
+
+ if(IsValid())
+ afile = mylocator->Locate(file.NestingEntity().Name(), file.Type(), file.Name());
+
+ if(!afile.IsNull())
+ {
+ file.Set(afile);
+ file.Located();
+ }
+ return;
+}
+
+//=======================================================================
+//function : LocateUnit
+//purpose :
+//=======================================================================
+WOKAPI_Unit WOKAPI_Locator::LocateUnit(const Handle(TCollection_HAsciiString)& aunitname) const
+{
+ WOKAPI_Unit aunit;
+
+ if(IsValid())
+ aunit.Set(mylocator->LocateDevUnit(aunitname));
+ return aunit;
+}
+
--- /dev/null
+-- File: WOKAPI_MakeOption.cdl
+-- Created: Sat Apr 13 00:38:56 1996
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1996
+
+
+class MakeOption from WOKAPI
+
+ ---Purpose:
+
+uses
+ StepType from WOKAPI,
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd
+
+is
+
+ Create returns MakeOption from WOKAPI;
+
+ Create(another : MakeOption from WOKAPI) returns MakeOption from WOKAPI;
+
+ Create( acode : HAsciiString from TCollection;
+ atype : StepType from WOKAPI;
+ targets : HSequenceOfHAsciiString from TColStd;
+ isforced : Boolean from Standard)
+ returns MakeOption from WOKAPI;
+
+ Create( acode : HAsciiString from TCollection;
+ atype : StepType from WOKAPI;
+ targets : HSequenceOfHAsciiString from TColStd;
+ isforced : Boolean from Standard;
+ platforms : HSequenceOfHAsciiString from TColStd)
+ returns MakeOption from WOKAPI;
+
+ Code(me)
+ returns HAsciiString from TCollection;
+ SetCode(me:out; acode : HAsciiString from TCollection);
+
+ Type(me)
+ returns StepType from WOKAPI;
+ SetType(me:out; atype : StepType from WOKAPI);
+
+ Targets(me)
+ returns HSequenceOfHAsciiString from TColStd;
+ SetTargets(me:out; target : HSequenceOfHAsciiString from TColStd);
+
+ IsForced(me)
+ returns Boolean from Standard;
+ SetForce(me:out; aflg : Boolean from Standard);
+
+ Platforms(me)
+ returns HSequenceOfHAsciiString from TColStd;
+ SetPlatforms(me:out; platform : HSequenceOfHAsciiString from TColStd);
+
+fields
+
+ mycode : HAsciiString from TCollection;
+ myforce : Boolean from Standard;
+ mytype : StepType from WOKAPI;
+ mytargets : HSequenceOfHAsciiString from TColStd;
+ myplatforms : HSequenceOfHAsciiString from TColStd;
+
+end MakeOption;
+
+
+
--- /dev/null
+// File: WOKAPI_MakeOption.cxx
+// Created: Sat Apr 13 01:43:03 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+#include <WOKAPI_MakeOption.ixx>
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : WOKAPI_MakeOption
+//purpose :
+//=======================================================================
+WOKAPI_MakeOption::WOKAPI_MakeOption()
+ : myforce(Standard_False), mytype(WOKAPI_None)
+{
+}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : WOKAPI_MakeOption
+//purpose :
+//=======================================================================
+WOKAPI_MakeOption::WOKAPI_MakeOption(const WOKAPI_MakeOption& another)
+ : mycode(another.Code()), mytype(another.Type()), mytargets(another.Targets()), myforce(another.IsForced()), myplatforms(another.Platforms())
+{
+}
+//=======================================================================
+//function : WOKAPI_MakeOption
+//purpose :
+//=======================================================================
+WOKAPI_MakeOption::WOKAPI_MakeOption(const Handle(TCollection_HAsciiString)& astr,
+ const WOKAPI_StepType atype,
+ const Handle(TColStd_HSequenceOfHAsciiString)& targets,
+ const Standard_Boolean forced)
+ : mycode(astr), mytype(atype), mytargets(targets), myforce(forced)
+{
+}
+//=======================================================================
+//function : WOKAPI_MakeOption
+//purpose :
+//=======================================================================
+WOKAPI_MakeOption::WOKAPI_MakeOption(const Handle(TCollection_HAsciiString)& astr,
+ const WOKAPI_StepType atype,
+ const Handle(TColStd_HSequenceOfHAsciiString)& targets,
+ const Standard_Boolean forced,
+ const Handle(TColStd_HSequenceOfHAsciiString) & platforms)
+ : mycode(astr), mytype(atype), mytargets(targets), myforce(forced),myplatforms(platforms)
+{
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Code
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_MakeOption::Code() const {return mycode;}
+
+void WOKAPI_MakeOption::SetCode(const Handle(TCollection_HAsciiString)& acode) {mycode = acode;}
+
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Type
+//purpose :
+//=======================================================================
+WOKAPI_StepType WOKAPI_MakeOption::Type() const {return mytype;}
+
+void WOKAPI_MakeOption::SetType(const WOKAPI_StepType atype) {mytype = atype;}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Targets
+//purpose :
+//=======================================================================
+Handle(TColStd_HSequenceOfHAsciiString) WOKAPI_MakeOption::Targets() const {return mytargets;}
+
+void WOKAPI_MakeOption::SetTargets(const Handle(TColStd_HSequenceOfHAsciiString)& targets ) {mytargets = targets;}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : IsForced
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_MakeOption::IsForced() const {return myforce;}
+
+void WOKAPI_MakeOption::SetForce(const Standard_Boolean aflg) {myforce = aflg;}
+
+//=======================================================================
+//function : Platforms
+//purpose :
+//=======================================================================
+Handle(TColStd_HSequenceOfHAsciiString) WOKAPI_MakeOption::Platforms() const {return myplatforms;}
+
+void WOKAPI_MakeOption::SetPlatforms(const Handle(TColStd_HSequenceOfHAsciiString)& platforms ) {myplatforms = platforms;}
+
+
+
+
+
--- /dev/null
+-- File: WOKAPI_MakeStep.cdl
+-- Created: Wed Apr 3 22:51:15 1996
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1996
+
+
+class MakeStep from WOKAPI
+
+ ---Purpose:
+
+uses
+ Step from WOKMake,
+ SequenceOfFile from WOKAPI,
+ HAsciiString from TCollection
+
+is
+
+ Create returns MakeStep from WOKAPI;
+
+ IsToExecute(me)
+ returns Boolean from Standard;
+
+ UniqueName(me)
+ returns HAsciiString from TCollection;
+
+ Code(me)
+ returns HAsciiString from TCollection;
+
+ Input(me; aseq : out SequenceOfFile from WOKAPI)
+ returns Integer from Standard;
+
+ Output(me; aseq : out SequenceOfFile from WOKAPI)
+ returns Integer from Standard;
+
+ --- MakeStep PRIVATE methods
+
+ Set(me:out; atep : Step from WOKMake)
+ is private;
+
+
+
+fields
+
+ mystep : Step from WOKMake;
+
+friends
+
+ class BuildProcess from WOKAPI
+
+end MakeStep;
--- /dev/null
+// File: WOKAPI_MakeStep.cxx
+// Created: Wed Apr 3 23:10:10 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+#include <WOKMake_Step.hxx>
+
+#include <WOKAPI_MakeStep.ixx>
+
+//=======================================================================
+//function : WOKAPI_MakeStep
+//purpose :
+//=======================================================================
+WOKAPI_MakeStep::WOKAPI_MakeStep()
+{
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+void WOKAPI_MakeStep::Set(const Handle(WOKMake_Step)& atep)
+{
+ mystep = atep;
+}
+
+//=======================================================================
+//function : IsToExecute
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_MakeStep::IsToExecute() const
+{
+ if(mystep.IsNull()) return Standard_False;
+ return mystep->IsToExecute();
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Code
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_MakeStep::Code() const
+{
+ Handle(TCollection_HAsciiString) result;
+ if(!mystep.IsNull())
+ {
+ result = mystep->Code();
+ }
+ return result;
+}
+
+
+//=======================================================================
+//function : UniqueName
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_MakeStep::UniqueName() const
+{
+ Handle(TCollection_HAsciiString) result;
+ if(!mystep.IsNull())
+ {
+ result = mystep->UniqueName();
+ }
+ return result;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Input
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_MakeStep::Input(WOKAPI_SequenceOfFile& aseq) const
+{
+ if(mystep.IsNull()) return 1;
+
+ Handle(WOKMake_HSequenceOfInputFile) tmp;
+
+ return 0;
+}
--- /dev/null
+-- File: WOKAPI_Parcel.cdl
+-- Created: Wed Apr 3 16:40:52 1996
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1996
+
+
+class Parcel from WOKAPI
+inherits Entity from WOKAPI
+
+ ---Purpose:
+
+uses
+ Parcel from WOKernel,
+ Unit from WOKAPI,
+ Session from WOKAPI,
+ Entity from WOKAPI,
+ SequenceOfUnit from WOKAPI,
+ SequenceOfEntity from WOKAPI,
+ HSequenceOfDefine from WOKTools,
+ HSequenceOfParamItem from WOKUtils,
+ HAsciiString from TCollection
+
+is
+
+ Create returns Parcel from WOKAPI;
+
+ Create(aent : Entity from WOKAPI)
+ returns Parcel from WOKAPI;
+
+ Create(asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ verbose,getit : Boolean from Standard = Standard_True)
+ returns Parcel from WOKAPI;
+
+ BuildParameters(me; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns HSequenceOfParamItem from WOKUtils;
+
+ Declare(me: in out; asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ anesting : Entity from WOKAPI;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns Boolean;
+
+ Delivery(me; unit : out Unit from WOKAPI);
+
+ NestedEntities(me; aseq : out SequenceOfEntity from WOKAPI)
+ returns Boolean from Standard
+ is redefined;
+
+ Units(me; unitseq : out SequenceOfUnit from WOKAPI);
+
+ IsValid(me)
+ returns Boolean from Standard
+ is redefined;
+
+end Parcel;
--- /dev/null
+// File: WOKAPI_Parcel.cxx
+// Created: Wed Apr 3 19:33:58 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Messages.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKernel_Warehouse.hxx>
+#include <WOKernel_Parcel.hxx>
+#include <WOKernel_Session.hxx>
+#include <WOKernel_DevUnit.hxx>
+#include <WOKernel_BasicUnitTypes.hxx>
+
+#include <WOKAPI_Unit.hxx>
+#include <WOKAPI_SequenceOfUnit.hxx>
+
+#include <WOKAPI_Parcel.ixx>
+
+//=======================================================================
+//function : WOKAPI_Parcel
+//purpose :
+//=======================================================================
+WOKAPI_Parcel::WOKAPI_Parcel()
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Parcel
+//purpose :
+//=======================================================================
+WOKAPI_Parcel::WOKAPI_Parcel(const WOKAPI_Entity& anent)
+ : WOKAPI_Entity(anent)
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Parcel
+//purpose :
+//=======================================================================
+WOKAPI_Parcel::WOKAPI_Parcel(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal, const Standard_Boolean getit)
+{
+ Set(asession.GetParcel(apath,fatal,getit));
+}
+
+//=======================================================================
+//function : BuildParameters
+//purpose :
+//=======================================================================
+Handle(WOKUtils_HSequenceOfParamItem) WOKAPI_Parcel::BuildParameters(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults) const
+{
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Entity anesting(asession, nestname);
+
+ if (!anesting.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Parcel::BuildParameters"
+ << "Invalid nesting to create parcel : " << name << endm;
+ return aseq;
+ }
+
+ if (myEntity.IsNull())
+ {
+ Handle(WOKernel_Parcel) aparc = new WOKernel_Parcel(name,
+ Handle(WOKernel_Warehouse)::DownCast(anesting.Entity()));
+ Handle(TCollection_HAsciiString) aprefix = new TCollection_HAsciiString("%");
+ aprefix->AssignCat(name);
+ aprefix->AssignCat("_");
+
+ Handle(WOKUtils_HSequenceOfParamItem) someparams = new WOKUtils_HSequenceOfParamItem;
+ for(Standard_Integer i=1; i<= defines->Length() ; i++)
+ {
+ Handle(TCollection_HAsciiString) astr = new TCollection_HAsciiString(aprefix);
+ astr->AssignCat(defines->Value(i).Name());
+ someparams->Append(WOKUtils_ParamItem(astr, defines->Value(i).Value()));
+ }
+
+ aseq = aparc->BuildParameters(someparams, usedefaults);
+ return aseq;
+ }
+ return GetBuildParameters(asession,name,anesting,defines,usedefaults);
+}
+
+//=======================================================================
+//function : Declare
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Parcel::Declare(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& name,
+ const WOKAPI_Entity& anesting,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+{
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+
+ Handle(WOKernel_Warehouse) theWarehouse = Handle(WOKernel_Warehouse)::DownCast(anesting.Entity());
+ UpdateBeforeBuild(theWarehouse);
+ Handle(WOKernel_Parcel) aparc = new WOKernel_Parcel(name,
+ theWarehouse);
+ Handle(TCollection_HAsciiString) aprefix = new TCollection_HAsciiString("%");
+ aprefix->AssignCat(name);
+ aprefix->AssignCat("_");
+ Handle(TCollection_HAsciiString) namedel = new TCollection_HAsciiString(aprefix->ToCString());
+ namedel->AssignCat("Delivery");
+ Handle(TCollection_HAsciiString) valnamedel;
+
+ Handle(WOKUtils_HSequenceOfParamItem) someparams = new WOKUtils_HSequenceOfParamItem;
+ for(Standard_Integer i=1; i<= defines->Length() ; i++)
+ {
+ Handle(TCollection_HAsciiString) astr = new TCollection_HAsciiString(aprefix);
+ astr->AssignCat(defines->Value(i).Name());
+ if (astr->IsSameString(namedel)) {
+ valnamedel = new TCollection_HAsciiString(defines->Value(i).Value());
+ }
+ someparams->Append(WOKUtils_ParamItem(astr, defines->Value(i).Value()));
+ }
+
+ Handle(WOKUtils_HSequenceOfParamItem) aseq = aparc->BuildParameters(someparams, usedefaults);
+
+ if (valnamedel.IsNull()) {
+ ErrorMsg << "WOKAPI_Parcel::Declare"
+ << "Delivery name not given" << endm;
+ return Standard_False;
+ }
+ WOKUtils_ParamItem itemdel(namedel,valnamedel);
+ aseq->Append(itemdel);
+
+
+ aparc->Build(aseq);
+
+ Set(aparc);
+
+ theWarehouse->AddParcel(aparc);
+ return Standard_True;
+}
+
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Parcel::IsValid() const
+{
+ if(myEntity.IsNull()) return Standard_False;
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Parcel));
+}
+
+//=======================================================================
+//function : Delivery
+//purpose :
+//=======================================================================
+void WOKAPI_Parcel::Delivery(WOKAPI_Unit& unit) const
+{
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Session) asession = myEntity->Session();
+ Handle(WOKernel_Parcel) aparcel = Handle(WOKernel_Parcel)::DownCast(myEntity);
+ Handle(WOKernel_DevUnit) aunit;
+ Handle(WOKernel_Entity) anent;
+
+ Handle(TCollection_HAsciiString) adel = aparcel->Delivery();
+ Handle(TCollection_HAsciiString) astr;
+
+ if(!adel.IsNull())
+ {
+ aunit.Nullify();
+ astr = aparcel->NestedUniqueName(adel);
+
+ if(asession->IsKnownEntity(astr))
+ {
+ aunit = asession->GetDevUnit(astr);
+
+ if(aunit.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Parcel::Deliveries"
+ << "Invalid name : " << adel << " in parcel " << aparcel->UserPathName() << endm;
+ return;
+ }
+ if(!WOKernel_IsDelivery(aunit))
+ {
+ ErrorMsg << "WOKAPI_Parcel::Deliveries"
+ << "Invalid type for " << adel << " in parcel " << aparcel->UserPathName() << endm;
+ return;
+ }
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Parcel::Units"
+ << "Invalid name : " << adel << " in parcel " << aparcel->UserPathName() << endm;
+ return;
+ }
+ if(!aunit.IsNull())
+ {
+ aunit->Open();
+ unit.Set(aunit);
+ }
+ }
+ return ;
+}
+
+//=======================================================================
+//function : NestedEntities
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Parcel::NestedEntities(WOKAPI_SequenceOfEntity& aseq) const
+{
+ if(!IsValid()) return Standard_False;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ aseq.Clear();
+
+ Handle(WOKernel_Session) asession = myEntity->Session();
+ Handle(WOKernel_Parcel) aparcel = Handle(WOKernel_Parcel)::DownCast(myEntity);
+ Handle(WOKernel_DevUnit) aunit;
+ Handle(WOKernel_Entity) anent;
+ WOKAPI_Unit apiunit;
+
+ Handle(TColStd_HSequenceOfHAsciiString) afullseq = aparcel->Units();
+ Handle(TCollection_HAsciiString) astr;
+ Standard_Integer i;
+
+ for(i=1; i<=afullseq->Length(); i++)
+ {
+ astr = afullseq->Value(i);
+
+ if(asession->IsKnownEntity(astr))
+ {
+ aunit = asession->GetDevUnit(astr);
+
+ if(aunit.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Parcel::NestedEntities"
+ << "Invalid name : " << afullseq->Value(i) << " in allcomponents of " << aparcel->UserPathName() << endm;
+ aseq.Clear();
+ return Standard_False;
+ }
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Parcel::NestedEntities"
+ << "Invalid name : " << afullseq->Value(i) << " in allcomponents of " << aparcel->UserPathName() << endm;
+ aseq.Clear();
+ return Standard_False;
+ }
+ apiunit.Set(aunit);
+ aseq.Append(apiunit);
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Units
+//purpose :
+//=======================================================================
+void WOKAPI_Parcel::Units(WOKAPI_SequenceOfUnit& units) const
+{
+ units.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Session) asession = myEntity->Session();
+ Handle(WOKernel_Parcel) aparcel = Handle(WOKernel_Parcel)::DownCast(myEntity);
+ Handle(WOKernel_DevUnit) aunit;
+ Handle(WOKernel_Entity) anent;
+ WOKAPI_Unit apiunit;
+
+ Handle(TColStd_HSequenceOfHAsciiString) afullseq = aparcel->Units();
+ Handle(TCollection_HAsciiString) astr;
+ Standard_Integer i;
+
+ for(i=1; i<=afullseq->Length(); i++)
+ {
+ astr = afullseq->Value(i);
+
+ if(asession->IsKnownEntity(astr))
+ {
+ aunit = asession->GetDevUnit(astr);
+
+ if(aunit.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Parcel::Units"
+ << "Invalid name : " << afullseq->Value(i) << " in allcomponents of " << aparcel->UserPathName() << endm;
+ units.Clear();
+ return;
+ }
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Parcel::Units"
+ << "Invalid name : " << afullseq->Value(i) << " in allcomponents of " << aparcel->UserPathName() << endm;
+ units.Clear();
+ return;
+ }
+ apiunit.Set(aunit);
+ units.Append(apiunit);
+ }
+ return;
+}
+
--- /dev/null
+-- File: WOKAPI_Process.cdl
+-- Created: Tue Oct 28 11:41:46 1997
+-- Author:
+-- <jga@GROMINEX>
+---Copyright: Matra Datavision 1997
+
+
+
+class Process from WOKAPI
+uses
+
+
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd,
+ Session from WOKAPI,
+ Workbench from WOKAPI,
+ BuildProcess from WOKAPI,
+ HSequenceOfDefine from WOKTools
+
+
+is
+
+
+ Create(asession : Session from WOKAPI) returns Process from WOKAPI;
+
+ Init(me:out; abench : HAsciiString from TCollection;
+ debug : Boolean from Standard;
+ aprof : HAsciiString from TCollection)
+ ---Purpose: Initialize process
+ returns Boolean from Standard;
+
+ ExploreInitSection(me:out; lines : HSequenceOfHAsciiString from TColStd;
+ fromindex : Integer from Standard = 1)
+ ---Purpose: Explores Init lines in config file and performs Init
+ returns Integer from Standard;
+
+ BuildProcess(me)
+ ---C++: return const &
+ returns BuildProcess from WOKAPI;
+
+ AdvanceToNextValidSection(me:out; lines : HSequenceOfHAsciiString from TColStd;
+ fromindex : Integer from Standard = 1)
+ ---Purpose: Advance to next section in executable state (regarding to :<cond> conditions
+ returns Integer from Standard;
+
+ ExploreTclSection(me:out; lines : HSequenceOfHAsciiString from TColStd;
+ fromindex : Integer from Standard = 1)
+ returns Integer from Standard;
+
+ ExecuteTcl(me:out; atclsection : HAsciiString from TCollection)
+ returns Boolean from Standard;
+
+ ExploreBuildSection(me:out; lines : HSequenceOfHAsciiString from TColStd;
+ fromindex : Integer from Standard = 1)
+ returns Integer from Standard;
+
+ ExecuteBuild(me:out; params : HSequenceOfDefine from WOKTools)
+ returns Boolean from Standard;
+
+
+ ExecuteFile(me:out; afile : HAsciiString from TCollection)
+ returns Boolean from Standard;
+
+fields
+
+ mysession : Session from WOKAPI;
+ mybp : BuildProcess from WOKAPI;
+
+end;
+
+
--- /dev/null
+
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Messages.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+
+#include <WOKUtils_AdmFile.hxx>
+#include <WOKUtils_Path.hxx>
+#include <WOKUtils_Triggers.hxx>
+
+#include <WOKernel_DBMSystem.hxx>
+#include <WOKernel_Station.hxx>
+
+#include <WOKAPI_Process.ixx>
+
+
+//=======================================================================
+//function : WOKAPI_Process
+//purpose :
+//=======================================================================
+WOKAPI_Process::WOKAPI_Process(const WOKAPI_Session& session)
+: mysession(session)
+{
+}
+
+
+//=======================================================================
+//function : Init
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Process::Init(const Handle(TCollection_HAsciiString)& abench,
+ const Standard_Boolean debug,
+ const Handle(TCollection_HAsciiString)& aprofile)
+{
+ Standard_Boolean initsession = Standard_False;
+
+ if(mysession.DebugMode() != debug)
+ {
+ mysession.SetDebugMode(debug);
+ initsession = Standard_True;
+ }
+
+ if(!aprofile.IsNull())
+ {
+ if(strcmp(aprofile->ToCString(), mysession.DBMSystem()->ToCString()))
+ {
+ mysession.SetDBMSystem(aprofile);
+ initsession = Standard_True;
+ }
+ }
+
+ if(initsession)
+ {
+ mysession.Close();
+ mysession.Open(abench);
+ }
+
+ WOKAPI_Workbench thebench(mysession, abench);
+
+ if(!mybp.Init(thebench))
+ {
+ ErrorMsg << "WOKAPI_Process::Init"
+ << "Could not initialize build process" << endm;
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
+
+//=======================================================================
+//function : ExploreInitSection
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Process::ExploreInitSection(const Handle(TColStd_HSequenceOfHAsciiString)& lines, const Standard_Integer fromindex)
+{
+ static char InitStr[] = ":Init";
+ static char EndInitStr[] = ":EndInit";
+ static char WorkbenchStr[] = "Workbench";
+
+ static char ModeStr[] = "Mode";
+ static char DebugStr[] = "Debug";
+ static char OptimiseStr[] = "Optimise";
+
+ static char DBMSStr[] = "DBMS";
+
+ static char InfoStr[] = "InfoLog";
+ static char WarningStr[] = "WarningLog";
+ static char ErrorStr[] = "ErrorLog";
+
+ // First lookup Init Section
+ Standard_Boolean initcomplete = Standard_False;
+ Standard_Integer i=fromindex;
+
+ Handle(TCollection_HAsciiString) workbench;
+ Handle(TCollection_HAsciiString) mode;
+ Handle(TCollection_HAsciiString) dbms;
+ Handle(TCollection_HAsciiString) info;
+ Handle(TCollection_HAsciiString) warning;
+ Handle(TCollection_HAsciiString) error;
+
+ while( i<=lines->Length() && !initcomplete)
+ {
+ const Handle(TCollection_HAsciiString)& line = lines->Value(i);
+
+ if(line->Value(1) == ':')
+ {
+ line->RightAdjust();
+
+ if(!strcmp(line->ToCString(), InitStr))
+ {
+ i++;
+
+ while(i<=lines->Length() && !initcomplete)
+ {
+ const Handle(TCollection_HAsciiString)& line = lines->Value(i);
+ if(line->Value(1) == ':')
+ {
+ line->RightAdjust();
+ if(!strcmp(EndInitStr, line->ToCString()))
+ initcomplete = Standard_True;
+ else
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreInitSection"
+ << "Section flag " << line << " inside :Init section" << endm;
+ return -1;
+ }
+ }
+ else
+ {
+ Handle(TCollection_HAsciiString) left = line->Token("=", 1);
+ Handle(TCollection_HAsciiString) right = line->Token("=", 2);
+
+ if(!left.IsNull() && !right.IsNull())
+ {
+ left->LeftAdjust(); left->RightAdjust();
+ right->LeftAdjust(); right->RightAdjust();
+
+ if(!strcmp(left->ToCString(), WorkbenchStr))
+ workbench = right;
+ else if(!strcmp(left->ToCString(), ModeStr))
+ mode = right;
+ else if(!strcmp(left->ToCString(), DBMSStr))
+ dbms = right;
+ else if(!strcmp(left->ToCString(), InfoStr))
+ info = right;
+ else if(!strcmp(left->ToCString(), WarningStr))
+ warning = right;
+ else if(!strcmp(left->ToCString(), ErrorStr))
+ error = right;
+ else
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreInitSection"
+ << "Unrecognized line in :Init section : " << line << endm;
+ return -1;
+ }
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreInitSection"
+ << "Malformed line in :Init section: " << line << endm;
+ return -1;
+ }
+ }
+ if(!initcomplete) i++;
+ }
+ }
+ }
+ i++;
+ }
+
+ if(!initcomplete)
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreInitSection"
+ << "Could not find :Init section in file" << endm;
+ return Standard_False;
+ }
+
+ if(workbench.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreInitSection"
+ << "Could not find required field Workbench= in :Init section" << endm;
+ return -1;
+ }
+
+ WOKAPI_Workbench abench(mysession, workbench);
+
+ if(!abench.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreInitSection"
+ << "Could not find " << workbench << " or this is not a workbench name" << endm;
+ return -1;
+ }
+
+ Standard_Boolean debugmode = mysession.DebugMode();
+
+ if(!mode.IsNull())
+ {
+ if(!strcmp(mode->ToCString(), "Debug"))
+ {
+ debugmode = Standard_True;
+ }
+ else if(!strcmp(mode->ToCString(), "Optimise"))
+ {
+ debugmode = Standard_False;
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreInitSection"
+ << "Invalid mode specification " << mode << " is ignored" << endm;
+ return -1;
+ }
+ }
+
+ Handle(TCollection_HAsciiString) dbmsmode = mysession.DBMSystem();
+
+ if(!dbms.IsNull())
+ {
+ if(!WOKernel_DBMSystem::IsNameKnown(dbms))
+ {
+ ErrorMsg << "WOKAPI_::SetDBMSystem"
+ << dbms << " is not known as a DBMSystem" << endm;
+ return -1;
+ }
+ else
+ {
+ dbmsmode = dbms;
+ }
+ }
+
+ if(!Init(abench.UserPath(), debugmode, dbmsmode)) return -1;
+ return i++;
+}
+
+
+//=======================================================================
+//function : AdvanceToNextValidSection
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Process::AdvanceToNextValidSection(const Handle(TColStd_HSequenceOfHAsciiString)& lines, const Standard_Integer fromindex)
+{
+
+ Standard_Integer i = fromindex;
+
+
+ while(i<=lines->Length())
+ {
+ const Handle(TCollection_HAsciiString)& line = lines->Value(i);
+
+ if(line->Value(1) == ':')
+ {
+ Standard_Integer j = 1;
+ Handle(TCollection_HAsciiString) token = line->Token(":", j);
+
+ while(!token->IsEmpty())
+ {
+ if(!strcmp(token->ToCString(), "Build") ||
+ !strcmp(token->ToCString(), "Init") ||
+ !strcmp(token->ToCString(), "Tcl"))
+ {
+ // This is a new section
+ return i;
+ }
+ else if(!strcmp(token->ToCString(), "EndBuild") ||
+ !strcmp(token->ToCString(), "EndInit") ||
+ !strcmp(token->ToCString(), "EndTcl"))
+ {
+ break;
+ }
+ else
+ {
+ if(WOKernel_DBMSystem::IsNameKnown(token))
+ {
+ if(!mysession.DBMSystem()->IsSameString(token)) break;
+ }
+ else if(WOKernel_Station::IsNameKnown(token))
+ {
+ if(!mysession.Station()->IsSameString(token)) break;
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Process::AdvanceToNextValidSection"
+ << "Unrecognized conditional (" << token << ") in line: " << line << endm;
+ return -1;
+ }
+ }
+ j++;
+ token = line->Token(":", j);
+ }
+ }
+ i++;
+ }
+ return -1;
+}
+
+
+//=======================================================================
+//function : ExecuteTcl
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Process::ExecuteTcl(const Handle(TCollection_HAsciiString)& atcl)
+{
+
+ WOKUtils_Trigger atrig;
+
+ atrig("eval") << atcl << endt;
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ExploreTclSection
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Process::ExploreTclSection(const Handle(TColStd_HSequenceOfHAsciiString)& lines, const Standard_Integer fromindex)
+{
+ static char TclStr[] = ":Tcl";
+ static char EndTclStr[] = ":EndTcl";
+
+ Standard_Boolean tclcomplete = Standard_False;
+ Standard_Integer i = fromindex;
+ Handle(TCollection_HAsciiString) command = new TCollection_HAsciiString;
+
+ while( i<=lines->Length() && !tclcomplete)
+ {
+ const Handle(TCollection_HAsciiString)& line = lines->Value(i);
+
+ if(line->Value(1) == ':')
+ {
+ line->RightAdjust();
+ Standard_CString sessflg = &(line->ToCString()[line->Length()-4]);
+
+ if(!strcmp(sessflg, TclStr))
+ {
+ i++;
+
+ while(i<=lines->Length() && !tclcomplete)
+ {
+ const Handle(TCollection_HAsciiString)& line = lines->Value(i);
+
+ if(line->Value(1) == ':')
+ {
+ line->RightAdjust();
+ if(!strcmp(EndTclStr, line->ToCString()))
+ tclcomplete = Standard_True;
+ else
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreTclSection"
+ << "Section flag " << line << " inside :Tcl section" << endm;
+ return -1;
+ }
+ }
+ else
+ {
+ command->AssignCat(line);
+ command->AssignCat(";");
+ }
+ if(!tclcomplete) i++;
+ }
+ }
+ }
+ i++;
+ }
+
+ if(!ExecuteTcl(command)) return -1;
+
+ return i++;
+}
+
+//=======================================================================
+//function : ExploreBuildSection
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Process::ExploreBuildSection(const Handle(TColStd_HSequenceOfHAsciiString)& lines, const Standard_Integer fromindex)
+{
+ static char BuildStr[] = ":Build";
+ static char EndBuildStr[] = ":EndBuild";
+
+ Standard_Boolean buildcomplete = Standard_False;
+ Standard_Integer i = fromindex;
+ Handle(WOKTools_HSequenceOfDefine) defines = new WOKTools_HSequenceOfDefine;
+
+ while( i<=lines->Length() && !buildcomplete)
+ {
+ const Handle(TCollection_HAsciiString)& line = lines->Value(i);
+
+ if(line->Value(1) == ':')
+ {
+ line->RightAdjust();
+
+ if(!strcmp(line->ToCString(), BuildStr))
+ {
+ i++;
+
+ while(i<=lines->Length() && !buildcomplete)
+ {
+ const Handle(TCollection_HAsciiString)& line = lines->Value(i);
+
+ if(line->Value(1) == ':')
+ {
+ line->RightAdjust();
+ if(!strcmp(EndBuildStr, line->ToCString()))
+ buildcomplete = Standard_True;
+ else
+ {
+ ErrorMsg << "WOKAPI_Process::ExploreBuildSection"
+ << "Section flag " << line << " inside :Build section" << endm;
+ return -1;
+ }
+ }
+ else
+ {
+ Handle(TCollection_HAsciiString) left = line->Token("=", 1);
+ Handle(TCollection_HAsciiString) right = line->Token("=", 2);
+
+ if(!left.IsNull() && !right.IsNull())
+ {
+ left->LeftAdjust(); left->RightAdjust();
+ right->LeftAdjust(); right->RightAdjust();
+
+ right->ChangeAll(',', ' ');
+
+ defines->Append(WOKTools_Define(left, right));
+ }
+ }
+ if(!buildcomplete) i++;
+ }
+ }
+ }
+ i++;
+ }
+
+ if(!ExecuteBuild(defines)) return -1;
+
+ return i++;
+}
+
+
+//=======================================================================
+//function : ExecuteBuild
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Process::ExecuteBuild(const Handle(WOKTools_HSequenceOfDefine)& params)
+{
+
+
+ Standard_Integer nbsteps = mybp.SelectOnDefines(params);
+
+ if(nbsteps)
+ {
+ mybp.PrintBanner();
+
+ mybp.Execute();
+ }
+ return Standard_True;
+}
+
+
+//=======================================================================
+//function : ExecuteFile
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Process::ExecuteFile(const Handle(TCollection_HAsciiString)& afile)
+{
+ static char BuildStr[] = ":Build";
+
+ static char ForceStr[] = "Force";
+ static char YesStr[] = "Yes";
+ static char NoStr[] = "No";
+
+ static char TclStr[] = ":Tcl";
+
+ Standard_Integer index;
+ WOKUtils_AdmFile configfile(new WOKUtils_Path(afile));
+
+ Handle(TColStd_HSequenceOfHAsciiString) lines = configfile.Read();
+
+ index = ExploreInitSection(lines);
+
+ index = AdvanceToNextValidSection(lines, index);
+ while(index > 0 && index <= lines->Length())
+ {
+ const Handle(TCollection_HAsciiString)& line = lines->Value(index);
+
+ if(line->Search(BuildStr) > 0)
+ {
+ index = ExploreBuildSection(lines, index);
+ }
+ else if(line->Search(TclStr) > 0)
+ {
+ index = ExploreTclSection(lines,index);
+ }
+ index = AdvanceToNextValidSection(lines, index);
+ }
+
+ return Standard_True;
+}
--- /dev/null
+-- File: WOKAPI_Session.cdl
+-- Created: Tue Aug 1 15:43:49 1995
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1995
+
+
+class Session from WOKAPI
+inherits Entity from WOKAPI
+
+ ---Purpose: Manages Session API for WOK
+
+uses
+ Entity from WOKAPI,
+ Factory from WOKAPI,
+ SequenceOfFactory from WOKAPI,
+ Workshop from WOKAPI,
+ Warehouse from WOKAPI,
+ Parcel from WOKAPI,
+ Workbench from WOKAPI,
+ Unit from WOKAPI,
+
+ Entity from WOKernel,
+ Session from WOKernel,
+ Warehouse from WOKernel,
+ Parcel from WOKernel,
+ Factory from WOKernel,
+ Workshop from WOKernel,
+ Workbench from WOKernel,
+ DevUnit from WOKernel,
+
+ Path from WOKUtils,
+ Param from WOKUtils,
+ HSequenceOfParamItem from WOKUtils,
+
+ ArgTable from WOKTools,
+ Return from WOKTools,
+ HSequenceOfDefine from WOKTools,
+
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd,
+ Failure from Standard
+
+is
+
+ Create returns Session from WOKAPI;
+
+ -- Session Manipulation Opening
+ Open(me:out; alocation,astation : HAsciiString from TCollection = NULL)
+ returns Integer from Standard;
+
+ Close(me:out)
+ is redefined;
+
+ GeneralFailure(me:out; afailure : Failure from Standard);
+
+ IsValid(me)
+ returns Boolean from Standard
+ is redefined;
+
+ Path(me) returns mutable Path from WOKUtils;
+ SetPath(me:out; apath : Path from WOKUtils);
+
+ CWEntityName(me)
+ returns HAsciiString from TCollection;
+
+ GetCWEntity(me)
+ returns Entity from WOKAPI;
+
+ SetCWEntity(me:out; anent : Entity from WOKAPI);
+
+ Factories(me; factseq : out SequenceOfFactory from WOKAPI);
+
+ Station(me)
+ returns HAsciiString from TCollection;
+ SetStation(me:out; astation : HAsciiString from TCollection)
+ returns Boolean from Standard;
+
+ DBMSystem(me)
+ returns HAsciiString from TCollection;
+ SetDBMSystem(me:out; adbms : HAsciiString from TCollection)
+ returns Boolean from Standard;
+
+ DebugMode(me)
+ returns Boolean from Standard;
+ SetDebugMode(me:out; amode : Boolean from Standard);
+
+ IsValidPath(me; apath : HAsciiString from TCollection)
+ returns Boolean from Standard;
+
+ Destroy(me:out)
+ returns Boolean from Standard
+ is redefined;
+
+
+-----
+-- SESSION PRIVATE METHODS
+-- Use them only in WOKAPI classes
+
+
+ Param(me)
+ returns Param from WOKUtils
+ is private;
+
+ SaveToFile(me)
+ is private;
+ ---Purpose: Sauve les parametres de session dans le fichier
+
+ OpenPath(me; apath : HAsciiString from TCollection; besilent : Boolean from Standard = Standard_False)
+ returns mutable Entity from WOKernel
+ is private;
+
+ GetEntity(me; ahumanpath : HAsciiString from TCollection; fatal : Boolean = Standard_True)
+ returns Entity from WOKernel
+ is private;
+
+ GetFactory(me; ahumanpath : HAsciiString from TCollection;
+ fatal : Boolean from Standard = Standard_True;
+ getit : Boolean from Standard = Standard_True)
+ returns Factory from WOKernel
+ is private;
+
+ GetWarehouse(me; ahumanpath : HAsciiString from TCollection;
+ fatal : Boolean from Standard = Standard_True;
+ getit : Boolean from Standard = Standard_True)
+ returns Warehouse from WOKernel
+ is private;
+
+ GetParcel(me; ahumanpath : HAsciiString from TCollection;
+ fatal : Boolean from Standard = Standard_True;
+ getit : Boolean from Standard = Standard_True)
+ returns Parcel from WOKernel
+ is private;
+
+
+ GetWorkshop(me; ahumanpath : HAsciiString from TCollection;
+ fatal : Boolean from Standard = Standard_True;
+ getit : Boolean from Standard = Standard_True)
+ returns Workshop from WOKernel
+ is private;
+
+ GetWorkbench(me; ahumanpath : HAsciiString from TCollection;
+ fatal : Boolean from Standard = Standard_True;
+ getit : Boolean from Standard = Standard_True)
+ returns Workbench from WOKernel
+ is private;
+
+ GetDevUnit(me; ahumanpath : HAsciiString from TCollection;
+ fatal : Boolean from Standard = Standard_True;
+ getit : Boolean from Standard = Standard_True)
+ returns DevUnit from WOKernel
+ is private;
+
+fields
+
+ mypath : Path from WOKUtils;
+ myparams : Param from WOKUtils;
+
+ mycwe : HAsciiString from TCollection;
+
+
+friends
+
+ Create from class Entity from WOKAPI (asession : Session from WOKAPI;aname : HAsciiString from TCollection; fatal,getit : Boolean from Standard = Standard_True),
+ Create from class Factory from WOKAPI (asession : Session from WOKAPI;aname : HAsciiString from TCollection; fatal,getit : Boolean from Standard = Standard_True),
+ Create from class Workshop from WOKAPI (asession : Session from WOKAPI;aname : HAsciiString from TCollection; fatal,getit : Boolean from Standard = Standard_True),
+ Create from class Warehouse from WOKAPI (asession : Session from WOKAPI;aname : HAsciiString from TCollection; fatal,getit : Boolean from Standard = Standard_True),
+ Create from class Parcel from WOKAPI (asession : Session from WOKAPI;aname : HAsciiString from TCollection; fatal,getit : Boolean from Standard = Standard_True),
+ Create from class Workbench from WOKAPI (asession : Session from WOKAPI;aname : HAsciiString from TCollection; fatal,getit : Boolean from Standard = Standard_True),
+ Create from class Unit from WOKAPI (asession : Session from WOKAPI;aname : HAsciiString from TCollection; fatal,getit : Boolean from Standard = Standard_True)
+
+end Session;
+
+
--- /dev/null
+// File: WOKAPI_Session.cxx
+// Created: Tue Aug 1 15:43:42 1995
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+#include <Standard_ErrorHandler.hxx>
+
+#include <OSD_Environment.hxx>
+#include <OSD.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+#include <TColStd_HSequenceOfAsciiString.hxx>
+
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_Path.hxx>
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_SearchList.hxx>
+#include <WOKUtils_ParamItem.hxx>
+#ifndef WNT
+# include <WOKUtils_ProcessManager.hxx>
+# include <WOKUtils_Signal.hxx>
+#else
+# include <WOKUtils_ShellManager.hxx>
+# define WOKUtils_ProcessManager WOKUtils_ShellManager
+#endif // WNT
+
+#include <WOKernel_StationID.hxx>
+#include <WOKernel_Station.hxx>
+#include <WOKernel_DBMSystem.hxx>
+#include <WOKernel_BaseEntity.hxx>
+#include <WOKernel_Entity.hxx>
+#include <WOKernel_Session.hxx>
+#include <WOKernel_Factory.hxx>
+#include <WOKernel_Workshop.hxx>
+#include <WOKernel_Workbench.hxx>
+#include <WOKernel_DevUnit.hxx>
+#include <WOKernel_Station.hxx>
+#include <WOKernel_StationID.hxx>
+#include <WOKernel_DBMSystem.hxx>
+#include <WOKernel_DBMSID.hxx>
+#include <WOKernel_DataMapIteratorOfDataMapOfHAsciiStringOfFile.hxx>
+
+
+#include <WOKMake_TriggerStep.hxx>
+
+
+#include <WOKAPI_Factory.hxx>
+
+#include <WOKAPI_Session.ixx>
+
+static const Standard_CString WOK_CWE = "%WOK_CWENTITY";
+static const Standard_CString WOK_STATION = "%WOK_STATION";
+static const Standard_CString WOK_DBMS = "%WOK_DBMS";
+static const Standard_CString WOK_DEBUG = "%WOK_DEBUG";
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : WOKAPI_Session
+//purpose : instantiates a API SESSION
+//=======================================================================
+WOKAPI_Session::WOKAPI_Session()
+{
+ mypath = new WOKUtils_Path;
+}
+
+//
+//
+//
+// WOKAPI_Session MAIN Features
+//
+//
+//
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Open
+//purpose :
+//=======================================================================
+Standard_Integer WOKAPI_Session::Open(const Handle(TCollection_HAsciiString)& alocation, const Handle(TCollection_HAsciiString)& astation)
+{
+ OSD_Environment sessid("WOK_SESSIONID");
+ OSD_Environment root("WOK_ROOTADMDIR");
+ OSD_Environment libpath("WOK_LIBPATH");
+ Handle(TCollection_HAsciiString) astr;
+ Handle(WOKUtils_Path) apath;
+ Handle(WOKernel_Session) asession;
+ Handle(WOKernel_Factory) afactory;
+ Handle(WOKernel_Workshop) aworkshop;
+ Handle(WOKernel_Workbench) aworkbench;
+ Handle(WOKernel_DevUnit) adevunit;
+ Handle(TColStd_HSequenceOfAsciiString) aseq, dirseq;
+ Standard_Integer i;
+
+ Handle(TCollection_HAsciiString) sessionname = new TCollection_HAsciiString(sessid.Value());
+
+ if(sessionname->IsEmpty() == Standard_True)
+ {
+ ErrorMsg << "WOKAPI_Session::Open" << "Symbol WOK_SESSIONID is not setted" << endm;
+ return 1;
+ }
+ Handle(TCollection_HAsciiString) rootname = new TCollection_HAsciiString(root.Value());
+
+ if(rootname->IsEmpty() == Standard_True)
+ {
+ ErrorMsg << "WOKAPI_Session::Open" << "Symbol WOK_ROOTADMDIR is not setted" << endm;
+ return 1;
+ }
+
+ Handle(TCollection_HAsciiString) libpathname = new TCollection_HAsciiString(libpath.Value());
+
+ if(libpathname->IsEmpty() == Standard_True)
+ {
+ ErrorMsg << "WOKAPI_Session::Open" << "Symbol WOK_LIBPATH is not setted" << endm;
+ return 1;
+ }
+
+
+
+ apath = new WOKUtils_Path(sessionname);
+ if (!apath->CreateDirectory()) {
+ ErrorMsg << "WOKAPI_Session::Open" << "Unable to create directory " << sessionname->ToCString() << endm;
+ return 1;
+ }
+
+
+ WOKernel_StationID astationID;
+
+ if(!astation.IsNull())
+ {
+ astationID = WOKernel_Station::GetID(astation);
+ }
+ else
+ {
+ astationID = WOKernel_UnknownStation;
+ }
+
+ asession = new WOKernel_Session(new TCollection_HAsciiString("WOKSESSION"));
+ asession->SetSession(asession);
+ asession->AddEntity(asession);
+ asession->SetStation(astationID);
+ asession->Open(rootname,libpathname);
+
+ myEntity = asession;
+
+ aseq = Session()->Params().SearchDirectories();
+ dirseq = new TColStd_HSequenceOfAsciiString;
+
+ dirseq->Append(apath->Name()->ToCString());
+
+ for(i=1; i<=aseq->Length(); i++)
+ {
+ dirseq->Append(aseq->Value(i));
+ }
+
+ Param().SetSearchDirectories(dirseq);
+
+ apath = new WOKUtils_Path(apath->Name()->ToCString(), "WOK.edl");
+
+ if (!apath->CreateFile()) {
+ ErrorMsg << "WOKAPI_Session::Open" << "Unable to create directory " << apath->Name()->ToCString() << endm;
+ return 1;
+ }
+
+ SetPath(apath);
+
+ //
+ // Determination de DBMS
+ //
+
+ astr = Param().Eval(WOK_DBMS);
+
+ if(!astr.IsNull())
+ {
+ Session()->SetDBMSystem(WOKernel_DBMSystem::GetID(astr));
+ }
+ else
+ {
+ Session()->SetDBMSystem(WOKernel_DFLT);
+ Param().Set(WOK_DBMS,WOKernel_DBMSystem::GetName( WOKernel_DFLT )->ToCString());
+ }
+
+
+ //
+ // Determination du debug mode
+ //
+
+ astr = Param().Eval(WOK_DEBUG);
+
+ if(!astr.IsNull())
+ {
+ if(!strcmp(astr->ToCString(), "True"))
+ {
+ Session()->SetDebugMode();
+ }
+ else
+ if(!strcmp(astr->ToCString(), "False"))
+ {
+ Session()->UnsetDebugMode();
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Session::Open"
+ << "Wrong value : " << astr << " for session parameter : " << WOK_DEBUG << " (has to be : True|False" << endm;
+ }
+ }
+ else
+ {
+ Session()->UnsetDebugMode();
+ Param().Set(WOK_DEBUG, "False");
+ }
+
+ //
+ // Set de la station
+ //
+ Param().Set(WOK_STATION, WOKernel_Station::GetName(asession->Station())->ToCString());
+
+ //
+ // Ouverture de la CWE
+ //
+
+
+ if(mycwe.IsNull())
+ {
+ if(alocation.IsNull())
+ {
+ astr = Param().Eval(WOK_CWE);
+ if(astr.IsNull())
+ {
+ astr = new TCollection_HAsciiString(":");
+ }
+ else if(astr->IsEmpty())
+ {
+ astr = new TCollection_HAsciiString(":");
+ }
+ }
+ else
+ {
+ if(!alocation->IsEmpty())
+ {
+ astr = alocation;
+ }
+ else
+ {
+ astr = new TCollection_HAsciiString(":");
+ }
+ }
+
+ WOKAPI_Entity anent(*this, astr);
+
+ if(anent.IsValid())
+ {
+ mycwe = anent.UserPath();
+ }
+ }
+ else
+ {
+ GetCWEntity();
+ }
+
+ //
+ //
+ SaveToFile();
+ //
+
+ return 0;
+}
+
+//=======================================================================
+//function : Close
+//purpose :
+//=======================================================================
+void WOKAPI_Session::Close()
+{
+ WOKAPI_Entity::Close();
+ mypath.Nullify();
+ myparams.Clear();
+}
+
+//=======================================================================
+//function : GeneralFailure
+//purpose :
+//=======================================================================
+void WOKAPI_Session::GeneralFailure(const Handle(Standard_Failure)& )
+{
+
+ static FailedInOpen;
+ OSD::SetSignal(); //==== ReArm the signals. =============
+#ifndef WNT
+ WOKUtils_Signal::Arm(WOKUtils_SIGINT, (WOKUtils_SigHandler) NULL);
+#endif // WNT
+ try {
+
+
+
+ WOK_TRACE {
+ VerboseMsg("WOK_API") << "WOKAPI_Session::GeneralFailure"
+ << "Killing processes" << endm;
+ }
+ WOKUtils_ProcessManager::KillAll();
+
+ WOK_TRACE {
+ VerboseMsg("WOK_API") << "WOKAPI_Session::GeneralFailure"
+ << "Reopen session" << endm;
+ }
+ Close();
+ myEntity.Nullify();
+ mypath.Nullify();
+ myparams.Clear();
+ mycwe.Nullify();
+ WOKMake_TriggerStep::CurrentTriggerStep() = Handle(WOKMake_TriggerStep)();
+ FailedInOpen = Standard_False;
+ Open();
+
+ }
+ catch(Standard_Failure) {
+ Handle(Standard_Failure) E = Standard_Failure::Caught();
+ strstream astream;
+ astream << E << ends;
+ ErrorMsg << "WOKAPI_Session::GeneralFailure"
+ << "Exception was raised : " << astream.str() << endm;
+ ErrorMsg << "WOKAPI_Session::GeneralFailure"
+ << "Could not recover session after Failure : Session is reinitialized" << endm;
+
+ WOKUtils_ProcessManager::UnArm();
+ WOKMake_TriggerStep::CurrentTriggerStep() = Handle(WOKMake_TriggerStep)();
+ if (!FailedInOpen) {
+ myEntity.Nullify();
+ mypath.Nullify();
+ myparams.Clear();
+ mycwe.Nullify();
+ FailedInOpen = Standard_True;
+ Open();
+ FailedInOpen = Standard_False;
+ }
+ else {
+ ErrorMsg << "WOKAPI_Session::GeneralFailure"
+ << "Session recovering Failed" << endm;
+ }
+ }
+ return;
+}
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Session::IsValid() const
+{
+ if(myEntity.IsNull()) return Standard_False;
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Session));
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Path
+//purpose : returns path of session file
+//=======================================================================
+Handle(WOKUtils_Path) WOKAPI_Session::Path() const {return mypath;}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SetPath
+//purpose : returns path of session file
+//=======================================================================
+void WOKAPI_Session::SetPath(const Handle(WOKUtils_Path)& apath) {mypath=apath;}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : Param
+//purpose : returns parameters of APISession
+//=======================================================================
+WOKUtils_Param WOKAPI_Session::Param() const {return myparams;}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : SaveToFile
+//purpose : sauvegarde les parametres de Session dans le fichier
+//=======================================================================
+void WOKAPI_Session::SaveToFile() const
+{
+ Handle(TColStd_HSequenceOfHAsciiString) aseq = new TColStd_HSequenceOfHAsciiString;
+
+ if(myparams.IsSet(WOK_CWE)) aseq->Append(new TCollection_HAsciiString(WOK_CWE));
+ if(myparams.IsSet(WOK_DBMS)) aseq->Append(new TCollection_HAsciiString(WOK_DBMS));
+ if(myparams.IsSet(WOK_DEBUG)) aseq->Append(new TCollection_HAsciiString(WOK_DEBUG));
+
+ if(!myparams.Write(mypath, aseq))
+ {
+ ErrorMsg << "WOKAPI_Session::SaveToFile"
+ << "Could not save session parameters to file : " << mypath->Name() << endm;
+ }
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : CWEntityName
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Session::CWEntityName() const
+{
+ return mycwe;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetCWEntity
+//purpose :
+//=======================================================================
+WOKAPI_Entity WOKAPI_Session::GetCWEntity() const
+{
+
+ if(!IsValid()) return WOKAPI_Entity();
+
+ if(mycwe.IsNull()) return *this;
+
+ if(!strcmp(mycwe->ToCString(), ":") || !strcmp(mycwe->ToCString(), "WOKSESSION:"))
+ return *this;
+
+ WOKAPI_Entity anentity;
+ anentity.Set(GetEntity(mycwe));
+
+ return anentity;
+}
+
+//=======================================================================
+//function : SetCWEntity
+//purpose :
+//=======================================================================
+void WOKAPI_Session::SetCWEntity(const WOKAPI_Entity& anent)
+{
+ if(anent.IsValid())
+ {
+ mycwe = anent.UserPath();
+ }
+ Param().Set(WOK_CWE, mycwe->ToCString());
+ SaveToFile();
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetEntity
+//purpose :
+//=======================================================================
+Handle(WOKernel_Entity) WOKAPI_Session::GetEntity(const Handle(TCollection_HAsciiString)& apath, const Standard_Boolean fatal) const
+{
+ Handle(WOKernel_Entity) result;
+
+ if(!IsValid()) return result;
+
+ if(apath.IsNull()) return GetCWEntity().Entity();
+
+ result = OpenPath(apath, !fatal);
+
+ return result;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetFactory
+//purpose :
+//=======================================================================
+Handle(WOKernel_Factory) WOKAPI_Session::GetFactory(const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal,
+ const Standard_Boolean getit) const
+{
+ Handle(WOKernel_Factory) NULLRESULT, result;
+
+ if(apath.IsNull())
+ {
+ WOKAPI_Entity cwe = GetCWEntity();
+
+ if(!cwe.IsValid()) return NULLRESULT;
+
+ Handle(WOKernel_Entity) Kcwe = cwe.Entity();
+
+ if(getit)
+ {
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_Workbench))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_Parcel))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_Warehouse))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_Workshop))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ }
+
+ result = Handle(WOKernel_Factory)::DownCast(Kcwe);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetFactory"
+ << "Could not find any nesting factory to your current position : " << cwe.Entity()->UserPathName() << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+ else
+ {
+ Handle(WOKernel_Entity) anentity = OpenPath(apath,!fatal);
+
+ if(anentity.IsNull()) return NULLRESULT;
+
+ if(getit)
+ {
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) anentity = Session()->GetEntity(anentity->Nesting());
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_Workbench))) anentity = Session()->GetEntity(anentity->Nesting());
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_Parcel))) anentity = Session()->GetEntity(anentity->Nesting());
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_Warehouse))) anentity = Session()->GetEntity(anentity->Nesting());
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_Workshop))) anentity = Session()->GetEntity(anentity->Nesting());
+ }
+
+ result = Handle(WOKernel_Factory)::DownCast(anentity);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetFactory"
+ << "Entity " << apath << " is not a factory" << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+}
+
+//=======================================================================
+//Function : GetWarehouse
+//purpose :
+//=======================================================================
+Handle(WOKernel_Warehouse) WOKAPI_Session::GetWarehouse(const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal,
+ const Standard_Boolean getit) const
+{
+ Handle(WOKernel_Warehouse) NULLRESULT, result;
+
+ if(apath.IsNull())
+ {
+ WOKAPI_Entity cwe = GetCWEntity();
+
+ if(!cwe.IsValid()) return NULLRESULT;
+
+ Handle(WOKernel_Entity) Kcwe = cwe.Entity();
+
+ if(getit)
+ {
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_Parcel))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ }
+
+ result = Handle(WOKernel_Warehouse)::DownCast(Kcwe);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetWarehouse"
+ << "Could not find any nesting warehouse to your current position : " << cwe.Entity()->UserPathName() << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+ else
+ {
+ Handle(WOKernel_Entity) anentity = OpenPath(apath,fatal);
+
+ if(anentity.IsNull()) return NULLRESULT;
+
+ if(getit)
+ {
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) anentity = Session()->GetEntity(anentity->Nesting());
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_Parcel))) anentity = Session()->GetEntity(anentity->Nesting());
+ }
+
+ result = Handle(WOKernel_Warehouse)::DownCast(anentity);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetWarehouse"
+ << "Entity " << apath << " is not a warehouse" << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetParcel
+//purpose :
+//=======================================================================
+Handle(WOKernel_Parcel) WOKAPI_Session::GetParcel(const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal,
+ const Standard_Boolean getit) const
+{
+ Handle(WOKernel_Parcel) NULLRESULT, result;
+
+ if(apath.IsNull())
+ {
+ WOKAPI_Entity cwe = GetCWEntity();
+
+ if(!cwe.IsValid()) return NULLRESULT;
+
+ Handle(WOKernel_Entity) Kcwe = cwe.Entity();
+
+ if(getit)
+ {
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ }
+
+ result = Handle(WOKernel_Parcel)::DownCast(Kcwe);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetParcel"
+ << "Could not find any parcel from your current position : " << cwe.Entity()->UserPathName() << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+ else
+ {
+ Handle(WOKernel_Entity) anentity = OpenPath(apath,!fatal);
+
+ if(anentity.IsNull()) return NULLRESULT;
+
+ if(getit)
+ {
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) anentity = Session()->GetEntity(anentity->Nesting());
+ }
+
+ result = Handle(WOKernel_Parcel)::DownCast(anentity);
+
+ if(!result.IsNull()) return result;
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetParcel"
+ << "Entity " << apath << " is not a parcel" << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetWorkshop
+//purpose :
+//=======================================================================
+Handle(WOKernel_Workshop) WOKAPI_Session::GetWorkshop(const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal,
+ const Standard_Boolean getit) const
+{
+ Handle(WOKernel_Workshop) NULLRESULT, result;
+
+ if(apath.IsNull())
+ {
+ WOKAPI_Entity cwe = GetCWEntity();
+
+ if(!cwe.IsValid()) return result;
+
+ Handle(WOKernel_Entity) Kcwe = cwe.Entity();
+
+ if(getit)
+ {
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_Workbench))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ }
+
+ result = Handle(WOKernel_Workshop)::DownCast(Kcwe);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetWorkshop"
+ << "Could not find any nesting workshop to your current position : " << cwe.Entity()->UserPathName() << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+ else
+ {
+ Handle(WOKernel_Entity) anentity = OpenPath(apath,!fatal);
+
+ if(anentity.IsNull()) return NULLRESULT;
+
+ if(getit)
+ {
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) anentity = Session()->GetEntity(anentity->Nesting());
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_Workbench))) anentity = Session()->GetEntity(anentity->Nesting());
+ }
+
+ result = Handle(WOKernel_Workshop)::DownCast(anentity);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetWorkshop"
+ << "Entity " << apath << " is not a workshop" << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetWorkbench
+//purpose :
+//=======================================================================
+Handle(WOKernel_Workbench) WOKAPI_Session::GetWorkbench(const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal,
+ const Standard_Boolean getit) const
+{
+ Handle(WOKernel_Workbench) NULLRESULT, result;
+
+ if(apath.IsNull())
+ {
+ WOKAPI_Entity cwe = GetCWEntity();
+
+ if(!cwe.IsValid()) return result;
+
+ Handle(WOKernel_Entity) Kcwe = cwe.Entity();
+
+ if(getit)
+ {
+ if(Kcwe->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) Kcwe = Session()->GetEntity(Kcwe->Nesting());
+ }
+
+ result = Handle(WOKernel_Workbench)::DownCast(Kcwe);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetWorkbench"
+ << "Could not find any workbench from your current position : " << cwe.Entity()->UserPathName() << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+ else
+ {
+ Handle(WOKernel_Entity) anentity = OpenPath(apath,!fatal);
+
+ if(anentity.IsNull()) return NULLRESULT;
+
+ if(getit)
+ {
+ if(anentity->IsKind(STANDARD_TYPE(WOKernel_DevUnit))) anentity = Session()->GetEntity(anentity->Nesting());
+ }
+
+ result = Handle(WOKernel_Workbench)::DownCast(anentity);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetWorkbench"
+ << "Entity " << apath << " is not a workbench" << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : GetDevUnit
+//purpose :
+//=======================================================================
+Handle(WOKernel_DevUnit) WOKAPI_Session::GetDevUnit(const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal,
+ const Standard_Boolean getit) const
+{
+ Handle(WOKernel_DevUnit) NULLRESULT, result;
+
+ if(apath.IsNull())
+ {
+
+ WOKAPI_Entity cwe = GetCWEntity();
+
+ if(!cwe.IsValid()) return result;
+
+ Handle(WOKernel_Entity) Kcwe = cwe.Entity();
+
+ result = Handle(WOKernel_DevUnit)::DownCast(Kcwe);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetDevUnit"
+ << "Could not find any Dev Unit from your current position : " << cwe.Entity()->UserPathName() << endm;
+ }
+ return NULLRESULT;
+ }
+
+ }
+ else
+ {
+ Handle(WOKernel_Entity) anentity = OpenPath(apath,!fatal);
+
+ if(anentity.IsNull()) return NULLRESULT;
+
+ result = Handle(WOKernel_DevUnit)::DownCast(anentity);
+
+ if(!result.IsNull()) return result;
+ else
+ {
+ if(fatal)
+ {
+ ErrorMsg << "WOKAPI_Session::GetDevUnit"
+ << "Entity " << apath << " is not a devunit" << endm;
+ }
+ return NULLRESULT;
+ }
+ }
+}
+
+//=======================================================================
+//function : Factories
+//purpose :
+//=======================================================================
+void WOKAPI_Session::Factories( WOKAPI_SequenceOfFactory& factseq) const
+{
+ factseq.Clear();
+
+ if(!IsValid()) return;
+
+ if(!myEntity->IsOpened())
+ {
+ ErrorMsg << "WOKAPI_Session::Factories"
+ << "Internal Error : Session is not opened" << endm;
+ return;
+ }
+
+ Handle(WOKernel_Session) Ksession = Handle(WOKernel_Session)::DownCast(myEntity);
+ Handle(WOKernel_Factory) Kfact;
+ Handle(TColStd_HSequenceOfHAsciiString) fseq;
+ Standard_Integer i;
+
+ fseq = Ksession->Factories();
+
+ for(i=1; i<=fseq->Length(); i++)
+ {
+ Kfact = Ksession->GetFactory(fseq->Value(i));
+
+ if(!Kfact.IsNull())
+ {
+ WOKAPI_Factory factory;
+ factory.Set(Kfact);
+
+ factseq.Append(factory);
+ }
+ }
+}
+
+//=======================================================================
+//function : Station
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Session::Station() const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(!IsValid()) return result;
+
+ result = WOKernel_Station::GetName(Session()->Station());
+ return result;
+}
+
+//=======================================================================
+//function : SetStation
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Session::SetStation(const Handle(TCollection_HAsciiString)& astation)
+{
+ if(!IsValid()) return Standard_False;
+
+ if(!WOKernel_Station::IsNameKnown(astation))
+ {
+ ErrorMsg << "WOKAPI_Session::SetStation"
+ << astation << " is not known as a " << endm;
+ ErrorMsg << "WOKAPI_Session::SetStation"
+ << "Station is unchanged" << endm;
+ return Standard_True;
+ }
+
+ WOKernel_StationID anid = WOKernel_Station::GetID(astation);
+ Session()->SetStation(anid);
+ Param().Set(WOK_STATION, WOKernel_Station::GetName(Session()->Station())->ToCString());
+ SaveToFile();
+ return Standard_False;
+}
+
+//=======================================================================
+//function : DBMSystem
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Session::DBMSystem() const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(!IsValid()) return result;
+
+ result = WOKernel_DBMSystem::GetName(Session()->DBMSystem());
+ return result;
+}
+
+//=======================================================================
+//function : SetDBMSystem
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Session::SetDBMSystem(const Handle(TCollection_HAsciiString)& adbms)
+{
+ if(!IsValid()) return Standard_True;
+
+ if(!WOKernel_DBMSystem::IsNameKnown(adbms))
+ {
+ ErrorMsg << "WOKAPI_Session::SetDBMSystem"
+ << adbms << " is not known as a DBMSystem" << endm;
+ ErrorMsg << "WOKAPI_Session::SetDBMSystem"
+ << "DBMS is unchanged" << endm;
+ return Standard_True;
+ }
+
+ WOKernel_DBMSID anid = WOKernel_DBMSystem::GetID(adbms);
+ Session()->SetDBMSystem(anid);
+
+ Param().Set(WOK_DBMS, WOKernel_DBMSystem::GetName(Session()->DBMSystem())->ToCString());
+ SaveToFile();
+ return Standard_False;
+}
+
+//=======================================================================
+//function : DebugMode
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Session::DebugMode() const
+{
+ if(!IsValid()) return Standard_False;
+
+ return Session()->DebugMode();
+}
+
+//=======================================================================
+//function : SetDebugMode
+//purpose :
+//=======================================================================
+void WOKAPI_Session::SetDebugMode(const Standard_Boolean amode)
+{
+ if(!IsValid()) return;
+
+ if(amode)
+ {
+ Session()->SetDebugMode();
+ Param().Set(WOK_DEBUG, "True");
+ }
+ else
+ {
+ Session()->UnsetDebugMode();
+ Param().Set(WOK_DEBUG, "False");
+ }
+ SaveToFile();
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : OpenPath
+//purpose :
+//=======================================================================
+Handle(WOKernel_Entity) WOKAPI_Session::OpenPath(const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean besilent) const
+{
+ Handle(WOKernel_BaseEntity) abaseentity;
+ Handle(WOKernel_Entity) anentity;
+ Standard_Integer pos,i;
+
+ if(apath.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath" << "Invalid NULL input" << endm;
+ return anentity;
+ }
+
+ if (apath->IsEmpty()) apath->AssignCat(":");
+
+ if(!strcmp(apath->ToCString(), ":") || !strcmp(apath->ToCString(), "WOKSESSION:") ) return myEntity;
+
+ if(apath->Value(1) == ':')
+ {
+ // le path commence par : --> Il y a de grandes chances pour
+ // que celui-ci soit un full path connu: on tente le getEntity direct
+ anentity = Session()->GetEntity(apath);
+ if(!anentity.IsNull())
+ {
+ anentity->Open();
+ return anentity;
+ }
+ }
+
+ Handle(TColStd_HSequenceOfHAsciiString) aseq = Session()->GetMatchingEntities(apath);
+
+ switch(aseq->Length())
+ {
+ case 1:
+ abaseentity = Session()->GetEntity(aseq->Value(1));
+
+ if(abaseentity->IsKind(STANDARD_TYPE(WOKernel_Entity)))
+ {
+ anentity = Handle(WOKernel_Entity)::DownCast(abaseentity);
+ anentity->Open();
+ }
+ else
+ {
+ if(!besilent)
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath" << "You cannot move in " << apath << endm;
+ }
+ }
+ return anentity;
+
+
+ case 0:
+ {
+ Handle(TCollection_HAsciiString) thepath = new TCollection_HAsciiString(":");
+ Standard_Boolean end = Standard_False;
+ i=1;
+
+ pos = apath->Location(i,':',1,apath->Length());
+ if (pos != 1) end = Standard_True;
+
+ while(!end)
+ {
+ // if a full path is given -> try to Open it
+ if (pos == 0 || pos == apath->Length())
+ {
+ end = Standard_True;
+ if (pos ==0)
+ thepath->AssignCat(apath->SubString(thepath->Length()+1,apath->Length()));
+ else
+ if(apath->Length() > thepath->Length()+2)
+ thepath->AssignCat(apath->SubString(thepath->Length()+1,apath->Length()-1));
+
+ Handle(TColStd_HSequenceOfHAsciiString) anotherseq = Session()->GetMatchingEntities(thepath);
+ if(anotherseq->Length())
+ anentity = OpenPath(thepath,besilent);
+ if(anentity.IsNull() || anotherseq->Length()==0)
+ {
+ if(!besilent)
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath"
+ << "No entity is matching path: " << thepath << endm;
+ }
+ return Handle(WOKernel_Entity)();
+ }
+ return anentity;
+ }
+ else
+ {
+ if (pos > thepath->Length()+2)
+ thepath->AssignCat(apath->SubString(thepath->Length()+1,pos-1));
+
+ //open the nesting
+ anentity = OpenPath(thepath,besilent);
+ if(anentity.IsNull())
+ {
+ if(!besilent)
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath"
+ << "No entity is matching path: " << thepath << endm;
+ }
+ return Handle(WOKernel_Entity)();
+ }
+ }
+ i++;
+ pos = apath->Location(i,':',1,apath->Length());
+ }
+
+ // else a partial path is given -> try ...
+
+ // root
+ thepath = new TCollection_HAsciiString(":");
+ thepath->AssignCat(apath);
+
+ anentity = OpenPath(thepath,besilent);
+ if(anentity.IsNull() == Standard_False)
+ return anentity;
+
+ Handle(WOKernel_Entity) theentity = GetCWEntity().Entity();
+ if(theentity.IsNull()) return Handle(WOKernel_Entity)();
+
+ // N'y suis-je pas deja ??
+ thepath = new TCollection_HAsciiString(theentity->Name());
+ thepath->AssignCat(":");
+
+ if(thepath->IsSameString(apath))
+ return theentity;
+
+ //N'y suis-je pas juste au dessus ??
+ thepath = new TCollection_HAsciiString(theentity->FullName());
+ if (strcmp(thepath->ToCString(), ":")) thepath->AssignCat(":");
+ thepath->AssignCat(apath);
+
+ anentity = OpenPath(thepath,besilent);
+ if(anentity.IsNull() == Standard_False)
+ return anentity;
+
+ //N'y suis-je pas juste a cote ??
+ if(theentity->Nesting().IsNull() == Standard_False)
+ {
+ thepath = new TCollection_HAsciiString(Session()->GetEntity(theentity->Nesting())->FullName());
+ if (strcmp(thepath->ToCString(), ":")) thepath->AssignCat(":");
+ thepath->AssignCat(apath);
+
+ anentity = OpenPath(thepath,besilent);
+ if(anentity.IsNull() == Standard_False)
+ return anentity;
+ }
+
+ //N'y suis-je pas en dessous ??
+ Handle(TCollection_HAsciiString) astring = new TCollection_HAsciiString(theentity->FullName());
+ end = Standard_False;
+ i=1;
+
+ while(!end)
+ {
+ pos = astring->Location(i,':',1,astring->Length());
+
+ if (pos == 0)
+ end = Standard_True;
+ else
+ {
+ if (pos == 1)
+ thepath = new TCollection_HAsciiString(":");
+ else
+ {
+ thepath = astring->SubString(1,pos-1);
+ thepath->AssignCat(":");
+ }
+ thepath->AssignCat(apath);
+
+ anentity = OpenPath(thepath,besilent);
+ if(anentity.IsNull() == Standard_False)
+ return anentity;
+ }
+ i++;
+ }
+
+ if(anentity.IsNull())
+ {
+ Standard_Boolean fullpath = Standard_False;
+
+ if(apath->Value(apath->Length()) == ':')
+ thepath = apath->SubString(1,apath->Length()-1);
+ else
+ thepath = apath;
+
+ Handle(TColStd_HSequenceOfHAsciiString) apartialseq = Session()->GetMatchingEntities(thepath,fullpath);
+ if(apartialseq->Length())
+ {
+ if(!besilent)
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath"
+ << "No entity is matching your path be more precise in: " << endm;
+ for(i=1; i<=apartialseq->Length(); i++)
+ {
+ anentity = Session()->GetEntity(apartialseq->Value(i));
+ if(!anentity.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath" << "\t" << anentity->UserPathName() << endm;
+ }
+ }
+ }
+ return Handle(WOKernel_Entity)();
+ }
+ else
+ {
+ if(!besilent)
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath"
+ << "No entity is matching path: " << apath << endm;
+ }
+ return Handle(WOKernel_Entity)();
+ }
+ }
+ break;
+ }
+
+ default:
+ if(!besilent)
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath" << "Abnormal Mulitple choice in Nesting : " << endm;
+ for(Standard_Integer i=1; i<=aseq->Length(); i++)
+ {
+ ErrorMsg << "WOKAPI_Session::OpenPath" << "\t\t" << aseq->Value(i) << endm;
+ }
+ }
+ return Handle(WOKernel_Entity)();
+
+ }
+
+ return anentity;
+
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : IsValidPath
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Session::IsValidPath(const Handle(TCollection_HAsciiString)& apath) const
+{
+ if(!IsValid()) return Standard_False;
+
+ if(apath.IsNull())
+ {
+ return IsValidPath(GetCWEntity().UserPath());
+ }
+
+ Handle(WOKernel_Entity) entity = OpenPath(apath,Standard_True);
+
+ if(entity.IsNull())
+ return Standard_False;
+ else
+ return Standard_True;
+}
+
+
+//=======================================================================
+//function : Destroy
+//purpose : bouchon
+//=======================================================================
+Standard_Boolean WOKAPI_Session::Destroy()
+{
+ return Standard_False;
+}
--- /dev/null
+-- File: WOKAPI_Unit.cdl
+-- Created: Mon Aug 21 22:06:13 1995
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1995
+
+
+class Unit from WOKAPI
+inherits Entity from WOKAPI
+ ---Purpose: Unit API in WOK
+
+uses
+
+ Session from WOKAPI,
+ Locator from WOKAPI,
+ SequenceOfUnit from WOKAPI,
+ SequenceOfFile from WOKAPI,
+ MakeOption from WOKAPI,
+ SequenceOfMakeOption from WOKAPI,
+ DevUnit from WOKernel,
+ HSequenceOfParamItem from WOKUtils,
+ HSequenceOfDefine from WOKTools,
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd
+is
+
+ Create returns Unit from WOKAPI;
+
+ Create(aent : Entity from WOKAPI)
+ returns Unit from WOKAPI;
+
+ Create(asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ verbose,getit : Boolean from Standard = Standard_True)
+ returns Unit from WOKAPI;
+
+ TypeKey(me) returns Character from Standard;
+
+ Type(me) returns HAsciiString from TCollection;
+
+ BuildParameters(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ acode : Character from Standard;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns HSequenceOfParamItem from WOKUtils;
+
+
+ Build(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ acode : Character from Standard;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns Boolean from Standard;
+
+ Destroy(me:out)
+ returns Boolean from Standard
+ is redefined;
+
+ IsValid(me)
+ returns Boolean from Standard
+ is redefined;
+
+ Files(me; alocator : Locator from WOKAPI; fileseq : out SequenceOfFile from WOKAPI);
+
+end Unit;
--- /dev/null
+// File: WOKAPI_Unit.cxx
+// Created: Mon Aug 21 22:07:27 1995
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+#include <Standard_ErrorHandler.hxx>
+
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <OSD_Host.hxx>
+
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+#include <WOKTools_Return.hxx>
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Messages.hxx>
+
+#include <WOKUtils_Path.hxx>
+#include <WOKUtils_ParamItem.hxx>
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ShellManager.hxx>
+
+#include <WOKernel_Station.hxx>
+#include <WOKernel_Session.hxx>
+#include <WOKernel_DevUnit.hxx>
+#include <WOKernel_Workbench.hxx>
+#include <WOKernel_File.hxx>
+#include <WOKernel_Locator.hxx>
+#include <WOKernel_UnitGraph.hxx>
+#include <WOKernel_HSequenceOfFile.hxx>
+#include <WOKernel_FileTypeBase.hxx>
+#include <WOKernel_DBMSystem.hxx>
+#include <WOKernel_Station.hxx>
+#include <WOKernel_SequenceOfSession.hxx>
+
+#include <WOKAPI_Session.hxx>
+#include <WOKAPI_File.hxx>
+#include <WOKAPI_Workbench.hxx>
+
+#include <WOKAPI_Unit.ixx>
+
+//=======================================================================
+//function : WOKAPI_Unit
+//purpose :
+//=======================================================================
+WOKAPI_Unit::WOKAPI_Unit()
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Unit
+//purpose :
+//=======================================================================
+WOKAPI_Unit::WOKAPI_Unit(const WOKAPI_Entity& anent)
+ : WOKAPI_Entity(anent)
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Unit
+//purpose :
+//=======================================================================
+WOKAPI_Unit::WOKAPI_Unit(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal, const Standard_Boolean getit)
+{
+ Set(asession.GetDevUnit(apath,fatal,getit));
+}
+
+//=======================================================================
+//function : TypeKey
+//purpose :
+//=======================================================================
+Standard_Character WOKAPI_Unit::TypeKey() const
+{
+ if(!IsValid()) return 0;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_DevUnit) aunit = Handle(WOKernel_DevUnit)::DownCast(myEntity);
+
+ return aunit->TypeCode();
+}
+
+//=======================================================================
+//function : Type
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Unit::Type() const
+{
+ if(!IsValid()) return 0;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_DevUnit) aunit = Handle(WOKernel_DevUnit)::DownCast(myEntity);
+
+ return aunit->Type();
+}
+
+
+//=======================================================================
+//function : BuildParameters
+//purpose :
+//=======================================================================
+Handle(WOKUtils_HSequenceOfParamItem) WOKAPI_Unit::BuildParameters(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Character acode,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+{
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+ Handle(WOKernel_DevUnit) Kunit;
+ Handle(WOKernel_Workbench) Kbench;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Workbench abench(asession,nestname);
+
+ if(!abench.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Unit::Build"
+ << "Invalid nesting (" << nestname << ") to create workbench : " << name << endm;
+ return aseq;
+ }
+
+ Kbench = Handle(WOKernel_Workbench)::DownCast(abench.Entity());
+
+ Kunit = Kbench->GetDevUnit(acode, name);
+
+ Set(Kunit);
+
+ aseq = GetBuildParameters(asession, name, abench, defines, usedefaults);
+
+ return aseq;
+}
+
+//=======================================================================
+//function : Build
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Unit::Build(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Character acode,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+{
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+ Handle(WOKernel_DevUnit) Kunit;
+ Handle(WOKernel_Workbench) Kbench;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Workbench abench(asession,nestname);
+
+ if(!abench.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Unit::Build"
+ << "Invalid nesting (" << nestname << ") to create unit : " << name << endm;
+ return Standard_True;
+ }
+
+ Kbench = Handle(WOKernel_Workbench)::DownCast(abench.Entity());
+
+ Kunit = Kbench->GetDevUnit(acode, name);
+
+ if(Kunit.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Unit::Build"
+ << "Could not obtain unit : wrong type code : " << acode << endm;
+ return Standard_True;
+ }
+
+ Set(Kunit);
+
+ UpdateBeforeBuild(Kbench);
+
+ if(!BuildEntity(asession, name, abench, defines, usedefaults))
+ {
+ Kbench->AddUnit(Kunit);
+ Kunit->Open();
+ }
+ else return Standard_True;
+ return Standard_False;
+}
+
+//=======================================================================
+//function : Destroy
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Unit::Destroy()
+{
+ if(!IsValid()) return Standard_True;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_UnitNesting) aunitnesting = myEntity->Session()->GetUnitNesting(myEntity->Nesting());
+
+ UpdateBeforeDestroy(aunitnesting);
+ if (!IsValid()) return Standard_True;
+
+ Handle(WOKernel_DevUnit) aDevUnit = Handle(WOKernel_DevUnit)::DownCast(myEntity);
+ aDevUnit->Open();
+ aDevUnit->Destroy();
+ aunitnesting->RemoveUnit(aDevUnit);
+
+ myEntity.Nullify();
+ return Standard_False;
+}
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Unit::IsValid() const
+{
+ if(myEntity.IsNull()) return Standard_False;
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_DevUnit));
+}
+
+//=======================================================================
+//function : Files
+//purpose :
+//=======================================================================
+void WOKAPI_Unit::Files(const WOKAPI_Locator& alocator, WOKAPI_SequenceOfFile& fileseq) const
+{
+ Standard_Integer i;
+
+ fileseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_DevUnit) aunit = Handle(WOKernel_DevUnit)::DownCast(myEntity);
+ Handle(WOKernel_UnitNesting) anesting = aunit->Session()->GetUnitNesting(aunit->Nesting());
+
+ Handle(TColStd_HSequenceOfHAsciiString) filelist;
+ Handle(TCollection_HAsciiString) astr;
+
+ if(aunit->FileList().IsNull())
+ {
+ aunit->ReadFileList(alocator.Locator());
+ }
+
+ filelist = aunit->FileList();
+
+ Handle(WOKernel_File) afile;
+ Handle(TCollection_HAsciiString) aname;
+ Handle(TCollection_HAsciiString) atype;
+ Handle(TCollection_HAsciiString) aunitname;
+ WOKAPI_File apifile;
+
+ for(i=1; i<=filelist->Length();i++)
+ {
+ astr = filelist->Value(i);
+ aunitname = astr->Token(":", 1);
+ atype = astr->Token(":", 2);
+ aname = astr->Token(":", 3);
+
+ afile = new WOKernel_File(aname,
+ aunit,
+ aunit->GetFileType(atype));
+ apifile.Set(afile);
+ fileseq.Append(apifile);
+ }
+ return;
+}
--- /dev/null
+-- File: WOKAPI_Warehouse.cdl
+-- Created: Wed Mar 27 10:59:40 1996
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1996
+
+
+class Warehouse from WOKAPI
+inherits Entity from WOKAPI
+
+ ---Purpose:
+
+uses
+ Session from WOKAPI,
+ SequenceOfParcel from WOKAPI,
+ SequenceOfEntity from WOKAPI,
+ Warehouse from WOKernel,
+ HSequenceOfParamItem from WOKUtils,
+ ArgTable from WOKTools,
+ Return from WOKTools,
+ HSequenceOfDefine from WOKTools,
+ HAsciiString from TCollection
+
+
+is
+
+ Create returns Warehouse from WOKAPI;
+
+ Create(aent : Entity from WOKAPI)
+ returns Warehouse from WOKAPI;
+
+ Create(asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ verbose,getit : Boolean from Standard = Standard_True)
+ returns Warehouse from WOKAPI;
+
+ BuildParameters(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns HSequenceOfParamItem from WOKUtils;
+
+ Build(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns Boolean from Standard;
+
+ NestedEntities(me; aseq : out SequenceOfEntity from WOKAPI)
+ returns Boolean from Standard
+ is redefined;
+
+ Parcels(me; parcels : out SequenceOfParcel from WOKAPI);
+
+ Destroy(me:out)
+ returns Boolean from Standard
+ is redefined;
+
+ IsValid(me)
+ returns Boolean from Standard
+ is redefined;
+
+end Warehouse;
--- /dev/null
+// File: WOKAPI_Warehouse.cxx
+// Created: Wed Mar 27 11:08:38 1996
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+
+
+#include <Standard_ErrorHandler.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Return.hxx>
+#include <WOKTools_Messages.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+
+#include <WOKUtils_Path.hxx>
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKernel_Session.hxx>
+#include <WOKernel_Factory.hxx>
+#include <WOKernel_Warehouse.hxx>
+
+#include <WOKAPI_Parcel.hxx>
+#include <WOKAPI_Factory.hxx>
+#include <WOKAPI_Session.hxx>
+
+#include <WOKAPI_Warehouse.ixx>
+
+//=======================================================================
+//function : WOKAPI_Warehouse
+//purpose :
+//=======================================================================
+WOKAPI_Warehouse::WOKAPI_Warehouse()
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Warehouse
+//purpose :
+//=======================================================================
+WOKAPI_Warehouse::WOKAPI_Warehouse(const WOKAPI_Entity& anent)
+ : WOKAPI_Entity(anent)
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Warehouse
+//purpose :
+//=======================================================================
+WOKAPI_Warehouse::WOKAPI_Warehouse(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal, const Standard_Boolean getit)
+{
+ Set(asession.GetWarehouse(apath,fatal,getit));
+}
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Warehouse::IsValid() const
+{
+ if(myEntity.IsNull()) return Standard_False;
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Warehouse));
+}
+
+
+//=======================================================================
+//function : BuildParameters
+//purpose :
+//=======================================================================
+Handle(WOKUtils_HSequenceOfParamItem) WOKAPI_Warehouse::BuildParameters(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+{
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+ Handle(WOKernel_Warehouse) Kware;
+ Handle(WOKernel_Factory) Kfact;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Factory afact(asession,nestname);
+
+ if(!afact.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Warehouse::Build"
+ << "Invalid nesting (" << nestname << ") to create Warehouse : " << name << endm;
+ return aseq;
+ }
+
+ Kfact = Handle(WOKernel_Factory)::DownCast(afact.Entity());
+
+ Kware = new WOKernel_Warehouse(name,Kfact);
+ Set(Kware);
+
+ aseq = GetBuildParameters(asession, name, afact, defines, usedefaults);
+
+ return aseq;
+}
+
+//=======================================================================
+//function : Build
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Warehouse::Build(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+
+{
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+ Handle(WOKernel_Warehouse) Kware;
+ Handle(WOKernel_Factory) Kfact;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Factory afact(asession,nestname);
+
+ if(!afact.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Warehouse::Build"
+ << "Invalid nesting (" << nestname << ") to create Warehouse : " << name << endm;
+ return Standard_True;
+ }
+
+ Kfact = Handle(WOKernel_Factory)::DownCast(afact.Entity());
+ UpdateBeforeBuild(Kfact);
+
+ Kware = new WOKernel_Warehouse(name,Kfact);
+ Set(Kware);
+
+ if(!BuildEntity(asession, name, afact, defines, usedefaults))
+ {
+ Kfact->Session()->AddEntity(Kware);
+ Kfact->SetWarehouse(Kware);
+ Kware->Open();
+ }
+ else return Standard_True;
+ return Standard_False;
+}
+
+
+
+//=======================================================================
+//function : NestedEntities
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Warehouse::NestedEntities(WOKAPI_SequenceOfEntity& aseq) const
+{
+ if(!IsValid()) return Standard_False;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ aseq.Clear();
+
+ Handle(TColStd_HSequenceOfHAsciiString) fullseq;
+ Standard_Integer i;
+
+ Handle(WOKernel_Session) asession = myEntity->Session();
+ Handle(WOKernel_Warehouse) aware = Handle(WOKernel_Warehouse)::DownCast(myEntity);
+ Handle(WOKernel_Parcel) aparcel;
+
+ fullseq = aware->Parcels();
+
+ WOKAPI_Parcel apiparcel;
+
+ for(i=1; i<=fullseq->Length(); i++)
+ {
+ apiparcel.Set(asession->GetParcel(fullseq->Value(i)));
+ aseq.Append(apiparcel);
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Parcels
+//purpose :
+//=======================================================================
+void WOKAPI_Warehouse::Parcels( WOKAPI_SequenceOfParcel& parcels ) const
+{
+ Handle(TColStd_HSequenceOfHAsciiString) fullseq;
+ Standard_Integer i;
+
+ parcels.Clear();
+
+ if(!IsValid()) return ;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Session) asession = myEntity->Session();
+ Handle(WOKernel_Warehouse) aware = Handle(WOKernel_Warehouse)::DownCast(myEntity);
+ Handle(WOKernel_Parcel) aparcel;
+
+ fullseq = aware->Parcels();
+
+ WOKAPI_Parcel apiparcel;
+
+ for(i=1; i<=fullseq->Length(); i++)
+ {
+ apiparcel.Set(asession->GetParcel(fullseq->Value(i)));
+ parcels.Append(apiparcel);
+ }
+ return;
+}
+
+//=======================================================================
+//function : Destroy
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Warehouse::Destroy()
+{
+ if(!IsValid()) return Standard_True;
+
+ Handle(WOKernel_Factory) afactory = myEntity->Session()->GetFactory(myEntity->Nesting());
+
+ UpdateBeforeDestroy(afactory);
+ if (!IsValid()) return Standard_True;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Warehouse) awarehouse = Handle(WOKernel_Warehouse)::DownCast(myEntity);
+ awarehouse->Open();
+
+ if(awarehouse->Parcels()->Length())
+ {
+ ErrorMsg << "WOKAPI_Warehouse::Destroy"
+ << "Cannot destroy not empty warehouse" << endm;
+ return Standard_True;
+ }
+
+ awarehouse->Destroy();
+
+ //afactory->RemoveWarehouse(awarehouse);
+ myEntity.Nullify();
+ return Standard_False;
+}
+
--- /dev/null
+-- File: WOKAPI_Workbench.cdl
+-- Created: Tue Aug 1 17:13:32 1995
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1995
+
+
+class Workbench from WOKAPI
+inherits Entity from WOKAPI
+
+ ---Purpose: Workbench Manipulation
+
+uses
+
+ Session from WOKAPI,
+ SequenceOfUnit from WOKAPI,
+ SequenceOfWorkbench from WOKAPI,
+ SequenceOfEntity from WOKAPI,
+ HSequenceOfParamItem from WOKUtils,
+ Workbench from WOKernel,
+ ArgTable from WOKTools,
+ Return from WOKTools,
+ HSequenceOfDefine from WOKTools,
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd,
+ SequenceOfHAsciiString from TColStd
+is
+
+ Create returns Workbench from WOKAPI;
+
+ Create(aent : Entity from WOKAPI)
+ returns Workbench from WOKAPI;
+
+ Create(asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ verbose : Boolean from Standard = Standard_False;
+ getit : Boolean from Standard = Standard_True)
+ returns Workbench from WOKAPI;
+
+ BuildParameters(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ afather : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns HSequenceOfParamItem from WOKUtils;
+
+ Build(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ afather : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns Boolean from Standard;
+
+ Destroy(me:out)
+ returns Boolean from Standard
+ is redefined;
+
+ KnownTypeKeys(me)
+ returns HAsciiString from TCollection;
+
+ KnownTypeNames(me; aseq : out SequenceOfHAsciiString from TColStd);
+
+ IsValid(me)
+ returns Boolean from Standard
+ is redefined;
+
+ ChangeFather(me; afather : Workbench from WOKAPI)
+ returns Boolean from Standard;
+
+ Father(me)
+ returns Workbench from WOKAPI;
+
+ Ancestors(me; benchseq : out SequenceOfWorkbench from WOKAPI);
+
+ NestedEntities(me; aseq : out SequenceOfEntity from WOKAPI)
+ returns Boolean from Standard
+ is redefined;
+
+ Units(me; unitseq : out SequenceOfUnit from WOKAPI);
+
+ UnitsOfType(me; type : HAsciiString from TCollection;
+ unitseq : out SequenceOfUnit from WOKAPI;
+ clearseq : Boolean from Standard = Standard_True);
+
+ Toolkits(me; tkseq : out SequenceOfUnit from WOKAPI);
+
+ ImplSuppliers(me; aunitname : HAsciiString from TCollection;
+ unitseq : out SequenceOfUnit from WOKAPI);
+
+ ImplClients(me; aunitname : HAsciiString from TCollection;
+ unitseq : out SequenceOfUnit from WOKAPI);
+
+ SortUnitList(me; aunitlist : HSequenceOfHAsciiString from TColStd;
+ asortedunitlist : out HSequenceOfHAsciiString from TColStd);
+
+end Workbench;
+
--- /dev/null
+// File: WOKAPI_Workbench.cxx
+// Created: Tue Aug 1 18:55:00 1995
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+#include <Standard_ErrorHandler.hxx>
+
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <WOKTools_MapOfHAsciiString.hxx>
+#include <WOKTools_Messages.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+#include <WOKTools_Options.hxx>
+
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <WOKernel_Session.hxx>
+#include <WOKernel_Workshop.hxx>
+#include <WOKernel_Workbench.hxx>
+#include <WOKernel_BasicUnitTypes.hxx>
+#include <WOKernel_UnitTypeBase.hxx>
+#include <WOKernel_UnitTypeDescr.hxx>
+#include <WOKernel_DevUnit.hxx>
+#include <WOKernel_Locator.hxx>
+#include <WOKernel_UnitGraph.hxx>
+
+#include <WOKAPI_Session.hxx>
+#include <WOKAPI_Workshop.hxx>
+#include <WOKAPI_SequenceOfWorkbench.hxx>
+#include <WOKAPI_Unit.hxx>
+#include <WOKAPI_SequenceOfUnit.hxx>
+
+#include <WOKAPI_Workbench.ixx>
+
+//=======================================================================
+//function : WOKAPI_Workbench
+//purpose :
+//=======================================================================
+ WOKAPI_Workbench::WOKAPI_Workbench()
+{
+}
+
+
+//=======================================================================
+//function : WOKAPI_Workbench
+//purpose :
+//=======================================================================
+WOKAPI_Workbench::WOKAPI_Workbench(const WOKAPI_Entity& anent)
+ : WOKAPI_Entity(anent)
+{
+}
+//=======================================================================
+//function : WOKAPI_Workbench
+//purpose :
+//=======================================================================
+ WOKAPI_Workbench::WOKAPI_Workbench(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal, const Standard_Boolean getit)
+{
+ Set(asession.GetWorkbench(apath,fatal,getit));
+}
+
+//=======================================================================
+//function : BuildParameters
+//purpose :
+//=======================================================================
+Handle(WOKUtils_HSequenceOfParamItem) WOKAPI_Workbench::BuildParameters(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(TCollection_HAsciiString)& afather,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+{
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+ Handle(WOKernel_Workbench) Kbench;
+ Handle(WOKernel_Workshop) Kshop;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Workshop ashop(asession,nestname);
+
+ if(!ashop.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Workbench::BuildParameters"
+ << "Invalid nesting (" << nestname << ") to create workbench : " << name << endm;
+ return aseq;
+ }
+
+ if(!WOKernel_Entity::IsValidName(name))
+ {
+ ErrorMsg << "WOKAPI_Workbench::BuildParameters"
+ << "Invalid name (" << name << ") to create workbench" << endm;
+ return aseq;
+ }
+
+
+ Kshop = Handle(WOKernel_Workshop)::DownCast(ashop.Entity());
+
+ WOKAPI_Workbench father;
+
+ if(!afather.IsNull())
+ {
+ father = WOKAPI_Workbench(asession,afather);
+
+ if(!father.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Workbench::BuildParameters"
+ << "Invalid father (" << afather << ") to create workbench : " << name << endm;
+ return aseq;
+ }
+ }
+
+ Kbench = new WOKernel_Workbench(name, Kshop, Handle(WOKernel_Workbench)::DownCast(father.Entity()));
+ Set(Kbench);
+
+ aseq = GetBuildParameters(asession, name, ashop, defines, usedefaults);
+
+ return aseq;
+}
+
+
+//=======================================================================
+//function : Build
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workbench::Build(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(TCollection_HAsciiString)& afather,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+{
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+ Handle(WOKernel_Workbench) Kbench;
+ Handle(WOKernel_Workshop) Kshop;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Workshop ashop(asession,nestname);
+
+ if(!ashop.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Workbench::Build"
+ << "Invalid nesting (" << nestname << ") to create workbench : " << name << endm;
+ return Standard_True;
+ }
+
+
+ if(!WOKernel_Entity::IsValidName(name))
+ {
+ ErrorMsg << "WOKAPI_Workbench::Build"
+ << "Invalid name (" << name << ") to create workbench" << endm;
+ return Standard_True;
+ }
+
+
+ Kshop = Handle(WOKernel_Workshop)::DownCast(ashop.Entity());
+
+ //mettre a jour l 'EntityList
+ UpdateBeforeBuild(Kshop);
+
+ WOKAPI_Workbench father;
+
+ if(!afather.IsNull())
+ {
+ father = WOKAPI_Workbench(asession,afather,Standard_False);
+
+ if(!father.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Workbench::Build"
+ << "Invalid father (" << afather << ") to create workbench : " << name << endm;
+ return Standard_True;
+ }
+ Handle(WOKernel_Workbench) Kfather = *((Handle(WOKernel_Workbench) *) &father.Entity());
+ if(!Kfather.IsNull())
+ {
+ Kfather->Open();
+ }
+ }
+
+ Kbench = new WOKernel_Workbench(name, Kshop, Handle(WOKernel_Workbench)::DownCast(father.Entity()));
+ Set(Kbench);
+
+ if(!BuildEntity(asession, name, ashop, defines, usedefaults,Standard_True))
+ {
+ Kshop->AddWorkbench(Kbench);
+ Kbench->Open();
+ }
+ else return Standard_True;
+ return Standard_False;
+}
+
+//=======================================================================
+//function : Destroy
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workbench::Destroy()
+{
+ if(!IsValid()) return Standard_True;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Workshop) aworkshop = myEntity->Session()->GetWorkshop(myEntity->Nesting());
+
+ //mettre a jour l 'EntityList
+ UpdateBeforeDestroy(aworkshop);
+ if (!IsValid()) return Standard_True;
+
+ Handle(WOKernel_Workbench) aworkbench = *((Handle(WOKernel_Workbench) *) &myEntity);
+ aworkbench->Open();
+
+ if(aworkbench->Units()->Length())
+ {
+ ErrorMsg << "WOKAPI_Workbench::Destroy"
+ << "Cannot destroy not empty workbench" << endm;
+ return Standard_True;
+ }
+
+ aworkbench->Destroy();
+ aworkshop->RemoveWorkbench(aworkbench);
+
+ myEntity.Nullify();
+ return Standard_False;
+}
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : KnownTypeKeys
+//purpose :
+//=======================================================================
+Handle(TCollection_HAsciiString) WOKAPI_Workbench::KnownTypeKeys() const
+{
+ Handle(TCollection_HAsciiString) result;
+
+ if(!IsValid()) return result;
+
+ Handle(WOKernel_Workbench) Kbench = *((Handle(WOKernel_Workbench) *) &myEntity);
+
+ const WOKernel_UnitTypeBase& typebase = Kbench->KnownTypes();
+
+ result = new TCollection_HAsciiString;
+
+ for(Standard_Integer i=1; i<=typebase.Length(); i++)
+ {
+ result->AssignCat(new TCollection_HAsciiString(typebase.Value(i)->Key()));
+ }
+ return result;
+}
+
+
+//=======================================================================
+//Author : Jean Gautier (jga)
+//function : KnownTypeKeys
+//purpose :
+//=======================================================================
+void WOKAPI_Workbench::KnownTypeNames(TColStd_SequenceOfHAsciiString& aseq) const
+{
+ if(!IsValid()) return;
+
+ Handle(WOKernel_Workbench) Kbench = *((Handle(WOKernel_Workbench) *) &myEntity);
+
+ const WOKernel_UnitTypeBase& typebase = Kbench->KnownTypes();
+
+ for(Standard_Integer i=1; i<=typebase.Length(); i++)
+ {
+ aseq.Append(typebase.Value(i)->Type());
+ }
+ return ;
+}
+
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workbench::IsValid() const
+{
+ if(myEntity.IsNull()) return Standard_False;
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Workbench));
+}
+
+//=======================================================================
+//function : ChangeFather
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workbench::ChangeFather(const WOKAPI_Workbench& aFather) const
+{
+ Standard_Boolean result = Standard_False;
+
+ if(!IsValid() || !aFather.IsValid()) {
+ result = Standard_True;
+ }
+ else {
+ WOKAPI_Entity fnest = aFather.NestingEntity();
+ WOKAPI_Entity nest = NestingEntity();
+
+ if (fnest.Name()->IsSameString(nest.Name())) {
+ Handle(WOKernel_Entity) ent = aFather.Entity();
+ Handle(WOKernel_Entity) shopent = fnest.Entity();
+
+ Handle(WOKernel_Workbench) kbench = *((Handle(WOKernel_Workbench)*)&myEntity);
+ Handle(WOKernel_Workbench) kfbench = *((Handle(WOKernel_Workbench)*)&ent);
+ Handle(WOKernel_Workshop) kshop = *((Handle(WOKernel_Workshop)*)&shopent);
+
+ kbench->SetFather(kfbench);
+ kshop->DumpWorkbenchList();
+ }
+ else {
+ result = Standard_True;
+ }
+ }
+
+ return result;
+}
+
+//=======================================================================
+//function : Father
+//purpose :
+//=======================================================================
+WOKAPI_Workbench WOKAPI_Workbench::Father() const
+{
+ WOKAPI_Workbench afather;
+
+ if(!IsValid()) return afather;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Workbench) abench = *((Handle(WOKernel_Workbench) *) &myEntity);
+
+ if(!abench->Father().IsNull())
+ afather.Set(abench->Session()->GetWorkbench(abench->Father()));
+
+ return afather;
+}
+
+//=======================================================================
+//function : Ancestors
+//purpose :
+//=======================================================================
+void WOKAPI_Workbench::Ancestors(WOKAPI_SequenceOfWorkbench& benchseq ) const
+{
+
+ benchseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Workbench) abench = *((Handle(WOKernel_Workbench) *) &myEntity);
+ Handle(WOKernel_Workbench) thebench;
+ Handle(WOKernel_Session) asession = abench->Session();
+
+ Handle(TColStd_HSequenceOfHAsciiString) aseq = abench->Ancestors();
+ Standard_Integer i;
+
+ WOKAPI_Workbench apibench;
+
+ for(i=1; i<= aseq->Length(); i++)
+ {
+ apibench.Set(asession->GetWorkbench(aseq->Value(i)));
+ benchseq.Append(apibench);
+ }
+ return;
+}
+
+//=======================================================================
+//function : NestedEntities
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workbench::NestedEntities(WOKAPI_SequenceOfEntity& aseq) const
+{
+ if(!IsValid()) return Standard_False;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ aseq.Clear();
+ Handle(WOKernel_Workbench) abench = *((Handle(WOKernel_Workbench) *) &myEntity);
+ Handle(WOKernel_Session) asession = abench->Session();
+ Handle(WOKernel_DevUnit) aunit;
+ Standard_Integer i;
+
+ Handle(TColStd_HSequenceOfHAsciiString) aKseq = abench->Units();
+
+ WOKAPI_Unit apiunit;
+
+ for(i=1; i<= aKseq->Length(); i++)
+ {
+ apiunit.Set(asession->GetDevUnit(aKseq->Value(i)));
+ aseq.Append(apiunit);
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Units
+//purpose :
+//=======================================================================
+void WOKAPI_Workbench::Units(WOKAPI_SequenceOfUnit& unitseq) const
+{
+ unitseq.Clear();
+
+ if(!IsValid()) return;
+
+ Handle(WOKernel_Workbench) abench = *((Handle(WOKernel_Workbench) *) &myEntity);
+ Handle(WOKernel_Session) asession = abench->Session();
+ Handle(WOKernel_DevUnit) aunit;
+ Standard_Integer i;
+
+ Handle(TColStd_HSequenceOfHAsciiString) aseq = abench->Units();
+
+ WOKAPI_Unit apiunit;
+
+ for(i=1; i<= aseq->Length(); i++)
+ {
+ apiunit.Set(asession->GetDevUnit(aseq->Value(i)));
+ unitseq.Append(apiunit);
+ }
+ return;
+}
+
+//=======================================================================
+//function : Units
+//purpose :
+//=======================================================================
+void WOKAPI_Workbench::UnitsOfType(const Handle(TCollection_HAsciiString)& atype,
+ WOKAPI_SequenceOfUnit& unitseq,
+ const Standard_Boolean clearseq) const
+{
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ if(clearseq) unitseq.Clear();
+
+ Handle(WOKernel_Workbench) abench = *((Handle(WOKernel_Workbench) *) &myEntity);
+ Handle(WOKernel_Session) asession = abench->Session();
+ Handle(WOKernel_DevUnit) aunit;
+ Standard_Integer i;
+
+ const Handle(WOKernel_UnitTypeDescr)& typedescr = abench->KnownTypes().GetTypeDescr(atype);
+
+ if(typedescr.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Workbench::UnitsOfType"
+ << "Requesting unit type (" << atype << " is not a valid type in " << UserPath() << endm;
+ return;
+ }
+
+ Standard_Character akey = typedescr->Key();
+
+ Handle(TColStd_HSequenceOfHAsciiString) aseq = abench->Units();
+
+ for(i=1; i<= aseq->Length(); i++)
+ {
+ const Handle(WOKernel_DevUnit)& Kunit = asession->GetDevUnit(aseq->Value(i));
+ if(Kunit->TypeCode() == akey)
+ {
+ WOKAPI_Unit unit;
+ unit.Set(Kunit);
+ unitseq.Append(unit);
+ }
+ }
+ return;
+
+}
+
+//=======================================================================
+//function : Toolkits
+//purpose :
+//=======================================================================
+void WOKAPI_Workbench::Toolkits(WOKAPI_SequenceOfUnit& tkseq) const
+{
+ tkseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Workbench) abench = *((Handle(WOKernel_Workbench) *) &myEntity);
+ Handle(WOKernel_Session) asession = abench->Session();
+ Handle(WOKernel_DevUnit) aunit;
+
+ Handle(TColStd_HSequenceOfHAsciiString) aseq = abench->Visibility();
+ Handle(TColStd_HSequenceOfHAsciiString) units;
+
+ WOKTools_MapOfHAsciiString tks;
+
+ WOKAPI_Unit apiunit;
+
+ for(Standard_Integer i=1; i<=aseq->Length(); i++) {
+ Handle(WOKernel_UnitNesting) nesting = asession->GetUnitNesting(aseq->Value(i));
+
+ if(!nesting.IsNull()) {
+ nesting->Open();
+
+ units = nesting->Units();
+
+ for(Standard_Integer j=1; j<=units->Length(); j++) {
+ aunit = asession->GetDevUnit(units->Value(j));
+
+ if(!aunit.IsNull()) {
+ if(WOKernel_IsToolkit(aunit)) {
+ if (!tks.Contains(aunit->Name())) {
+ tks.Add(aunit->Name());
+ apiunit.Set(aunit);
+ tkseq.Append(apiunit);
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
+
+//=======================================================================
+//function : ImplSuppliers
+//purpose :
+//=======================================================================
+void WOKAPI_Workbench::ImplSuppliers(const Handle(TCollection_HAsciiString)& aunitname,
+ WOKAPI_SequenceOfUnit& unitseq) const
+{
+ unitseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(TColStd_HSequenceOfHAsciiString) aseq;
+ Standard_Integer i;
+
+ Handle(WOKernel_Workbench) abench = *((Handle(WOKernel_Workbench) *) &myEntity);
+ Handle(WOKernel_Locator) alocator = new WOKernel_Locator(abench);
+ Handle(WOKernel_UnitGraph) agraph = new WOKernel_UnitGraph(alocator);
+ Handle(WOKernel_DevUnit) asupplier;
+
+ Handle(WOKernel_DevUnit) aunit = alocator->LocateDevUnit(aunitname);
+ WOKAPI_Unit apiunit;
+
+ if (aunit.IsNull())
+ {
+ // perhaps it's an executable name instead of a unit name
+ Handle(TCollection_HAsciiString) aname;
+ Handle(TCollection_HAsciiString) apart;
+
+ aname = aunitname->Token(":",1);
+ apart = aunitname->Token(":",2);
+
+ aunit = alocator->LocateDevUnit(aname);
+
+ if (aunit.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Workbench::ImplSuppliers"
+ << "Unit " << aname << " : unit does not exist in workbench visibility" << endm;
+ return;
+ }
+ else
+ {
+ if(!WOKernel_IsExecutable(aunit))
+ {
+ ErrorMsg << "WOKAPI_Workbench::ImplSuppliers"
+ << "Unit " << aname << " is not an executable" << endm;
+ return;
+ }
+ aseq = aunit->ImplementationDep(apart,agraph);
+ }
+ }
+
+ else
+ aseq = aunit->ImplementationDep(agraph);
+
+ if ( !aseq.IsNull() )
+ {
+ for(i=1; i<aseq->Length(); i++)
+ {
+ asupplier = alocator->LocateDevUnit(aseq->Value(i));
+ apiunit.Set(asupplier);
+ unitseq.Append(apiunit);
+ }
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Workbench::ImplSuppliers"
+ << "Failed during getting suppliers of " << aunitname << endm;
+ return;
+ }
+
+ return;
+}
+
+//=======================================================================
+//function : ImplClients
+//purpose :
+//=======================================================================
+void WOKAPI_Workbench::ImplClients(const Handle(TCollection_HAsciiString)& aunitname,
+ WOKAPI_SequenceOfUnit& unitseq) const
+{
+
+ Handle(WOKernel_Workbench) abench = Handle(WOKernel_Workbench)::DownCast(myEntity);
+ Handle(WOKernel_Locator) alocator = new WOKernel_Locator(abench);
+ Handle(WOKernel_Session) asession = abench->Session();
+ Handle(WOKernel_UnitGraph) clientgraph = new WOKernel_UnitGraph(alocator);
+ Handle(WOKernel_UnitGraph) agraph = new WOKernel_UnitGraph(alocator);
+ Handle(TColStd_HSequenceOfHAsciiString) aseq = abench->Visibility();
+ Handle(TCollection_HAsciiString) anudname,asuppliername,dummy;
+ WOKTools_MapOfHAsciiString treated;
+ Handle(TColStd_HSequenceOfHAsciiString) uds,suppliers,clients;
+ Standard_Integer i,j,k;
+
+ unitseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_DevUnit) aunit = alocator->LocateDevUnit(aunitname);
+
+ if (aunit.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Workbench::ImplClients"
+ << "Unit " << aunitname << " : unit does not exist in workbench visibility" << endm;
+ return;
+ }
+
+ // construction du graphe des clients
+
+ for(i=1; i<=aseq->Length(); i++)
+ {
+ Handle(WOKernel_UnitNesting) nesting = asession->GetUnitNesting(aseq->Value(i));
+
+ if(!nesting.IsNull())
+ {
+ nesting->Open();
+ uds = nesting->Units();
+
+ for(j=1; j<=uds->Length(); j++)
+ {
+ Handle(WOKernel_DevUnit) anud;
+
+ anud = asession->GetDevUnit(uds->Value(j));
+
+ if(!anud.IsNull())
+ {
+ anudname = anud->Name();
+ if (!treated.Contains(anudname))
+ {
+ suppliers = anud->ImplementationDepList(agraph);
+
+ if (!suppliers.IsNull())
+ {
+ for (k=1; k<=suppliers->Length(); k++)
+ {
+ asuppliername = suppliers->Value(k);
+ clientgraph->Add(asuppliername,anudname);
+ }
+ }
+ else
+ {
+ ErrorMsg << "WOKAPI_Workbench::ImplClients"
+ << "Failed during getting clients of " << aunitname << endm;
+ return;
+ }
+
+ clientgraph->Add(anudname,new TColStd_HSequenceOfHAsciiString); //toutes les Uds doivent apparaitre
+ treated.Add(anudname);
+ }
+ }
+ }
+ }
+ }
+
+ //
+ clients = aunit->ImplClients(clientgraph);
+
+ Handle(WOKernel_DevUnit) aclient;
+ WOKAPI_Unit apiunit;
+
+ if (!clients.IsNull())
+ {
+ for(i=1; i<=clients->Length(); i++)
+ {
+ aclient = alocator->LocateDevUnit(clients->Value(i));
+ if (!aclient.IsNull())
+ {
+ apiunit.Set(aclient);
+ unitseq.Append(apiunit);
+ }
+ }
+ }
+ return;
+}
+
+//=======================================================================
+//function : SortUnitList
+//purpose : order a given list by Implementation dependences
+//=======================================================================
+void WOKAPI_Workbench::SortUnitList(const Handle(TColStd_HSequenceOfHAsciiString)& unitlist,
+ Handle(TColStd_HSequenceOfHAsciiString)& sortedunitlist) const
+{
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Standard_Integer i;
+ Handle(WOKernel_Workbench) abench = *((Handle(WOKernel_Workbench) *) &myEntity);
+ Handle(WOKernel_Locator) alocator = new WOKernel_Locator(abench);
+ Handle(WOKernel_UnitGraph) agraph = new WOKernel_UnitGraph(alocator);
+ WOKTools_MapOfHAsciiString amap;
+
+ Handle(TColStd_HSequenceOfHAsciiString) aunitseq = new TColStd_HSequenceOfHAsciiString;
+ Handle(TColStd_HSequenceOfHAsciiString) anexecseq = new TColStd_HSequenceOfHAsciiString;
+
+ for (i=1 ; i<=unitlist->Length(); i++)
+ {
+ Handle(TCollection_HAsciiString) aunitname = unitlist->Value(i);
+ Handle(WOKernel_DevUnit) aunit = alocator->LocateDevUnit(aunitname);
+
+ if (aunit.IsNull())
+ {
+ // perhaps it's an executable name instead of a unit name
+ Handle(TCollection_HAsciiString) anexecname;
+ Handle(TCollection_HAsciiString) apart;
+
+ anexecname = aunitname->Token(":",1);
+ apart = aunitname->Token(":",2);
+
+ aunit = alocator->LocateDevUnit(anexecname);
+
+ if (aunit.IsNull())
+ {
+ ErrorMsg << "WOKAPI_Workbench::SortUnitList"
+ << "Unit " << anexecname << " : unit does not exist in workbench visibility" << endm;
+ return;
+ }
+ else
+ {
+ if(!WOKernel_IsExecutable(aunit))
+ {
+ ErrorMsg << "WOKAPI_Workbench::SortUnitList"
+ << "Unit " << anexecname << " is not an executable" << endm;
+ return;
+ }
+
+ anexecname->AssignCat("_");
+ anexecname->AssignCat(apart);
+
+ Handle(TColStd_HSequenceOfHAsciiString) execsuppliers = aunit->ImplementationDep(apart,agraph);
+ if ( execsuppliers.IsNull() )
+ {
+ ErrorMsg << "WOKAPI_Workbench::SortUnitList"
+ << "Failed during getting sorted unit list" << endm;
+ return;
+ }
+
+ anexecseq->Append(anexecname);
+ }
+ }
+ else
+ {
+ aunitseq->Append(aunitname);
+
+ if (!amap.Contains(aunitname))
+ amap.Add(aunitname);
+ }
+ }
+
+ Handle(TCollection_HAsciiString) avirtualhead = new TCollection_HAsciiString("HEAD");
+
+ Handle(TColStd_HSequenceOfHAsciiString) unitsuppliers = WOKernel_DevUnit::ImplementationDep(agraph,avirtualhead,aunitseq);
+
+ if ( unitsuppliers.IsNull() )
+ {
+ ErrorMsg << "WOKAPI_Workbench::SortUnitList"
+ << "Failed during getting sorted unit list" << endm;
+ return;
+ }
+
+ sortedunitlist = new TColStd_HSequenceOfHAsciiString;
+
+ for (i=1; i<unitsuppliers->Length(); i++)
+ {
+ Handle(TCollection_HAsciiString) asupplier = unitsuppliers->Value(i);
+ if (amap.Contains(asupplier))
+ {
+ sortedunitlist->Append(asupplier);
+ }
+ }
+ sortedunitlist->Append(anexecseq);
+}
--- /dev/null
+-- File: WOKAPI_Workshop.cdl
+-- Created: Tue Aug 1 16:48:14 1995
+-- Author: Jean GAUTIER
+-- <jga@cobrax>
+---Copyright: Matra Datavision 1995
+
+
+class Workshop from WOKAPI
+inherits Entity from WOKAPI
+
+ ---Purpose:
+
+uses
+
+ Session from WOKAPI,
+ Workbench from WOKAPI,
+ SequenceOfWorkbench from WOKAPI,
+ SequenceOfParcel from WOKAPI,
+ SequenceOfEntity from WOKAPI,
+ Workshop from WOKernel,
+ HSequenceOfParamItem from WOKUtils,
+ ArgTable from WOKTools,
+ Return from WOKTools,
+ HSequenceOfDefine from WOKTools,
+ HAsciiString from TCollection,
+ HSequenceOfHAsciiString from TColStd
+
+is
+
+ Create returns Workshop from WOKAPI;
+
+ Create(aent : Entity from WOKAPI)
+ returns Workshop from WOKAPI;
+
+ Create(asession : Session from WOKAPI;
+ aname : HAsciiString from TCollection;
+ verbose,getit : Boolean from Standard = Standard_True)
+ returns Workshop from WOKAPI;
+
+ BuildParameters(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns HSequenceOfParamItem from WOKUtils;
+
+ Build(me:out; asession : Session from WOKAPI;
+ apath : HAsciiString from TCollection;
+ defines : HSequenceOfDefine from WOKTools;
+ usedefaults : Boolean from Standard)
+ returns Boolean from Standard;
+
+ Destroy(me:out)
+ returns Boolean from Standard
+ is redefined;
+
+ IsValid(me)
+ returns Boolean from Standard
+ is redefined;
+
+ NestedEntities(me; aseq : out SequenceOfEntity from WOKAPI)
+ returns Boolean from Standard
+ is redefined;
+
+ Workbenches(me; benchseq : out SequenceOfWorkbench from WOKAPI );
+
+ UsedParcels(me; parcelseq : out SequenceOfParcel from WOKAPI );
+
+end Workshop;
--- /dev/null
+// File: WOKAPI_Workshop.cxx
+// Created: Tue Aug 1 18:53:50 1995
+// Author: Jean GAUTIER
+// <jga@cobrax>
+
+
+#include <WOKAPI_Workshop.ixx>
+
+#include <WOKAPI_Session.hxx>
+#include <WOKAPI_Factory.hxx>
+#include <WOKAPI_Warehouse.hxx>
+#include <WOKAPI_Workbench.hxx>
+#include <WOKAPI_SequenceOfWorkbench.hxx>
+#include <WOKAPI_Parcel.hxx>
+#include <WOKAPI_SequenceOfParcel.hxx>
+
+#include <WOKernel_Session.hxx>
+#include <WOKernel_Factory.hxx>
+#include <WOKernel_Parcel.hxx>
+#include <WOKernel_Workshop.hxx>
+#include <WOKernel_Workbench.hxx>
+#include <WOKernel_DBMSystem.hxx>
+#include <WOKernel_Station.hxx>
+#include <WOKernel_FileTypeBase.hxx>
+
+#include <WOKTools_Options.hxx>
+#include <WOKTools_Define.hxx>
+#include <WOKTools_HSequenceOfDefine.hxx>
+#include <WOKTools_Return.hxx>
+#include <WOKTools_Messages.hxx>
+#include <WOKUtils_Path.hxx>
+#include <WOKUtils_HSequenceOfParamItem.hxx>
+#include <WOKUtils_ParamItem.hxx>
+
+#include <TCollection_HAsciiString.hxx>
+
+#include <TColStd_HSequenceOfHAsciiString.hxx>
+
+#include <Standard_ErrorHandler.hxx>
+
+//=======================================================================
+//function : WOKAPI_Workshop
+//purpose :
+//=======================================================================
+WOKAPI_Workshop::WOKAPI_Workshop()
+{
+}
+
+///=======================================================================
+//function : WOKAPI_Workshop
+//purpose :
+//=======================================================================
+WOKAPI_Workshop::WOKAPI_Workshop(const WOKAPI_Entity& anent)
+ : WOKAPI_Entity(anent)
+{
+}
+
+//=======================================================================
+//function : WOKAPI_Workshop
+//purpose :
+//=======================================================================
+WOKAPI_Workshop::WOKAPI_Workshop(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Standard_Boolean fatal, const Standard_Boolean getit)
+{
+ Set(asession.GetWorkshop(apath,fatal,getit));
+}
+
+//=======================================================================
+//function : IsValid
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workshop::IsValid() const
+{
+ if(myEntity.IsNull()) return Standard_False;
+ return myEntity->IsKind(STANDARD_TYPE(WOKernel_Workshop));
+}
+
+//=======================================================================
+//function : NestedEntities
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workshop::NestedEntities(WOKAPI_SequenceOfEntity& aseq) const
+{
+ if(!IsValid()) return Standard_False;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ aseq.Clear();
+
+ Handle(WOKernel_Workbench) abench;
+ Handle(WOKernel_Workshop) theshop = Handle(WOKernel_Workshop)::DownCast(myEntity);
+ Handle(WOKernel_Session) asession = theshop->Session();
+
+ Handle(TColStd_HSequenceOfHAsciiString) fullseq = theshop->Workbenches();
+
+ if (!fullseq.IsNull())
+ {
+ WOKAPI_Workbench apibench;
+
+ for(Standard_Integer i=1; i<=fullseq->Length(); i++)
+ {
+ apibench.Set(asession->GetWorkbench(fullseq->Value(i)));
+ aseq.Append(apibench);
+ }
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Workbenches
+//purpose :
+//=======================================================================
+void WOKAPI_Workshop::Workbenches(WOKAPI_SequenceOfWorkbench& benchseq) const
+{
+ Handle(TColStd_HSequenceOfHAsciiString) fullseq;
+ Standard_Integer i;
+
+ benchseq.Clear();
+
+ if(!IsValid()) return;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Workbench) abench;
+ Handle(WOKernel_Workshop) theshop = Handle(WOKernel_Workshop)::DownCast(myEntity);
+ Handle(WOKernel_Session) asession = theshop->Session();
+
+ fullseq = theshop->Workbenches();
+
+ if (!fullseq.IsNull()) {
+ WOKAPI_Workbench apibench;
+
+ for(i=1; i<=fullseq->Length(); i++)
+ {
+ apibench.Set(asession->GetWorkbench(fullseq->Value(i)));
+ benchseq.Append(apibench);
+ }
+ }
+}
+
+//=======================================================================
+//function : UsedParcels
+//purpose :
+//=======================================================================
+void WOKAPI_Workshop::UsedParcels(WOKAPI_SequenceOfParcel& parcseq) const
+{
+ Handle(TColStd_HSequenceOfHAsciiString) fullseq;
+ Standard_Integer i;
+
+ parcseq.Clear();
+
+ if(!IsValid()) return ;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Parcel) aparcel;
+ Handle(WOKernel_Workshop) theshop = Handle(WOKernel_Workshop)::DownCast(myEntity);
+ Handle(WOKernel_Session) asession = theshop->Session();
+
+ fullseq = theshop->ParcelsInUse();
+
+ WOKAPI_Parcel apiparcel;
+
+ for(i=1; i<=fullseq->Length(); i++)
+ {
+ apiparcel.Set(asession->GetParcel(fullseq->Value(i)));
+ parcseq.Append(apiparcel);
+ }
+
+ return;
+}
+
+//=======================================================================
+//function : BuildParameters
+//purpose :
+//=======================================================================
+Handle(WOKUtils_HSequenceOfParamItem) WOKAPI_Workshop::BuildParameters(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+{
+ Handle(WOKUtils_HSequenceOfParamItem) aseq;
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+ Handle(WOKernel_Workshop) Kshop;
+ Handle(WOKernel_Factory) Kfact;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Factory afact(asession,nestname);
+
+ if(!afact.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Workshop::Build"
+ << "Invalid nesting (" << nestname << ") to create workshop : " << name << endm;
+ return aseq;
+ }
+
+ WOKAPI_Warehouse aware = afact.Warehouse();
+ if(!aware.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Workshop::Build"
+ << "No valid warehouse in factory : " << afact.Name() << endm;
+ return aseq;
+ }
+
+ Kfact = Handle(WOKernel_Factory)::DownCast(afact.Entity());
+
+ Kshop = new WOKernel_Workshop(name,Kfact);
+ Set(Kshop);
+
+ aseq = GetBuildParameters(asession, name, afact, defines, usedefaults);
+
+ return aseq;
+}
+
+//=======================================================================
+//function : Build
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workshop::Build(const WOKAPI_Session& asession,
+ const Handle(TCollection_HAsciiString)& apath,
+ const Handle(WOKTools_HSequenceOfDefine)& defines,
+ const Standard_Boolean usedefaults)
+
+{
+ Handle(TCollection_HAsciiString) name;
+ Handle(TCollection_HAsciiString) nestname;
+ Handle(WOKernel_Workshop) Kshop;
+ Handle(WOKernel_Factory) Kfact;
+
+ name = BuildName(apath);
+ nestname = BuildNesting(apath);
+
+ WOKAPI_Factory afact(asession,nestname);
+
+ if(!afact.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Workshop::Build"
+ << "Invalid nesting (" << nestname << ") to create workshop : " << name << endm;
+ return Standard_True;
+ }
+
+ WOKAPI_Warehouse aware = afact.Warehouse();
+
+ if(!aware.IsValid())
+ {
+ ErrorMsg << "WOKAPI_Workshop::Build"
+ << "No valid warehouse in factory : " << afact.Name() << endm;
+ return Standard_True;
+ }
+
+ Kfact = Handle(WOKernel_Factory)::DownCast(afact.Entity());
+ UpdateBeforeBuild(Kfact);
+
+ Kshop = new WOKernel_Workshop(name,Kfact);
+ Set(Kshop);
+
+ if(!BuildEntity(asession, name, afact, defines, usedefaults))
+ {
+ Kfact->AddWorkshop(Kshop);
+ Kshop->Open();
+ }
+ else return Standard_True;
+ return Standard_False;
+}
+
+//=======================================================================
+//function : Destroy
+//purpose :
+//=======================================================================
+Standard_Boolean WOKAPI_Workshop::Destroy()
+{
+ if(!IsValid()) return Standard_True;
+ if(!myEntity->IsOpened()) myEntity->Open();
+
+ Handle(WOKernel_Factory) afactory = myEntity->Session()->GetFactory(myEntity->Nesting());
+
+ UpdateBeforeDestroy(afactory);
+ if (!IsValid()) return Standard_True;
+
+ Handle(WOKernel_Workshop) aworkshop = Handle(WOKernel_Workshop)::DownCast(myEntity);
+ aworkshop->Open();
+
+ if(aworkshop->Workbenches()->Length())
+ {
+ ErrorMsg << "WOKAPI_Workshop::Destroy"
+ << "Cannot destroy not empty workshop" << endm;
+ return Standard_True;
+ }
+
+ aworkshop->Destroy();
+
+ afactory->RemoveWorkshop(aworkshop);
+ myEntity.Nullify();
+ return Standard_False;
+}
+
+
+