fix compile on gcc 4.1.2, armv5tel
parent
3202bf2809
commit
f8f2e7fee1
45
algparam.cpp
45
algparam.cpp
|
|
@ -46,63 +46,30 @@ bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_inf
|
|||
}
|
||||
|
||||
AlgorithmParameters::AlgorithmParameters()
|
||||
: m_constructed(false), m_defaultThrowIfNotUsed(true)
|
||||
: m_defaultThrowIfNotUsed(true)
|
||||
{
|
||||
new(m_first) member_ptr<AlgorithmParametersBase>;
|
||||
}
|
||||
|
||||
AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x)
|
||||
: m_constructed(false), m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
|
||||
: m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
|
||||
{
|
||||
if (x.m_constructed)
|
||||
{
|
||||
x.First().MoveInto(m_first);
|
||||
m_constructed = true;
|
||||
}
|
||||
else
|
||||
new(m_first) member_ptr<AlgorithmParametersBase>(x.Next().release());
|
||||
}
|
||||
|
||||
AlgorithmParameters::~AlgorithmParameters()
|
||||
{
|
||||
if (m_constructed)
|
||||
First().~AlgorithmParametersBase();
|
||||
else
|
||||
Next().~member_ptr<AlgorithmParametersBase>();
|
||||
m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
|
||||
}
|
||||
|
||||
AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
|
||||
{
|
||||
if (this == &x)
|
||||
return *this;
|
||||
this->~AlgorithmParameters();
|
||||
new (this) AlgorithmParameters(x);
|
||||
m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
|
||||
{
|
||||
if (m_constructed)
|
||||
return First().GetVoidValue(name, valueType, pValue);
|
||||
else if (Next().get())
|
||||
return Next()->GetVoidValue(name, valueType, pValue);
|
||||
if (m_next.get())
|
||||
return m_next->GetVoidValue(name, valueType, pValue);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
AlgorithmParametersBase & AlgorithmParameters::First()
|
||||
{
|
||||
return *reinterpret_cast<AlgorithmParametersBase *>(m_first);
|
||||
}
|
||||
|
||||
member_ptr<AlgorithmParametersBase> & AlgorithmParameters::Next()
|
||||
{
|
||||
if (m_constructed)
|
||||
return First().m_next;
|
||||
else
|
||||
return *reinterpret_cast<member_ptr<AlgorithmParametersBase> *>(m_first);
|
||||
}
|
||||
|
||||
NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
25
algparam.h
25
algparam.h
|
|
@ -337,26 +337,14 @@ public:
|
|||
|
||||
AlgorithmParameters(const AlgorithmParameters &x);
|
||||
|
||||
~AlgorithmParameters();
|
||||
|
||||
AlgorithmParameters & operator=(const AlgorithmParameters &x);
|
||||
|
||||
template <class T>
|
||||
AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
|
||||
{
|
||||
if (m_constructed || sizeof(m_first) < sizeof(AlgorithmParametersTemplate<T>))
|
||||
{
|
||||
member_ptr<AlgorithmParametersBase> p(new AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed));
|
||||
p->m_next.reset(Next().release());
|
||||
Next().reset(p.release());
|
||||
}
|
||||
else
|
||||
{
|
||||
member_ptr<AlgorithmParametersBase> temp(Next().release());
|
||||
AlgorithmParametersTemplate<T>* p = new(m_first) AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed);
|
||||
p->m_next.reset(temp.release());
|
||||
m_constructed = true;
|
||||
}
|
||||
p->m_next.reset(m_next.release());
|
||||
m_next.reset(p.release());
|
||||
m_defaultThrowIfNotUsed = throwIfNotUsed;
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -370,13 +358,8 @@ public:
|
|||
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
|
||||
|
||||
protected:
|
||||
AlgorithmParametersBase & First();
|
||||
member_ptr<AlgorithmParametersBase> & Next();
|
||||
const AlgorithmParametersBase & First() const {return const_cast<AlgorithmParameters *>(this)->First();}
|
||||
member_ptr<AlgorithmParametersBase> & Next() const {return const_cast<AlgorithmParameters *>(this)->Next();}
|
||||
|
||||
bool m_constructed, m_defaultThrowIfNotUsed;
|
||||
size_t m_first[(sizeof(AlgorithmParametersBase) + 19)/sizeof(size_t)];
|
||||
member_ptr<AlgorithmParametersBase> m_next;
|
||||
bool m_defaultThrowIfNotUsed;
|
||||
};
|
||||
|
||||
//! Create an object that implements NameValuePairs for passing parameters
|
||||
|
|
|
|||
Loading…
Reference in New Issue