Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / Test / PluginOptEvTest1.cxx
1 #include "PluginOptEvTest1.hxx"
2 #include "TypeCode.hxx"
3 #include "Pool.hxx"
4
5 #include <cmath>
6
7 using namespace YACS::ENGINE;
8
9 PluginOptEvTest1::PluginOptEvTest1(Pool *pool):OptimizerAlgSync(pool),_tcIn(0),_tcOut(0),_idTest(0)
10 {
11   _tcIn=new TypeCode(Double);
12   _tcOut=new TypeCode(Int);
13 }
14
15 PluginOptEvTest1::~PluginOptEvTest1()
16 {
17   _tcIn->decrRef();
18   _tcOut->decrRef();
19 }
20
21 TypeCode *PluginOptEvTest1::getTCForIn() const
22 {
23   return _tcIn;
24 }
25
26 TypeCode *PluginOptEvTest1::getTCForOut() const
27 {
28   return _tcOut;
29 }
30
31 void PluginOptEvTest1::parseFileToInit(const std::string& fileName)
32 {
33 }
34
35 void PluginOptEvTest1::start()
36 {
37   _idTest=0;
38   Any *val=AtomAny::New(1.2);
39   _pool->pushInSample(4,val);
40   val=AtomAny::New(3.4);
41   _pool->pushInSample(9,val);
42 }
43
44 void PluginOptEvTest1::takeDecision()
45 {
46   if(_idTest==1)
47     {
48       Any *val=AtomAny::New(5.6);
49       _pool->pushInSample(16,val);
50       val=AtomAny::New(7.8);
51       _pool->pushInSample(25,val);
52       val=AtomAny::New(9. );
53       _pool->pushInSample(36,val);
54       val=AtomAny::New(12.3);
55       _pool->pushInSample(49,val);
56     }
57   else if(_idTest==4)
58     {
59       Any *val=AtomAny::New(45.6);
60       _pool->pushInSample(64,val);
61       val=AtomAny::New(78.9);
62       _pool->pushInSample(81,val);
63     }
64   else
65     {
66       Any *tmp= _pool->getCurrentInSample();
67       if(fabs(tmp->getDoubleValue()-45.6)<1.e-12)
68         _pool->destroyAll();
69     }
70   _idTest++;
71 }
72
73 void PluginOptEvTest1::initialize(const Any *input) throw (Exception)
74 {
75 }
76
77 void PluginOptEvTest1::finish()
78 {
79 }
80
81 OptimizerAlgBase *PluginOptEvTest1Factory(Pool *pool)
82 {
83   return new PluginOptEvTest1(pool);
84 }