Go to the documentation of this file.
25 void setValue(
const std::map<Base::Type, Core::DocObject*>& list);
28 [[nodiscard]]
const std::map<Base::Type, Core::DocObject*>&
getValue()
const {
return _linkMap; }
29 [[nodiscard]] std::vector<Core::DocObject*>
getLinks()
override;
50 std::shared_ptr<Core::DbgInfo>
getDbgInfo()
const override;
55 std::map<Base::Type, Core::DocObject*>
_linkMap;
72 void setValue(
const std::map<T, Core::DocObject*>& list);
75 [[nodiscard]]
const std::map<T, Core::DocObject*>&
getValue()
const {
return _linkMap; }
76 [[nodiscard]] std::vector<Core::DocObject*>
getLinks()
override;
88 [[nodiscard]]
bool isEmpty()
const;
90 [[nodiscard]]
size_t getSize()
const;
98 std::shared_ptr<Core::DbgInfo>
getDbgInfo()
const override;
109 template <
typename T>
112 static const char*
Get() {
return typeid(T).name(); }
115 template <
typename T>
123 template <
typename T>
127 for (
auto pairIt : _linkMap)
130 pairIt.second->unref();
131 onRemoveLink(pairIt.second);
134 _linkMap = *(
const std::map<T, Core::DocObject*>*)(&map);
136 for (
auto pairIt : _linkMap)
138 onAddLink(pairIt.second);
140 pairIt.second->ref();
145 template <
typename T>
148 cWarn(
"Core::PropertyLinkMap::setValueFromVariant, Variant not implemented.");
152 template <
typename T>
155 cWarn(
"Core::PropertyLinkMap::setValueFromVariant, Variant not implemented.");
159 template <
typename T>
162 const auto it = _linkMap.find(key);
163 if (it != _linkMap.end())
169 template <
typename T>
172 assert(p->
getTypeId() == getTypeId() &&
"Wrong property type!");
180 template <
typename T>
183 assert(p->
getTypeId() == getTypeId() &&
"Wrong property type!");
189 for (
auto pairIt : source->
getValue())
191 auto it = copyMap.find(pairIt.second);
192 if (it != copyMap.end())
199 copyMap[pairIt.second] = dest_obj;
206 template <
typename T>
210 for (
auto pairIt : _linkMap)
213 pairIt.second->unref();
214 onRemoveLink(pairIt.second);
221 template <
typename T>
224 const auto it = _linkMap.find(key);
225 return it != _linkMap.end();
228 template <
typename T>
232 for (
const auto& [key, value] : _linkMap)
239 template <
typename T>
248 _linkMap.emplace(key, link);
254 template <
typename T>
261 for (
const auto& [key, value] : _linkMap)
279 template <
typename T>
282 std::vector<Core::DocObject*> links;
284 for (
auto pairIt : _linkMap)
286 links.push_back(pairIt.second);
292 template <
typename T>
295 return _linkMap.empty();
298 template <
typename T>
301 return _linkMap.size();
304 template <
typename T>
307 writer <<
"<Link size=\"" << _linkMap.
size() <<
"\"/>";
309 for (
const auto& [key, value] : _linkMap)
313 writer <<
"<Key value=\"" << key <<
"\"/>";
314 writer <<
"<Link value=\"" << value->getId() <<
"\"/>";
319 template <
typename T>
326 for (
int i = 0; i < size; i++)
341 if (
Core::DocObject* container = Base::cast2<Core::DocObject>(getContainer()))
352 if (std::is_same<T, int>::value)
354 else if (std::is_same<T, double>::value)
356 else if (std::is_same<T, std::string>::value)
362 cWarn(
"Core::PropertyLinkMap::restore (%s) Container (%s) (%s), Object %s not exists!", getName().c_str(),
363 container->getTypeId().getName().c_str(), container->getId().c_str(),
id.c_str());
365 cWarn(
"Core::PropertyLinkMap::restore (%s), Object %s not exists!", getName().c_str(),
id.c_str());
371 template <
typename T>
377 template <
typename T>
381 return _linkMap == other->_linkMap;
386 template <
typename T>
389 QString s = QString(
"size: %1").arg(_linkMap.size());
394 auto info = Core::DbgInfo::createDbgInfo<Core::DbgInfo>(name, value, type,
nullptr);
395 for (
const auto& [key, link] : _linkMap)
397 s = QString(
"key: %1, val: %2").arg(key).arg(link ? link->getId().c_str() :
"nullptr");
398 value = s.toStdWString();
401 auto m0 = Core::DbgInfo::createDbgInfo<Core::DbgInfoLink>(name, value, type, info);
419 template <
typename T>
437 template <
typename T>
bool isEqual(const Property *o) const override
compare properties
void paste(const Core::Property &from) override
Paste the value from the property (mainly for Undo/Redo and transactions)
static const char * Get()
Definition: PropertyLinkMap.h:112
static const Type badType(void)
Definition: Type.h:97
void save(Base::AbstractWriter &writer, Base::PersistenceVersion &save_version) override
This method is used to save properties or very small amounts of data to an XML document.
Definition: PropertyLinkMap.h:305
bool isEqual(const Property *o) const override
compare properties
Definition: PropertyLinkMap.h:378
Core::DocObject * copyObject(Core::DocObject *o, DocObjectMap ©Map)
Creates a copy of 'o' and adds it to the document, provides map of pairs original-copy to see which o...
Definition: CoreDocument.h:269
void copyValue(Core::Property *p) override
Definition: PropertyLinkMap.h:170
void restore(Base::AbstractXMLReader &reader, Base::PersistenceVersion &version) override
This method is used to restore properties from an XML document.
PropertyKind
Definition: Property.h:42
Core::DocObject * getLink(Base::Type type) const
Core::Variant getVariant(void) const override
Definition: PropertyLinkMap.h:27
Definition: PropertyLinkBaseBase.h:8
bool addLink(Core::DocObject *link) override
Definition: PropertyLinkMap.h:83
void setValue(const std::map< Base::Type, Core::DocObject * > &list)
LX_BASE_EXPORT Base::LogClass cWarn()
std::map< Base::Type, Core::DocObject * > _linkMap
Definition: PropertyLinkMap.h:55
Core::CoreDocument * getDocument() const
Returns the CoreDocument of this DocObject.
std::map< Core::DocObject *, Core::DocObject * > DocObjectMap
Definition: DocObject.h:50
void restore(Base::AbstractXMLReader &reader, Base::PersistenceVersion &version) override
This method is used to restore properties from an XML document.
Definition: PropertyLinkMap.h:320
void setValue(const std::map< T, Core::DocObject * > &list)
Definition: PropertyLinkMap.h:124
bool removeLink(Core::DocObject *link) override
Definition: PropertyLinkMap.h:255
bool hasLink(Core::DocObject *link) const
bool hasKey(Base::Type type) const
bool removeLink(Core::DocObject *link) override
void deepCopy(Core::Property *p, Core::CoreDocument *dest_doc, DocObjectMap ©Map) override
Definition: PropertyLinkMap.h:111
static const Type createType(const Type parent, const char *name, instantiationMethod method=0)
const Core::PropertyKind getPropertyKind(void) const override
Definition: PropertyLinkMap.h:372
virtual uint64_t size()
Definition: Writer.h:63
Core::Property * copy(void) const override
Definition: PropertyLinkMap.h:420
size_t getSize() const
Definition: PropertyLinkMap.h:299
Definition: DocObject.h:54
bool addLink(Core::DocObject *link) override
std::shared_ptr< Core::DbgInfo > getDbgInfo() const override
Returns the debug information for this property.
Definition: PropertyLinkMap.h:387
virtual long getAttributeAsInteger(const char *AttrName) const =0
Definition: Persistence.h:13
bool setValueFromVariant(const Core::Variant &v) override
const std::map< Base::Type, Core::DocObject * > & getValue() const
Definition: PropertyLinkMap.h:28
std::shared_ptr< Core::DbgInfo > getDbgInfo() const override
Returns the debug information for this property.
void save(Base::AbstractWriter &writer, Base::PersistenceVersion &save_version) override
This method is used to save properties or very small amounts of data to an XML document.
Core::Variant getVariant(void) const override
Definition: PropertyLinkMap.h:153
std::vector< Core::DocObject * > getLinks() override
bool setValueFromVariant(const Core::Variant &) override
Definition: PropertyLinkMap.h:146
void setEmpty()
Definition: PropertyLinkMap.h:207
Definition: AbstractXMLReader.h:7
std::vector< Core::DocObject * > getLinks() override
Definition: PropertyLinkMap.h:280
bool hasKey(T key) const
Definition: PropertyLinkMap.h:222
void deepCopy(Core::Property *p, Core::CoreDocument *dest_doc, DocObjectMap ©Map) override
Definition: PropertyLinkMap.h:181
@ P_MODIFY_LINK
Definition: Property.h:45
virtual Core::DocObject * getObjectById(const DocObject::IdType &id) const
Returns the object with this id.
bool isEmpty() const
Definition: PropertyLinkMap.h:293
virtual Base::String getAttribute(const char *AttrName) const =0
Definition: PropertyLinkMap.h:21
LX_CORE_EXPORT Version & version
Definition: Property.h:72
std::map< T, Core::DocObject * > _linkMap
Definition: PropertyLinkMap.h:103
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:18
void paste(const Core::Property &from) override
Definition: PropertyLinkMap.h:438
virtual Type getTypeId(void) const
#define TYPESYSTEM_HEADER()
define for subclassing Base::BaseClass
Definition: Base.h:12
const Core::PropertyKind getPropertyKind(void) const override
Core::Property * copy(void) const override
Returns a new copy of the property (mainly for Undo/Redo and transactions). The copy has no container...
Core::DocObject * getLink(T key) const
Definition: PropertyLinkMap.h:160
const std::map< T, Core::DocObject * > & getValue() const
Definition: PropertyLinkMap.h:75
void copyValue(Core::Property *p) override
Definition: PropertyLinkMap.h:68
virtual double getAttributeAsDouble(const char *AttrName) const =0
bool hasLink(Core::DocObject *link) const
Definition: PropertyLinkMap.h:229
virtual void readElement(const char *ElementName=0)=0