$treeview $search $mathjax
StdAir Logo  1.00.1
$projectbrief
$projectbrief
$searchbox

stdair/basic/UnconstrainingMethod.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // StdAir
00008 #include <stdair/stdair_exceptions.hpp>
00009 #include <stdair/basic/UnconstrainingMethod.hpp>
00010 
00011 namespace stdair {
00012   
00013   // //////////////////////////////////////////////////////////////////////
00014   const std::string UnconstrainingMethod::_labels[LAST_VALUE] =
00015     { "Expectation-Maximisation" };
00016 
00017   // //////////////////////////////////////////////////////////////////////
00018   const char UnconstrainingMethod::
00019   _methodLabels[LAST_VALUE] = { 'E' };
00020 
00021   
00022   // //////////////////////////////////////////////////////////////////////
00023   UnconstrainingMethod::UnconstrainingMethod()
00024     : _method (LAST_VALUE) {
00025     assert (false);
00026   }
00027 
00028   // //////////////////////////////////////////////////////////////////////
00029   UnconstrainingMethod::
00030   UnconstrainingMethod (const UnconstrainingMethod& iUnconstrainingMethod)
00031     : _method (iUnconstrainingMethod._method) {
00032   }
00033 
00034   // //////////////////////////////////////////////////////////////////////
00035   UnconstrainingMethod::
00036   UnconstrainingMethod (const EN_UnconstrainingMethod& iUnconstrainingMethod)
00037     : _method (iUnconstrainingMethod) {
00038   }
00039 
00040   // //////////////////////////////////////////////////////////////////////
00041   UnconstrainingMethod::UnconstrainingMethod (const char iMethod) {
00042     switch (iMethod) {
00043     case 'E': _method = EM; break;
00044     default: _method = LAST_VALUE; break;
00045     }
00046 
00047     if (_method == LAST_VALUE) {
00048       const std::string& lLabels = describeLabels();
00049       std::ostringstream oMessage;
00050       oMessage << "The unconstraining method '" << iMethod
00051                << "' is not known. Known unconstraining methods: " << lLabels;
00052       throw CodeConversionException (oMessage.str());
00053     }
00054   }
00055   
00056   // //////////////////////////////////////////////////////////////////////
00057   const std::string& UnconstrainingMethod::
00058   getLabel (const EN_UnconstrainingMethod& iMethod) {
00059     return _labels[iMethod];
00060   }
00061   
00062   // //////////////////////////////////////////////////////////////////////
00063   char UnconstrainingMethod::getMethodLabel (const EN_UnconstrainingMethod& iMethod) {
00064     return _methodLabels[iMethod];
00065   }
00066 
00067   // //////////////////////////////////////////////////////////////////////
00068   std::string UnconstrainingMethod::
00069   getMethodLabelAsString (const EN_UnconstrainingMethod& iMethod) {
00070     std::ostringstream oStr;
00071     oStr << _methodLabels[iMethod];
00072     return oStr.str();
00073   }
00074 
00075   // //////////////////////////////////////////////////////////////////////
00076   std::string UnconstrainingMethod::describeLabels() {
00077     std::ostringstream ostr;
00078     for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) {
00079       if (idx != 0) {
00080         ostr << ", ";
00081       }
00082       ostr << _labels[idx] << " (" << _methodLabels[idx] << ")";
00083     }
00084     return ostr.str();
00085   }
00086 
00087   // //////////////////////////////////////////////////////////////////////
00088   UnconstrainingMethod::EN_UnconstrainingMethod UnconstrainingMethod::getMethod() const {
00089     return _method;
00090   }
00091   
00092   // //////////////////////////////////////////////////////////////////////
00093   std::string UnconstrainingMethod::getMethodAsString() const {
00094     std::ostringstream oStr;
00095     oStr << _methodLabels[_method];
00096     return oStr.str();
00097   }
00098   
00099   // //////////////////////////////////////////////////////////////////////
00100   const std::string UnconstrainingMethod::describe() const {
00101     std::ostringstream ostr;
00102     ostr << _labels[_method];
00103     return ostr.str();
00104   }
00105 
00106   // //////////////////////////////////////////////////////////////////////
00107   bool UnconstrainingMethod::
00108   operator== (const EN_UnconstrainingMethod& iMethod) const {
00109     return (_method == iMethod);
00110   }
00111   
00112 }