6#include <QtCore/QCoreApplication>
25template <
typename Attribute>
83 const Attribute* m_attributePtr;
90template <
typename Attribute>
92: m_attributePtr(nullptr),
98template <
typename Attribute>
103 InitInternal(ownerPtr, staticInfo,
nullptr);
106template <
typename Attribute>
109 Q_ASSERT_X(m_isAssigned,
"Component initialization",
"No I_ASSIGN used or attribute is used out of component context");
111 return (m_attributePtr !=
nullptr);
115template <
typename Attribute>
118 Q_ASSERT_X(m_isAssigned,
"Component initialization",
"No I_ASSIGN used or attribute is used out of component context");
120 return m_attributePtr;
124template <
typename Attribute>
127 Q_ASSERT(m_attributePtr !=
nullptr);
129 return m_attributePtr->GetValue();
133template <
typename Attribute>
136 Q_ASSERT_X(m_isAssigned,
"Component initialization",
"No I_ASSIGN used or attribute is used out of component context");
138 return m_attributePtr;
142template <
typename Attribute>
145 Q_ASSERT(m_attributePtr !=
nullptr);
147 return m_attributePtr->GetValue();
153template <
typename Attribute>
156 m_attributePtr = attributePtr;
160template <
typename Attribute>
166 Q_ASSERT(ownerPtr !=
nullptr);
172 if (componentContextPtr !=
nullptr){
173 if (definitionComponentPtr !=
nullptr){
174 int definitionLevel = -1;
175 const iser::IObject* attributePtr = componentContextPtr->GetAttribute(attributeId, &definitionLevel);
176 if (attributePtr !=
nullptr){
177 m_attributePtr =
dynamic_cast<const Attribute*
>(attributePtr);
179 if (m_attributePtr !=
nullptr){
180 Q_ASSERT(definitionLevel >= 0);
182 while (definitionLevel > 0 && (ownerPtr !=
nullptr)){
189 *definitionComponentPtr = ownerPtr;
194 qCritical(
"Component '%s': Attribute '%s' type inconsistence!",
196 attributeId.constData());
201 const iser::IObject* attributePtr = componentContextPtr->GetAttribute(attributeId,
nullptr);
202 m_attributePtr =
dynamic_cast<const Attribute*
>(attributePtr);
204 if (m_attributePtr ==
nullptr){
205 if (attributePtr !=
nullptr){
206 qCritical(
"Component %s: Attribute %s exists in the component context but has a wrong type",
208 attributeId.constData());
212 return (m_attributePtr !=
nullptr);
216 qCritical(
"Error during resolving of attribute: %s in component %s: Component context not set",
218 attributeId.constData());
220 m_attributePtr =
nullptr;
269 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)
iattr::CStringAttribute BaseClass
static QByteArray GetTypeName()
virtual QByteArray GetFactoryId() const
TAttributeMember< CTextAttribute > BaseClass
QString operator*() const
@ AF_TRANSLATABLE
Attribute is able to translate.
Main component interface.
virtual const icomp::IComponent * GetParentComponent(bool ownerOnly=false) const =0
Get parent of this component.
virtual IComponentContextSharedPtr GetComponentContext() const =0
Get access to component context describing all application-specified component information loaded fro...
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.
const AttributeValueType & operator*() const
Get value of attribute.
const Attribute * operator->() const
Access to internal attribute pointer.
void SetAttribute(const Attribute *attributePtr)
Attribute::ValueType AttributeValueType
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.
std::shared_ptr< icomp::IComponentContext > IComponentContextSharedPtr