]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/Test/PluginOptEvTest1.cxx
Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / engine / Test / PluginOptEvTest1.cxx
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "PluginOptEvTest1.hxx"
20 #include "TypeCode.hxx"
21 #include "Pool.hxx"
22
23 #include <cmath>
24
25 using namespace YACS::ENGINE;
26
27 PluginOptEvTest1::PluginOptEvTest1(Pool *pool):OptimizerAlgSync(pool),_tcIn(0),_tcOut(0),_idTest(0)
28 {
29   _tcIn=new TypeCode(Double);
30   _tcOut=new TypeCode(Int);
31 }
32
33 PluginOptEvTest1::~PluginOptEvTest1()
34 {
35   _tcIn->decrRef();
36   _tcOut->decrRef();
37 }
38
39 TypeCode *PluginOptEvTest1::getTCForIn() const
40 {
41   return _tcIn;
42 }
43
44 TypeCode *PluginOptEvTest1::getTCForOut() const
45 {
46   return _tcOut;
47 }
48
49 void PluginOptEvTest1::parseFileToInit(const std::string& fileName)
50 {
51 }
52
53 void PluginOptEvTest1::start()
54 {
55   _idTest=0;
56   Any *val=AtomAny::New(1.2);
57   _pool->pushInSample(4,val);
58   val=AtomAny::New(3.4);
59   _pool->pushInSample(9,val);
60 }
61
62 void PluginOptEvTest1::takeDecision()
63 {
64   if(_idTest==1)
65     {
66       Any *val=AtomAny::New(5.6);
67       _pool->pushInSample(16,val);
68       val=AtomAny::New(7.8);
69       _pool->pushInSample(25,val);
70       val=AtomAny::New(9. );
71       _pool->pushInSample(36,val);
72       val=AtomAny::New(12.3);
73       _pool->pushInSample(49,val);
74     }
75   else if(_idTest==4)
76     {
77       Any *val=AtomAny::New(45.6);
78       _pool->pushInSample(64,val);
79       val=AtomAny::New(78.9);
80       _pool->pushInSample(81,val);
81     }
82   else
83     {
84       Any *tmp= _pool->getCurrentInSample();
85       if(fabs(tmp->getDoubleValue()-45.6)<1.e-12)
86         _pool->destroyAll();
87     }
88   _idTest++;
89 }
90
91 void PluginOptEvTest1::initialize(const Any *input) throw (Exception)
92 {
93 }
94
95 void PluginOptEvTest1::finish()
96 {
97 }
98
99 OptimizerAlgBase *PluginOptEvTest1Factory(Pool *pool)
100 {
101   return new PluginOptEvTest1(pool);
102 }