PIVariantSimple now has no error when assign to non-copyable typeName
patch pip_cmg according to last PIByteArray changes plugin system fix
This commit is contained in:
@@ -40,12 +40,21 @@ public:
|
||||
virtual void deleteT(void *& ptr) {;}
|
||||
//virtual PIByteArray toData(const void * ptr) const {return PIByteArray();}
|
||||
//virtual void fromData(void *& ptr, PIByteArray ba) {;}
|
||||
static PIMap<uint, __VariantFunctionsBase__*> & registered() {static PIMap<uint, __VariantFunctionsBase__*> ret; return ret;}
|
||||
//static PIMap<uint, __VariantFunctionsBase__*> & registered() {static PIMap<uint, __VariantFunctionsBase__*> ret; return ret;}
|
||||
};
|
||||
|
||||
|
||||
template<class T, class Enable = void>
|
||||
class __VariantFunctions__: public __VariantFunctionsBase__ {
|
||||
public:
|
||||
__VariantFunctionsBase__ * instance() final {static __VariantFunctions__<T> ret; return &ret;}
|
||||
PIString typeName() const final {static PIString ret(typeid(T).name()); return ret;}
|
||||
uint hash() const final {static uint ret = typeName().hash(); return ret;}
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class __VariantFunctions__: public __VariantFunctionsBase__ {
|
||||
class __VariantFunctions__<T, typename std::enable_if< std::is_assignable<T&, const T&>::value>::type>: public __VariantFunctionsBase__ {
|
||||
public:
|
||||
__VariantFunctionsBase__ * instance() final {static __VariantFunctions__<T> ret; return &ret;}
|
||||
PIString typeName() const final {static PIString ret(typeid(T).name()); return ret;}
|
||||
@@ -58,6 +67,7 @@ public:
|
||||
//void fromData(void *& ptr, PIByteArray ba) final {ba >> *(T*)ptr;}
|
||||
};
|
||||
|
||||
|
||||
class PIVariantSimple {
|
||||
public:
|
||||
PIVariantSimple() {ptr = 0; f = 0;}
|
||||
@@ -129,6 +139,7 @@ public:
|
||||
private:
|
||||
template <typename T>
|
||||
bool isMyType() const {
|
||||
if (!f) return false;
|
||||
uint mh = f->hash(), th = __VariantFunctions__<T>().instance()->hash();
|
||||
if (mh == 0 || th == 0) return false;
|
||||
return mh == th;
|
||||
@@ -146,13 +157,13 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
#define REGISTER_PIVARIANTSIMPLE_STREAM(Type) \
|
||||
STATIC_INITIALIZER_BEGIN() \
|
||||
__VariantFunctionsBase__ * f = __VariantFunctions__<Type>().instance(); \
|
||||
__VariantFunctionsBase__::registered()[f->hash()] = f; \
|
||||
STATIC_INITIALIZER_END()
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#endif // PIVARIANTSIMPLE_H
|
||||
|
||||
Reference in New Issue
Block a user