Skip to content
Snippets Groups Projects
Commit d6fa1507 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

AttLimits is moved from Fit to Core library. RealParameterWrapper now carries AttLimits on boiard.

parent 9c88da34
No related branches found
No related tags found
No related merge requests found
File moved
......@@ -18,6 +18,7 @@
#include "WinDllMacros.h"
#include "Exceptions.h"
#include "AttLimits.h"
#include <ostream>
......@@ -28,40 +29,56 @@
class BA_CORE_API_ RealParameterWrapper {
public:
explicit RealParameterWrapper(double *par) : m_data(par) {}
// explicit RealParameterWrapper(double *par) : m_data(par), m_signal() {}
explicit RealParameterWrapper(double *par, const AttLimits &limits = AttLimits::limitless());
RealParameterWrapper(const RealParameterWrapper& other );
RealParameterWrapper& operator=(const RealParameterWrapper& other);
~RealParameterWrapper(){}
//! Sets value of wrapped parameter and emmit signal
void setValue(double value)
{
checkNull();
if(value != *m_data) {
*m_data = value;
// m_signal();
}
}
bool setValue(double value);
//! Returns value of wrapped parameter
double getValue() const { checkNull(); return *m_data; }
double getValue() const;
//! Returns true if wrapped parameter was not initialized with proper real value
bool isNull() const { return (m_data ? false : true); }
bool isNull() const;
//! throw exception if parameter was not initialized with proper value
void checkNull() const { if(isNull()) throw NullPointerException("RealParameterWrapper::getValue() -> Attempt to access uninitialised pointer."); }
void checkNull() const;
//! Prints the parameter's address to an output stream
friend std::ostream& operator<<(std::ostream& ostr, const RealParameterWrapper& p) { ostr << p.m_data; return ostr; }
friend std::ostream& operator<<(std::ostream& ostr, const RealParameterWrapper& p)
{
ostr << p.m_data; return ostr;
}
private:
//! swap function
void swapContent(RealParameterWrapper& other);
volatile double *m_data;
AttLimits m_limits;
};
inline double RealParameterWrapper::getValue() const
{
checkNull();
return *m_data;
}
inline bool RealParameterWrapper::isNull() const
{
return (m_data ? false : true);
}
inline void RealParameterWrapper::checkNull() const
{
if(isNull())
throw NullPointerException(
"RealParameterWrapper::getValue() -> Attempt to access uninitialised pointer.");
}
#endif // REALPARAMETERPROXY_H
......@@ -15,9 +15,17 @@
#include "RealParameterWrapper.h"
RealParameterWrapper::RealParameterWrapper(double *par, const AttLimits &limits)
: m_data(par)
, m_limits(limits)
{
}
RealParameterWrapper::RealParameterWrapper(const RealParameterWrapper& other )
{
m_data = other.m_data;
m_limits = other.m_limits;
}
RealParameterWrapper& RealParameterWrapper::operator=(const RealParameterWrapper& other)
......@@ -29,9 +37,20 @@ RealParameterWrapper& RealParameterWrapper::operator=(const RealParameterWrapper
return *this;
}
bool RealParameterWrapper::setValue(double value)
{
bool success(true);
checkNull();
if(value != *m_data) {
*m_data = value;
}
return success;
}
void RealParameterWrapper::swapContent(RealParameterWrapper& other)
{
std::swap(this->m_data, other.m_data);
std::swap(this->m_limits, other.m_limits);
}
......@@ -3,6 +3,7 @@
#endif
#include "gtest/gtest.h"
#include "AttLimitsTest.h"
#include "BeamTest.h"
#include "ChiSquaredModuleTest.h"
#include "CVectorTest.h"
......
......@@ -3,7 +3,6 @@
#endif
#include "gtest/gtest.h"
#include "AttLimitsTest.h"
#include "FitParameterTest.h"
#include "FitParameterLinkedTest.h"
#include "MinimizerOptionsTest.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment