1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "OptimizerAlg.hxx"
21 #include "Runtime.hxx"
23 using namespace YACS::BASES;
24 using namespace YACS::ENGINE;
26 OptimizerAlgBase::OptimizerAlgBase(Pool *pool):_pool(pool), _proc(NULL)
30 OptimizerAlgBase::~OptimizerAlgBase()
34 void OptimizerAlgBase::initialize(const Any *input) throw (YACS::Exception)
38 void OptimizerAlgBase::finish()
42 TypeCode * OptimizerAlgBase::getTCForAlgoInit() const
44 return Runtime::_tc_string;
47 TypeCode * OptimizerAlgBase::getTCForAlgoResult() const
49 return Runtime::_tc_string;
52 Any * OptimizerAlgBase::getAlgoResult()
57 TypeCode * OptimizerAlgBase::getTCForInProxy() const
62 TypeCode * OptimizerAlgBase::getTCForOutProxy() const
67 TypeCode * OptimizerAlgBase::getTCForAlgoInitProxy() const
69 return getTCForAlgoInit();
72 TypeCode * OptimizerAlgBase::getTCForAlgoResultProxy() const
74 return getTCForAlgoResult();
77 void OptimizerAlgBase::initializeProxy(const Any *input) throw (YACS::Exception)
82 void OptimizerAlgBase::startProxy()
87 void OptimizerAlgBase::takeDecisionProxy()
92 void OptimizerAlgBase::finishProxy()
98 Any * OptimizerAlgBase::getAlgoResultProxy()
100 return getAlgoResult();
103 void OptimizerAlgBase::setPool(Pool* pool)
108 void OptimizerAlgBase::setProc(Proc * proc)
113 Proc * OptimizerAlgBase::getProc()
118 bool OptimizerAlgBase::hasError() const
120 return (_errorMessage.length() > 0);
123 const std::string & OptimizerAlgBase::getError() const
125 return _errorMessage;
128 void OptimizerAlgBase::setError(const std::string & message)
130 _errorMessage = (message.length() > 0) ? message : "Unknown error";
134 OptimizerAlgASync::OptimizerAlgASync(Pool *pool):OptimizerAlgBase(pool)
138 OptimizerAlgASync::~OptimizerAlgASync()
142 void OptimizerAlgASync::finishProxy()
144 terminateSlaveThread();
145 OptimizerAlgBase::finishProxy();
148 void OptimizerAlgASync::takeDecision()
150 signalSlaveAndWait();
153 void OptimizerAlgASync::start()
155 AlternateThread::start();
158 void OptimizerAlgASync::run()
160 startToTakeDecision();