8#include <QtCore/QMutex>
33template <
class Interface>
76 mutable std::atomic<Interface*> m_interfacePtr;
77 mutable std::atomic<bool> m_isInitialized;
79 mutable QRecursiveMutex m_mutex;
85template <
class Interface>
87 :m_definitionComponentPtr(
NULL),
88 m_isInitialized(false),
89 m_interfacePtr(nullptr)
94template <
class Interface>
97 QMutexLocker lock(&m_mutex);
99 BaseClass::InitInternal(ownerPtr, staticInfo, &m_definitionComponentPtr);
112 m_isInitialized =
false;
113 m_interfacePtr =
nullptr;
114 m_componentPtr.reset();
118template <
class Interface>
121 return EnsureInitialized();
125template <
class Interface>
128 if (!m_isInitialized){
129 QMutexLocker lock(&m_mutex);
131 if (!m_isInitialized && (m_definitionComponentPtr !=
NULL) && BaseClass::IsValid()) {
133 if (parentPtr !=
NULL) {
134 const QByteArray& componentId = BaseClass::operator*();
138 BaseClass2::SplitId(componentId, baseId, subId);
141 if (m_componentPtr !=
nullptr) {
142 m_interfacePtr = BaseClass2::ExtractInterface<Interface>(m_componentPtr.get(), subId);
144 m_isInitialized =
true;
147 qCritical(
"Component %s is defined, but definition component has no parent", BaseClass::operator*().constData());
153 return (m_interfacePtr !=
NULL);
157template <
class Interface>
162 return m_interfacePtr;
166template <
class Interface>
171 Q_ASSERT(m_interfacePtr !=
NULL);
179template <
class Interface>
182 m_definitionComponentPtr(ptr.m_definitionComponentPtr),
183 m_interfacePtr(nullptr),
184 m_isInitialized(false)
187 QMutexLocker lock(&ptr.m_mutex);
188 m_componentPtr = ptr.m_componentPtr;
189 m_interfacePtr = ptr.m_interfacePtr.load();
190 m_isInitialized = ptr.m_isInitialized.load();
202template <
class Interface>
void operator*(const icomp::TReferenceMember< void > &)
Main component interface.
Composite component interface.
virtual IComponentSharedPtr GetSubcomponent(const QByteArray &componentId) const =0
Get access to subcomponent using its ID.
Interface adding to attribute static info functionality existing only for real attributes.
Pointer to component attribute.
Pointer to referenced component object.
Interface * GetPtr() const
Direct cccess to internal pointer.
Interface * operator->() const
Access to internal pointer.
bool IsValid() const
Check if this reference can be resolved.
void Init(const IComponent *ownerPtr, const IRealAttributeStaticInfo &staticInfo)
bool EnsureInitialized() const
Ensure that initlization process is closed.
CInterfaceManipBase BaseClass2
TAttributeMember< CReferenceAttribute > BaseClass
Package with interfaces and class used for components concept.
std::shared_ptr< IComponent > IComponentSharedPtr