From 122b7442c1012167eddc78f378fe15f22aefc572 Mon Sep 17 00:00:00 2001 From: LPTK Date: Wed, 12 Jun 2013 15:26:27 +0200 Subject: [PATCH] created eoOptional --- eo/src/eoOptional.h | 79 ++++++++++++++++++++++++++ mo/src/continuator/moStdDevEstimator.h | 34 ----------- 2 files changed, 79 insertions(+), 34 deletions(-) create mode 100644 eo/src/eoOptional.h diff --git a/eo/src/eoOptional.h b/eo/src/eoOptional.h new file mode 100644 index 000000000..d3cdbff80 --- /dev/null +++ b/eo/src/eoOptional.h @@ -0,0 +1,79 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +/* +(c) Thales group, 2013 + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; + version 2 of the License. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact: http://eodev.sourceforge.net + +Authors: +Lionel Parreaux + +*/ + +/** @defgroup Logging Logging + * @ingroup Utilities + + + +@{ +*/ + +#ifndef _EOOPTIONAL_H +#define _EOOPTIONAL_H + +#include + + +template< class T > +class eoOptional { +public: + static const eoOptional null; // = eoOptional(); + + eoOptional (T& init) + : _val(&init) + { } + + bool hasValue() const + { + return _val != NULL; + } + + T& get () const + { + if (!hasValue()) + throw std::runtime_error("Cannot get a reference from a eoOptional wrapper with no value"); + return *_val; + } + +protected: + eoOptional () + : _val(NULL) + { } + +private: + T* _val; +}; + +template< class T > +const eoOptional eoOptional::null = eoOptional(); + + +#endif // _EOOPTIONAL_H + + +/** @} */ + diff --git a/mo/src/continuator/moStdDevEstimator.h b/mo/src/continuator/moStdDevEstimator.h index 4d8902055..ff3b645d2 100644 --- a/mo/src/continuator/moStdDevEstimator.h +++ b/mo/src/continuator/moStdDevEstimator.h @@ -9,40 +9,6 @@ // TODO make tests -template< class T > -class eoOptional { -public: - static const eoOptional null; // = eoOptional(); - - eoOptional (T& init) - : _val(&init) - { } - - bool hasValue() const - { - return _val != NULL; - } - - T& get () const - { - if (!hasValue()) - throw std::runtime_error("Cannot get a reference from a eoOptional wrapper with no value"); - return *_val; - } - -protected: - eoOptional () - : _val(NULL) - { } - -private: - T* _val; -}; - -template< class T > -const eoOptional eoOptional::null = eoOptional(); - - template< class EOT, class Neighbor > class moStdDevEstimator : public eoUF {