24template <
class Interface>
62 static Interface*
ExtractInterface(istd::IPolymorphic* instancePtr,
const QByteArray& subId =
"");
65 virtual std::unique_ptr<Interface>
CreateInstance(
const QByteArray& keyId =
"")
const;
80template <
class Interface>
82: m_definitionComponentPtr(nullptr)
87template <
class Interface>
90 BaseClass::InitInternal(ownerPtr, staticInfo, &m_definitionComponentPtr);
94template <
class Interface>
97 return (m_definitionComponentPtr !=
nullptr) && BaseClass::IsValid();
102template <
class Interface>
105 if ((m_definitionComponentPtr !=
nullptr) && BaseClass::IsValid()){
107 if (parentPtr !=
nullptr){
108 const QByteArray& componentId = BaseClass::operator*();
112 BaseClass2::SplitId(componentId, baseId, subId);
113 Q_ASSERT(subId.isEmpty());
118 qCritical(
"Component %s is defined, but definition component has no parent", BaseClass::operator*().constData());
126template <
class Interface>
129 auto newComponentPtr = CreateComponent();
130 if (newComponentPtr !=
nullptr){
131 Interface* retVal = BaseClass2::ExtractInterface<Interface>(newComponentPtr.get());
132 if (retVal !=
nullptr){
133 newComponentPtr.release();
135 return std::unique_ptr<Interface>{retVal};
145template <
class Interface>
149 if (defaultList.isEmpty()){
150 defaultList <<
"Component";
159template <
class Interface>
162 if (instancePtr !=
nullptr){
163 if (
auto* componentPtr =
dynamic_cast<IComponent*
>(instancePtr)) {
164 return BaseClass2::ExtractInterface<Interface>(componentPtr, subId);
176template <
class Interface>
179 m_definitionComponentPtr(ptr.m_definitionComponentPtr)
Main component interface.
virtual const ICompositeComponent * GetParentComponent(bool ownerOnly=false) const =0
Get parent of this component.
Composite component interface.
virtual std::unique_ptr< IComponent > CreateSubcomponent(const QByteArray &componentId) const =0
Create instance of subcomponent using its ID.
Interface adding to attribute static info functionality existing only for real attributes.
Pointer to component attribute.
Factory of components used as component member.
virtual std::unique_ptr< Interface > CreateInstance(const QByteArray &keyId="") const
Create an instance of the object, mapped to the keyId keyId.
TAttributeMember< CFactoryAttribute > BaseClass
static Interface * ExtractInterface(istd::IPolymorphic *instancePtr, const QByteArray &subId="")
Extract interface from some component.
bool IsValid() const
Check if this factory can be resolved.
virtual KeyList GetFactoryKeys() const
Returns all posible keys for this factory.
void Init(const IComponent *ownerPtr, const IRealAttributeStaticInfo &staticInfo)
CInterfaceManipBase BaseClass2
std::unique_ptr< IComponent > CreateComponent() const
Create component without extracting any interface.
istd::IFactoryInfo::KeyList KeyList
QSet< QByteArray > KeyList
Generic interface for a factory.
Package with interfaces and class used for components concept.