10#include <QtCore/QCoreApplication>
29template <
typename Attribute>
89 const Attribute* m_attributePtr;
96template <
typename Attribute>
98: m_attributePtr(nullptr),
104template <
typename Attribute>
109 InitInternal(ownerPtr, staticInfo,
nullptr);
112template <
typename Attribute>
115 Q_ASSERT_X(m_isAssigned,
"Component initialization",
"No I_ASSIGN used or attribute is used out of component context");
117 return (m_attributePtr !=
nullptr);
121template <
typename Attribute>
124 Q_ASSERT_X(m_isAssigned,
"Component initialization",
"No I_ASSIGN used or attribute is used out of component context");
126 return m_attributePtr;
130template <
typename Attribute>
133 Q_ASSERT(m_attributePtr !=
nullptr);
135 return m_attributePtr->GetValue();
139template <
typename Attribute>
142 Q_ASSERT_X(m_isAssigned,
"Component initialization",
"No I_ASSIGN used or attribute is used out of component context");
144 return m_attributePtr;
148template <
typename Attribute>
151 Q_ASSERT(m_attributePtr !=
nullptr);
153 return m_attributePtr->GetValue();
157template <
typename Attribute>
160 return m_attributePtr == ptr;
164template <
typename Attribute>
167 return m_attributePtr != ptr;
173template <
typename Attribute>
176 m_attributePtr = attributePtr;
180template <
typename Attribute>
186 Q_ASSERT(ownerPtr !=
nullptr);
192 if (componentContextPtr !=
nullptr){
193 if (definitionComponentPtr !=
nullptr){
194 int definitionLevel = -1;
196 if (attributePtr !=
nullptr){
197 m_attributePtr =
dynamic_cast<const Attribute*
>(attributePtr);
199 if (m_attributePtr !=
nullptr){
200 Q_ASSERT(definitionLevel >= 0);
202 while (definitionLevel > 0){
204 Q_ASSERT(ownerPtr !=
nullptr);
209 *definitionComponentPtr = ownerPtr;
214 qCritical(
"Component '%s': Attribute '%s' type inconsistence!",
216 attributeId.constData());
222 m_attributePtr =
dynamic_cast<const Attribute*
>(attributePtr);
224 if (m_attributePtr ==
nullptr){
225 if (attributePtr !=
nullptr){
226 qCritical(
"Component %s: Attribute %s exists in the component context but has a wrong type",
228 attributeId.constData());
232 return (m_attributePtr !=
nullptr);
236 qCritical(
"Error during resolving of attribute: %s in component %s: Component context not set",
238 attributeId.constData());
240 m_attributePtr =
nullptr;
289 return QCoreApplication::translate(
"Attribute", BaseClass::operator*().toUtf8());
Template implementation of single component attribute.
static QByteArray GetHierarchyAddress(const IComponentContext *contextPtr)
Get address of this component identifying it in component topology hierarchy.
CTextAttribute(const QString &value)
static QByteArray GetTypeName()
virtual QByteArray GetFactoryId() const
iattr::CStringAttribute BaseClass
TAttributeMember< CTextAttribute > BaseClass
QString operator*() const
@ AF_TRANSLATABLE
Attribute is able to translate.
Provide session context of component.
virtual const iser::IObject * GetAttribute(const QByteArray &attributeId, int *definitionLevelPtr=nullptr) const =0
Get attribute using its ID.
Main component interface.
virtual const IComponentContext * GetComponentContext() const =0
Get access to component context describing all application-specified component information loaded fro...
virtual const ICompositeComponent * GetParentComponent(bool ownerOnly=false) const =0
Get parent of this component.
Interface adding to attribute static info functionality existing only for real attributes.
virtual const QByteArray & GetAttributeId() const =0
Get ID of this attribute.
Pointer to component attribute.
void Init(const IComponent *ownerPtr, const IRealAttributeStaticInfo &staticInfo)
Initialize this attribute.
bool IsValid() const
Check if this attribute is valid.
Attribute::ValueType AttributeValueType
bool operator==(const Attribute *ptr) const
const AttributeValueType & operator*() const
Get value of attribute.
const Attribute * operator->() const
Access to internal attribute pointer.
void SetAttribute(const Attribute *attributePtr)
bool operator!=(const Attribute *ptr) const
bool InitInternal(const IComponent *ownerPtr, const IRealAttributeStaticInfo &staticInfo, const IComponent **definitionComponentPtr)
Internal initialize of attribute.
const AttributeValueType & GetOriginalValue() const
Get value of attribute.
const Attribute * GetAttributePtr() const
Access to internal attribute pointer.
Common interface for factorisable model objects.
Package with interfaces and class used for components concept.