7 #ifndef __core_Instance_h__ 8 #define __core_Instance_h__ 33 std::atomic<int> *pRefCnt);
41 void acquire(
void)
const;
52 void *
data(
void)
const;
55 std::atomic<int> *pRefCnt);
63 BWORD unique(
void)
const 64 {
return m_pRefCnt? ((*m_pRefCnt)<2): TRUE; }
69 std::atomic<int> *m_pRefCnt;
73 T &Instance::cast(
void)
const 77 feX(
"fe::Instance::cast",
"unknown type");
79 if(
TypeInfo(getTypeId<T>()) != m_spType->typeinfo())
81 feX(
"fe::Instance::cast",
82 "(template '%s') type mismatch casting to '%s' from '%s'",
83 FE_TYPESTRING(T).c_str(),
84 TypeInfo(getTypeId<T>()).ref().name(),
85 m_spType->typeinfo().ref().name());
87 return *(
reinterpret_cast<T *
>(m_pData));
91 bool Instance::is(
void)
const 97 if(
TypeInfo(getTypeId<T>()) != m_spType->typeinfo())
108 m_spType = spTM->lookupType(
TypeInfo(getTypeId<T>()));
109 if(m_spType.isNull())
111 feX(
"fe::Instance::cast",
"unknown type");
122 m_spType = spTM->lookupType(
TypeInfo(getTypeId<T>()));
123 if(m_spType.isNull())
125 feX(
"fe::Instance::cast",
"unknown type");
127 m_pData = allocate(
sizeof(T) +
sizeof(std::atomic<int>));
128 m_pRefCnt = (std::atomic<int> *)((
char *)m_pData +
sizeof(T));
130 if(m_spType->getConstruct())
132 m_spType->construct(m_pData);
136 return *(
reinterpret_cast<T *
>(m_pData));
144 return a_instance.type()->getInfo()->print(a_instance.data());
Smart pointer used with types represented by BaseType.
Definition: Instance.h:28
kernel
Definition: namespace.dox:3
C++ type_info wrapper.
Definition: Type.h:20
BWORD operator==(const DualString &s1, const DualString &s2)
Compare two DualString's.
Definition: DualString.h:208
Automatically reference-counted string container.
Definition: String.h:128
String print(const Instance &a_instance)
Instance print.
Definition: Instance.h:142
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53