1 // Copyright (C) 2006-2014 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, or (at your option) any later version.
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";
133 void OptimizerAlgBase::setNbOfBranches(int nbOfBranches)
135 _nbOfBranches=nbOfBranches;
138 int OptimizerAlgBase::getNbOfBranches() const
140 return _nbOfBranches;
143 OptimizerAlgASync::OptimizerAlgASync(Pool *pool):OptimizerAlgBase(pool)
147 OptimizerAlgASync::~OptimizerAlgASync()
151 void OptimizerAlgASync::finishProxy()
153 terminateSlaveThread();
154 OptimizerAlgBase::finishProxy();
157 void OptimizerAlgASync::takeDecision()
159 signalSlaveAndWait();
162 void OptimizerAlgASync::start()
164 AlternateThread::start();
167 void OptimizerAlgASync::run()
169 startToTakeDecision();