1 // SimpleDriver.cpp: implementation of the SimpleDriver class.
3 //////////////////////////////////////////////////////////////////////
5 #include "SimpleDriver.h"
7 #include <TDF_Reference.hxx>
8 #include <TDF_ChildIterator.hxx>
9 #include <Standard_GUID.hxx>
10 #include <OSD_Timer.hxx>
11 #include <TDataStd_Real.hxx>
12 #include <BRepPrimAPI_MakeSphere.hxx>
14 IMPLEMENT_STANDARD_HANDLE(SimpleDriver, TFunction_Driver)
15 IMPLEMENT_STANDARD_RTTIEXT(SimpleDriver, TFunction_Driver)
17 // ID of the function driver
18 const Standard_GUID& SimpleDriver::GetID()
20 static const Standard_GUID id("4534840D-6DCD-440f-9F0E-BDEF1C50D434");
25 SimpleDriver::SimpleDriver()
30 // Returns the arguments of the function
31 void SimpleDriver::Arguments(TDF_LabelList& args) const
33 // A double - relative time of execution
36 // References to other functions through TDF_Reference
37 TDF_ChildIterator itr(Label().FindChild(1), false);
38 for (; itr.More(); itr.Next())
40 Handle(TDF_Reference) ref;
41 if (itr.Value().FindAttribute(TDF_Reference::GetID(), ref))
42 args.Append(ref->Get());
47 // Returns the results of the function
48 void SimpleDriver::Results(TDF_LabelList& res) const
50 // References to other functions through TDF_Reference
52 TDF_ChildIterator itr(Label().FindChild(2), false);
53 for (; itr.More(); itr.Next())
55 Handle(TDF_Reference) ref;
56 if (itr.Value().FindAttribute(TDF_Reference::GetID(), ref))
57 res.Append(ref->Get());
62 Standard_Integer SimpleDriver::Execute(Handle(TFunction_Logbook)& log) const
64 // Check initialization
68 // Take the double argument
69 Handle(TDataStd_Real) time_keeper;
70 if (!Label().FindAttribute(TDataStd_Real::GetID(), time_keeper))
72 double times = time_keeper->Get();
74 // Make a sphere 10000 * "times" times (it takes about a second on a simple computer).
76 while (++i < 10000 * times)
78 // Call any fucntions taking much time.
79 // It is necessary to "see" the execution of a function in real time.
80 BRepPrimAPI_MakeSphere mkSphere(100.0);