ACF $AcfVersion:0$
CAbComp.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4// ACF includes
6
8
9
10// AB includes
11#include "IAb.h"
12#include "IAConstraints.h"
13
14
18class CAbComp:
19 public icomp::CComponentBase, // Basic class for all ACF-components
20 virtual public IAb, // Interface to be implemented
21 virtual public IAConstraints // Contraints interface can be also directly implemented hier, but it is only an option.
22{
23public:
24 typedef icomp::CComponentBase BaseClass; // CComponentBase or any from CComponentBase direct or indirect derived class must be declared as BaseClass. It is necessary for I_BEGIN_COMPONENT macro.
25
26 // Component initialization block:
27 I_BEGIN_COMPONENT(CAbComp);
28 // Register interfaces (It makes these interface accessable for other components):
29 I_REGISTER_INTERFACE(IAb);
30 I_REGISTER_INTERFACE(IAConstraints);
31 I_REGISTER_INTERFACE(iser::ISerializable);
32
33 // Assign meta-informations for declared attributes: (ID of the attribute, short description, obligatory/optional flag and default value)
34 I_ASSIGN(m_defaultAValueAttrPtr, "DefaultAValue", "Default value of A", false, 50);
35 I_ASSIGN(m_defaultBValueAttrPtr, "DefaultBValue", "Default value of B", false, "SomeText");
36 I_END_COMPONENT;
37
39
40 // reimplemented (IAb)
41 virtual const IAConstraints& GetAConstraints() const override;
42 virtual int GetA() const override;
43 virtual bool SetA(int a) override;
44 virtual QByteArray GetB() const override;
45 virtual void SetB(const QByteArray& b) override;
46
47 // reimplemented (IAConstraints)
48 virtual const istd::CRange& GetARange() const override;
49
50 // reimplemented (iser::ISerializable)
51 virtual bool Serialize(iser::IArchive& archive) override;
52
53protected:
54 // reimplemented (icomp::CComponentBase)
55 virtual void OnComponentCreated() override;
56
57private:
58 // Data model definition
59
63 int m_a;
64
68 QByteArray m_b;
69
73 istd::CRange m_aRange;
74
78 I_ATTR(int, m_defaultAValueAttrPtr);
79
83 I_ATTR(QByteArray, m_defaultBValueAttrPtr);
84};
85
86
87
Implementation of AB-component.
Definition CAbComp.h:22
virtual void OnComponentCreated() override
virtual const IAConstraints & GetAConstraints() const override
Get constraints of A.
virtual const istd::CRange & GetARange() const override
Get the possible value range for A.
virtual void SetB(const QByteArray &b) override
Set the value of B.
virtual bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
virtual QByteArray GetB() const override
Get the value of B.
virtual int GetA() const override
Get the values of A.
virtual bool SetA(int a) override
Set the value of A.
icomp::CComponentBase BaseClass
Definition CAbComp.h:24
Interface for contraints of A.
Interface for AB-object.
Definition IAb.h:19
Base class for component implementation.
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
Common class for all classes which objects can be archived or restored from archive.