BEGIN_NCBI_SCOPE ///////////////////////////////////////////////////////////////////////////// impl::CDBExceptionStorage& GetCTLExceptionStorage(void) { static CStaticTls<impl::CDBExceptionStorage> instance; impl::CDBExceptionStorage* result = instance.GetValue(); if (!result) { auto_ptr<impl::CDBExceptionStorage> tmp_value(new impl::CDBExceptionStorage); instance.SetValue(tmp_value.get(), s_DelExceptionStorage); result = tmp_value.release(); } return *result; }
//------------------------------------------------------------------------- //! @brief This is the callback function which is passed to the Signal in //! the model's constructor. //! //! Here the value is retrieved and appended to the list. If the list is too //! large, the oldest value is removed. The Validity is updated, and the //! Signal is emitted, telling others that the values have been updated. //! //! @todo Make the 'average value' calculation more efficient. //------------------------------------------------------------------------- void ValueList::update() { variant tmp_value( retrieve_value__() ); // Make tmp_average the same 'type' as tmp_value and set it to '0'. variant tmp_average = tmp_value; tmp_average.zero(); if( max_value__.isEmpty() ) { max_value__ = tmp_value; max_value__.zero(); } values__.push_back( tmp_value ); if( values__.size() > list_size__ ) values__.pop_front(); std::for_each( values__.begin() , values__.end() , [&]( variant const& _var ) { tmp_average = tmp_average + _var; } ); average_value__ = tmp_average / values__.size(); if( tmp_value > max_value__ ) { max_value__ = tmp_value; max_value_position__ = 0; } else ++max_value_position__; if( max_value_position__ >= list_size__ ) findMaxValue(); validity__ = Validity::ENABLED; signal__->emit(); }