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()
|
AlgorithmParameters::AlgorithmParameters()
|
||||||
: m_constructed(false), m_defaultThrowIfNotUsed(true)
|
: m_defaultThrowIfNotUsed(true)
|
||||||
{
|
{
|
||||||
new(m_first) member_ptr<AlgorithmParametersBase>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x)
|
AlgorithmParameters::AlgorithmParameters(const AlgorithmParameters &x)
|
||||||
: m_constructed(false), m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
|
: m_defaultThrowIfNotUsed(x.m_defaultThrowIfNotUsed)
|
||||||
{
|
{
|
||||||
if (x.m_constructed)
|
m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
|
||||||
{
|
|
||||||
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>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
|
AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
|
||||||
{
|
{
|
||||||
if (this == &x)
|
m_next.reset(const_cast<AlgorithmParameters &>(x).m_next.release());
|
||||||
return *this;
|
|
||||||
this->~AlgorithmParameters();
|
|
||||||
new (this) AlgorithmParameters(x);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
|
bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
|
||||||
{
|
{
|
||||||
if (m_constructed)
|
if (m_next.get())
|
||||||
return First().GetVoidValue(name, valueType, pValue);
|
return m_next->GetVoidValue(name, valueType, pValue);
|
||||||
else if (Next().get())
|
|
||||||
return Next()->GetVoidValue(name, valueType, pValue);
|
|
||||||
else
|
else
|
||||||
return false;
|
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
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
25
algparam.h
25
algparam.h
|
|
@ -337,26 +337,14 @@ public:
|
||||||
|
|
||||||
AlgorithmParameters(const AlgorithmParameters &x);
|
AlgorithmParameters(const AlgorithmParameters &x);
|
||||||
|
|
||||||
~AlgorithmParameters();
|
|
||||||
|
|
||||||
AlgorithmParameters & operator=(const AlgorithmParameters &x);
|
AlgorithmParameters & operator=(const AlgorithmParameters &x);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
|
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));
|
member_ptr<AlgorithmParametersBase> p(new AlgorithmParametersTemplate<T>(name, value, throwIfNotUsed));
|
||||||
p->m_next.reset(Next().release());
|
p->m_next.reset(m_next.release());
|
||||||
Next().reset(p.release());
|
m_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;
|
|
||||||
}
|
|
||||||
m_defaultThrowIfNotUsed = throwIfNotUsed;
|
m_defaultThrowIfNotUsed = throwIfNotUsed;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
@ -370,13 +358,8 @@ public:
|
||||||
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
|
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AlgorithmParametersBase & First();
|
member_ptr<AlgorithmParametersBase> m_next;
|
||||||
member_ptr<AlgorithmParametersBase> & Next();
|
bool m_defaultThrowIfNotUsed;
|
||||||
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)];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Create an object that implements NameValuePairs for passing parameters
|
//! Create an object that implements NameValuePairs for passing parameters
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue