OpenLexocad  27.1
Core::CoreDocument Class Reference

#include <CoreDocument.h>

Inheritance diagram for Core::CoreDocument:
Core::PropertyContainer Base::Subject< Core::DocChanges > Base::Persistence Base::BaseClass

Public Types

enum  Status {
  SkipRecompute = 0, KeepTrailingDigits = 1, Closable = 2, Restoring = 3,
  Recomputing = 4, PartialRestore = 5, Importing = 6, PartialDoc = 7,
  AllowPartialRecompute = 8, TempDoc = 9, RestoreError = 10
}
 
- Public Types inherited from Base::Subject< Core::DocChanges >
typedef Observer< Core::DocChangesObserverType
 
typedef Core::DocChanges MessageType
 
typedef Subject< Core::DocChangesSubjectType
 

Public Member Functions

int getDocumentVersion () const
 Returns the version of the document. More...
 
bool addObject (Core::DocObject *e)
 Adds an existing object to the document. More...
 
void removeObject (Core::DocObject *e)
 Removes an object from the document. More...
 
void removeObjectFinal (Core::DocObject *e, bool deep=false)
 Removes an object from the document. More...
 
virtual void onFileOpened ()
 Is called when the file was opened, but before the message FileOpened gets emitted. Can be overwritten to add custom behavior. More...
 
void onBeforeChangeProperty (const Core::DocObject *Who, const Property *What)
 callback from the Document objects before property will be changed More...
 
void onChangedProperty (const Core::DocObject *Who, const Property *What)
 callback from the Document objects after property was changed More...
 
virtual bool onChangedDebug (Core::DocObject *o, Core::Property *p)
 
Base::Type getCopyType () const
 
void clearCopyType ()
 Sets the copy type to Base::Type::badType(), next copied object will be copied as its own type. More...
 
Core::DocObjectcopyObject (Core::DocObject *o, DocObjectMap &copyMap=DocObjectMap())
 Creates a copy of 'o' and adds it to the document, provides map of pairs original-copy to see which object is a copy of another one. More...
 
Core::DocObjectcopyToDifferentType (Core::DocObject *o, Base::Type typeToCreate, DocObjectMap &copyMap)
 Creates an object of type 'typeToCreate' and copy properties from 'o' to it. Provides map of pairs original-copy. More...
 
Core::DocObjectcopySharedObject (Core::DocObject *o, DocObjectMap &copyMap)
 Copy shared object. This is violating of the share, but in some cases this is useful. Use wisely!! More...
 
template<typename Type >
Type copyObjectShallow (Type o)
 Creates a copy of 'o' and adds it to the document. Performs shallow copy. More...
 
std::vector< Core::DocObject * > getObjects (bool includeDeletedObjects=false) const
 Returns all objects in the document. More...
 
std::vector< const Core::DocObject * > getObjectsConst (bool includeDeletedObjects=false) const
 
std::vector< Core::DocObject * > getObjectsSorted () const
 Returns all objects topologically sorted. More...
 
Core::DocObjectcreateObjectFromTypeName (const char *typeName)
 Creates an object from type name and adds it to the document. More...
 
Core::DocObjectcreateObjectFromType (Base::Type type)
 Creates an object from type and adds it to the document. More...
 
std::vector< Core::DocObject * > getObjectsByTypeName (const std::string &typeName) const
 Returns all objects of typeName. More...
 
virtual void recompute ()
 Recomputes the document. More...
 
- Public Member Functions inherited from Core::PropertyContainer
 PropertyContainer (void)
 
 PropertyContainer (const PropertyContainer &rhs)
 
virtual ~PropertyContainer (void)=default
 
bool addProperty (Core::Property *p, const std::string &name)
 
Core::PropertyaddProperty (Base::Type t, const std::string &name, const Core::Variant &defaultValue)
 Adds a property to the PropertyContainer. Returns the added property on success, '0' on failure. More...
 
Core::PropertyUseraddPropertyUser (const std::string &name, const Core::Variant &value)
 Convenience method for Python bindings. More...
 
void removeProperty (Core::Property *p, std::string pName)
 Removes a property from the PropertyContainer and deletes it. More...
 
void removeAllProperties ()
 Removes all properties from the PropertyContainer and deletes them. More...
 
Core::PropertygetPropertyByName (const std::string &name) const
 Returns the property with name 'name'. Returns '0' on failure. More...
 
Core::PropertygetPropertyByName (const Base::String &name) const
 Returns the property with name 'name'. Returns '0' on failure. More...
 
virtual const char * getPropertyName (const Property *prop) const
 get the name of a property More...
 
template<typename T >
T * getPropertyByName (const std::string &name) const
 Returns the property of type T with name 'name'. Returns 'nullptr' on failure. More...
 
void getPropertyMap (Core::PropertyMap &) const
 Fills a PropertyMap. More...
 
std::vector< std::pair< Core::Property *, std::string > > getPropertiesAndNameByType (Base::Type type) const
 Returns all properties of type 'type'. More...
 
std::vector< Core::Property * > getPropertiesByType (Base::Type type) const
 
std::vector< Core::Property * > getPropertiesByTypes (const std::vector< Base::Type > &type) const
 
bool setPropertyFromVariant (const std::string &name, const Core::Variant &value)
 Sets a property to value. More...
 
bool setProperty (const std::string &name, double value)
 
bool setProperty (const std::string &name, int value)
 
bool setProperty (const std::string &name, const Geom::Vec &value)
 
bool setProperty (const std::string &name, const std::list< Geom::Vec > &value)
 
bool setProperty (const std::string &name, const Geom::Trsf &value)
 
bool setProperty (const std::string &name, const std::string &value)
 
bool setProperty (const std::string &name, const char *value)
 
bool setProperty (const std::string &name, const Base::String &value)
 
bool setProperty (const std::string &name, const Geom::Pnt &value)
 
bool setProperty (const std::string &name, const Geom::Pnt2d &value)
 
bool setProperty (const std::string &name, const std::vector< Geom::Pnt > &value)
 
bool setProperty (const std::string &name, const std::vector< Geom::Pnt2d > &value)
 
bool setProperty (const std::string &name, const MD5 &value)
 
bool setProperty (const std::string &name, bool value)
 
bool setProperty (const std::string &name, Core::DocObject *value)
 
bool setProperty (const std::string &name, const Core::DocObject *value)
 
bool setProperty (const std::string &name, const std::unordered_set< Core::DocObject * > &value)
 
bool setProperty (const std::string &name, const std::list< Core::DocObject * > &value)
 
bool setProperty (const std::string &name, const std::vector< int > &value)
 
bool setProperty (const std::string &name, const QFont &value)
 
bool setProperty (const std::string &name, const Draw::DrawStyle &value)
 
bool setProperty (const std::string &name, const Draw::Arrowheads &value)
 
bool setProperty (const std::string &name, const Geom::Dir &value)
 
bool setProperty (const std::string &name, const Geom::Dir2d &value)
 
bool setProperty (const std::string &name, const Base::Color &value)
 
bool setProperty (const std::string &name, const Geom::Ax1 &value)
 
bool setProperty (const std::string &name, const Geom::Ax2 &value)
 
bool setProperty (const std::string &name, const Draw::Texture2Transform &value)
 
bool setProperty (const std::string &name, const std::list< std::list< Geom::Pnt > > &value)
 
bool setProperty (const std::string &name, const std::vector< double > &value)
 
bool setProperty (const std::string &name, pBrepData &value)
 
virtual bool onBeforeChange (Core::Property *p, const Core::Variant &newValue=Core::Variant())
 
virtual void onChanged (Core::Property *p)
 Is called after a property in a PropertyContainer has been changed. More...
 
virtual void onDeleted ()
 Is called when a PropertyContainer's status is set to MarkedForDelete. More...
 
virtual void onNew ()
 Is called when a PropertyContainer's status is set to New. More...
 
virtual void onPropertyStatusBitsChanged (const Property &prop, unsigned long oldStatus)
 Is called when the Property StatusBits are changed. More...
 
virtual void save (Base::AbstractWriter &writer, Base::PersistenceVersion &version)
 Saves the PropertyContainer to writer. More...
 
virtual void restore (Base::AbstractXMLReader &reader, Base::PersistenceVersion &version)
 Restores the PropertyContainer from reader in specified version. More...
 
bool enableNotify (const bool enable)
 
bool isNotifyEnabled (void) const
 Returns whether notification of changes to the field values in the container is propagated to its auditors. More...
 
void touch ()
 Sets all properties of this PropertyContainer to updated. More...
 
bool isDeleted () const
 
bool isStatusDeleted () const
 Returns true if the status is set to 'Deleted'. More...
 
bool isMarkedForDelete () const
 Returns true if the status is set to 'MarkedForDelete'. More...
 
bool isMarkedForDeleteFinal () const
 Returns true if the status is set to 'MarkedForDeleteFinal'. More...
 
bool isDeletedFinal () const
 Returns true if the status is set to 'DeletedFinal'. More...
 
bool isNew () const
 Returns true if the status is set to 'New'. More...
 
bool isUpdated () const
 Returns true if the status is set to 'Updated'. More...
 
bool isValid () const
 Returns true if the status is set to 'Valid'. More...
 
bool hasErrors () const
 Returns true if the status is set to 'Error'. More...
 
void setData (const std::string &key, void *data)
 Adds arbitrary data for this key to the PropertyContainer (Used in SDK) More...
 
void * getData (const std::string &key, bool *ok=nullptr) const
 Returns data for this key from the PropertyContainer (Used in SDK) More...
 
void removeData (const std::string &key)
 Removes the data from the PropertyContainer (Used in SDK) More...
 
bool hasSameValuesAs (const PropertyContainer *container) const
 Returns 'true' if all values in 'container' match the corresponding property in this PropertyContainer. More...
 
void setPropertyValues (const PropertyContainer *other)
 Copies the property values from 'other' PropertyContainer to this PropertyContainer. More...
 
template<typename T >
getPropertyValueByName (const std::string &propertyName, bool *ok=0) const
 Returns the property value T with this name. If ok=true T holds a valid value. More...
 
virtual void ensureIntegrity ()
 
void integrityMaintained ()
 
void integrityLost ()
 Sets _integrity to false. More...
 
bool checkIntegrity ()
 Returns the value of _integrity. More...
 
virtual bool onChangedDebug (Core::Property *p)
 Is called after a property in a PropertyContainers has been changed, it ignores notify-flag. More...
 
virtual void checkAfterOnDeleted ()
 
Core::PropertyValueMap getPropertyValueMap () const
 Returns a map with the name of the property and its PropertyValue as a struct of the property type and the Core::Variant value. More...
 
std::map< std::string, Core::VariantgetKeyValueMap () const
 Returns all keys and sub keys with their values of this container. More...
 
bool setPropertyFromKeyValue (const std::string &propertyName, const std::string &key, const Core::Variant &value)
 Sets the key in a property to value. More...
 
std::set< Core::Property * > getUpdatedProperties () const
 Returns all properties that were updated since the last recompute. More...
 
void setUpdated ()
 Sets the status to 'Updated' if the old status was 'Valid'. More...
 
void setUpdated (const Core::Property *p)
 
void setHasErrors ()
 Sets the status to 'Error'. More...
 
void setNew ()
 Sets the status to 'New'. More...
 
void setValid ()
 Sets the status to 'Valid'. More...
 
void setDeleted ()
 Sets the status to 'Delete'. More...
 
void setMarkedForDelete ()
 Sets the status to 'MarkedForDelete'. More...
 
void setMarkedForDeleteFinal ()
 Sets the status to 'MarkedForDeleteFinal'. More...
 
void setDeleteFinal ()
 Sets the status to 'DeleteFinal'. More...
 
virtual void breakLinks ()
 Sets all links of this container to null. More...
 
unsigned int getPropertyChangeStatus () const
 
void setAllPropertiesValid ()
 Sets the status of all properties to 'Valid'. More...
 
void setPropertyValues (const Core::PropertyValueMap &other)
 Copies the property values from a Core::PropertyValueMap to this PropertyContainer. More...
 
std::vector< Core::Property * > getPropertiesOrdered () const
 Returns the properties in the init order. More...
 
virtual bool check_lx (char *f, char *n)
 
bool rollBack ()
 Brings back the PropertyContainer to its last valid status. More...
 
void saveLastValidPropertyMap ()
 Saves the last valid property map, p.e. before a recompute to enable a rollback. More...
 
const Core::PropertyValueMapgetLastValidPropertyMap () const
 Returns the last valid PropertyValueMap. More...
 
virtual Core::PropertyaddDynamicProperty (const char *type, const char *name=0, const char *group=0, const char *doc=0, short attr=0, bool ro=false, bool hidden=false)
 
DynamicProperty::PropData getDynamicPropertyData (const Property *prop) const
 
virtual bool removeDynamicProperty (const char *name)
 
virtual std::vector< std::string > getDynamicPropertyNames () const
 
virtual Core::PropertygetDynamicPropertyByName (const char *name) const
 
- Public Member Functions inherited from Base::Persistence
virtual void saveDocFile (Base::AbstractWriter &, const Base::String &, const Base::String &)
 This method is used to save large amounts of data to a binary file. More...
 
virtual void restoreDocFile (Base::Reader &, const Base::String &)
 This method is used to restore large amounts of data from a binary file. More...
 
virtual bool mustbeSaved () const
 Return 'true' if this object must always be saved in the file. More...
 
virtual bool createSQL (Base::AbstractWriter &, Base::PersistenceVersion &, bool)
 This method is used to save properties or very small amounts of data to an XML document. More...
 
- Public Member Functions inherited from Base::BaseClass
virtual Type getTypeId (void) const
 
template<typename T >
bool isDerivedFrom () const
 
bool isDerivedFrom (const Type type) const
 
 BaseClass ()
 Construction. More...
 
virtual ~BaseClass ()
 Destruction. More...
 
- Public Member Functions inherited from Base::Subject< Core::DocChanges >
 Subject ()
 
virtual ~Subject ()
 
void attach (Observer< Core::DocChanges > *ToObserv)
 
void detach (Observer< Core::DocChanges > *ToObserv)
 
void observerDeleted (Observer< Core::DocChanges > *ToObserv)
 
void detachAll ()
 
void notify_internal (Core::DocChanges &rcReason, size_t deep)
 
void notify (Core::DocChanges &rcReason)
 
Observer< Core::DocChanges > * get (const char *Name)
 
std::vector< Observer< Core::DocChanges > * > getAll ()
 
virtual const char * subject_name (void)
 
void resetObserverTime ()
 
std::map< std::string, double > getObserverTime ()
 

Public Attributes

Core::PropertyText name
 
Core::PropertyText documentVersion
 
Core::PropertyText compatibleInfo
 
Core::PropertyText documentGUID
 
Core::PropertyIndex documentChanges
 
Core::PropertyIndex documentMaxID
 
Core::PropertyIndex application_mainversion
 
Core::PropertyIndex application_minorversion
 
Core::PropertyText documentTypeName
 
Core::PropertyText filename
 
Core::PropertyText createdBy
 
Core::PropertyText creationDate
 
Core::PropertyText lastModifiedBy
 
Core::PropertyText lastModifiedDate
 
Core::PropertyText company
 
Core::PropertyText comment
 
Core::PropertyText projectNumber
 
Core::PropertyText architect
 
Base::String fileName
 
auto onRecomputedCB
 
- Public Attributes inherited from Core::PropertyContainer
bool isRestored = false
 
- Public Attributes inherited from Base::BaseClass
long ____deadVal = 0xBADEAFFE
 

Friends

class CoreApplication
 
class CoreDocument_Factory
 
class PropertyGUID
 
class DocumentTimeStampSentinel
 

Additional Inherited Members

- Static Public Member Functions inherited from Base::Persistence
static std::string encodeAttribute (const std::string &)
 
- Static Public Member Functions inherited from Base::BaseClass
static Type getClassTypeId (void)
 
static void init (void)
 
static void * create (void)
 
static void setIfcNameAndID (const std::string &n, int id)
 
- Protected Types inherited from Core::PropertyContainer
enum  Status {
  Status::New = 1, Status::Updated = 2, Status::Valid = 3, Status::MarkedForDelete = 4,
  Status::MarkedForDeleteFinal, Status::Deleted, Status::DeletedFinal, Status::Error
}
 
- Protected Types inherited from Base::Subject< Core::DocChanges >
typedef std::set< ObserverHolder, CompareObservers > ObserverSetType
 
- Protected Member Functions inherited from Core::PropertyContainer
virtual void onBeforeChangeProperty (const Property *prop)
 
virtual void onChangedProperty (const Property *prop)
 
void addPropertiesFrom (const Core::PropertyContainer *other)
 Adds copy of all properties from other to this PropertyContainer. More...
 
virtual void setStatus (Status status)
 
Status getStatus () const
 
bool checkForAlreadyExistingProperty (Core::Property *property)
 
virtual void restoreProperty (Core::Property *property, const Base::String &name, Base::AbstractXMLReader &reader, Base::PersistenceVersion &version)
 Restores property from from reader in specified version. More...
 
- Protected Member Functions inherited from Base::Subject< Core::DocChanges >
std::vector< ObserverHolder > getObserverSortedByPriority (const ObserverSetType &obs)
 
- Static Protected Member Functions inherited from Base::BaseClass
static void initSubclass (Base::Type &toInit, const char *ClassName, const char *ParentName, Type::instantiationMethod method=0)
 
static void initIfcTypes (const std::string &s, Base::Type classTypeId, int id)
 
- Protected Attributes inherited from Core::PropertyContainer
unsigned int _changedProperties
 
- Protected Attributes inherited from Base::Subject< Core::DocChanges >
ObserverSetType _ObserverSet
 
ObserverSetType _ObserverSet_AddedLater
 Set of attached observers. More...
 
bool _running_notify
 Set of attached observers at running notify. More...
 
std::list< Core::DocChanges_messages_WhileRunningNotify
 
std::map< std::string, double > _observerTime
 

Member Enumeration Documentation

◆ Status

Enumerator
SkipRecompute 
KeepTrailingDigits 
Closable 
Restoring 
Recomputing 
PartialRestore 
Importing 
PartialDoc 
AllowPartialRecompute 
TempDoc 
RestoreError 

Member Function Documentation

◆ addObject()

bool Core::CoreDocument::addObject ( Core::DocObject e)

Adds an existing object to the document.

◆ clearCopyType()

void Core::CoreDocument::clearCopyType ( )

Sets the copy type to Base::Type::badType(), next copied object will be copied as its own type.

◆ copyObject()

Core::DocObject* Core::CoreDocument::copyObject ( Core::DocObject o,
DocObjectMap copyMap = DocObjectMap() 
)

Creates a copy of 'o' and adds it to the document, provides map of pairs original-copy to see which object is a copy of another one.

◆ copyObjectShallow()

template<typename Type >
Type Core::CoreDocument::copyObjectShallow ( Type  o)
inline

Creates a copy of 'o' and adds it to the document. Performs shallow copy.

◆ copySharedObject()

Core::DocObject* Core::CoreDocument::copySharedObject ( Core::DocObject o,
DocObjectMap copyMap 
)

Copy shared object. This is violating of the share, but in some cases this is useful. Use wisely!!

◆ copyToDifferentType()

Core::DocObject* Core::CoreDocument::copyToDifferentType ( Core::DocObject o,
Base::Type  typeToCreate,
DocObjectMap copyMap 
)

Creates an object of type 'typeToCreate' and copy properties from 'o' to it. Provides map of pairs original-copy.

◆ createObjectFromType()

Core::DocObject* Core::CoreDocument::createObjectFromType ( Base::Type  type)

Creates an object from type and adds it to the document.

◆ createObjectFromTypeName()

Core::DocObject* Core::CoreDocument::createObjectFromTypeName ( const char *  typeName)

Creates an object from type name and adds it to the document.

◆ getCopyType()

Base::Type Core::CoreDocument::getCopyType ( ) const

Return type of which new copied element should be created. setCopyType is intentionally not available because it is decided in copy methods.

◆ getDocumentVersion()

int Core::CoreDocument::getDocumentVersion ( ) const

Returns the version of the document.

◆ getObjects()

std::vector<Core::DocObject*> Core::CoreDocument::getObjects ( bool  includeDeletedObjects = false) const

Returns all objects in the document.

◆ getObjectsByTypeName()

std::vector<Core::DocObject*> Core::CoreDocument::getObjectsByTypeName ( const std::string &  typeName) const

Returns all objects of typeName.

◆ getObjectsConst()

std::vector<const Core::DocObject*> Core::CoreDocument::getObjectsConst ( bool  includeDeletedObjects = false) const

◆ getObjectsSorted()

std::vector<Core::DocObject*> Core::CoreDocument::getObjectsSorted ( ) const

Returns all objects topologically sorted.

◆ onBeforeChangeProperty()

void Core::CoreDocument::onBeforeChangeProperty ( const Core::DocObject Who,
const Property What 
)

callback from the Document objects before property will be changed

◆ onChangedDebug()

virtual bool Core::CoreDocument::onChangedDebug ( Core::DocObject o,
Core::Property p 
)
virtual

◆ onChangedProperty()

void Core::CoreDocument::onChangedProperty ( const Core::DocObject Who,
const Property What 
)

callback from the Document objects after property was changed

◆ onFileOpened()

virtual void Core::CoreDocument::onFileOpened ( )
inlinevirtual

Is called when the file was opened, but before the message FileOpened gets emitted. Can be overwritten to add custom behavior.

◆ recompute()

virtual void Core::CoreDocument::recompute ( )
virtual

Recomputes the document.

◆ removeObject()

void Core::CoreDocument::removeObject ( Core::DocObject e)

Removes an object from the document.

◆ removeObjectFinal()

void Core::CoreDocument::removeObjectFinal ( Core::DocObject e,
bool  deep = false 
)

Removes an object from the document.

Friends And Related Function Documentation

◆ CoreApplication

friend class CoreApplication
friend

◆ CoreDocument_Factory

friend class CoreDocument_Factory
friend

◆ DocumentTimeStampSentinel

friend class DocumentTimeStampSentinel
friend

◆ PropertyGUID

friend class PropertyGUID
friend

Member Data Documentation

◆ application_mainversion

Core::PropertyIndex Core::CoreDocument::application_mainversion

◆ application_minorversion

Core::PropertyIndex Core::CoreDocument::application_minorversion

◆ architect

Core::PropertyText Core::CoreDocument::architect

◆ comment

Core::PropertyText Core::CoreDocument::comment

◆ company

Core::PropertyText Core::CoreDocument::company

◆ compatibleInfo

Core::PropertyText Core::CoreDocument::compatibleInfo

◆ createdBy

Core::PropertyText Core::CoreDocument::createdBy

◆ creationDate

Core::PropertyText Core::CoreDocument::creationDate

◆ documentChanges

Core::PropertyIndex Core::CoreDocument::documentChanges

◆ documentGUID

Core::PropertyText Core::CoreDocument::documentGUID

◆ documentMaxID

Core::PropertyIndex Core::CoreDocument::documentMaxID

◆ documentTypeName

Core::PropertyText Core::CoreDocument::documentTypeName

◆ documentVersion

Core::PropertyText Core::CoreDocument::documentVersion

◆ filename

Core::PropertyText Core::CoreDocument::filename

◆ fileName

Base::String Core::CoreDocument::fileName

◆ lastModifiedBy

Core::PropertyText Core::CoreDocument::lastModifiedBy

◆ lastModifiedDate

Core::PropertyText Core::CoreDocument::lastModifiedDate

◆ name

Core::PropertyText Core::CoreDocument::name

◆ onRecomputedCB

auto Core::CoreDocument::onRecomputedCB
Initial value:
= [this] (DOCOBJECTS newObj, DOCOBJECTS updatedObj,
* DOCOBJECTS deletedObj, DOCOBJECTS_ERROR_MAP errorObj)

Recomputes the document. Takes a lambda as an argument -> { /*CODE

◆ projectNumber

Core::PropertyText Core::CoreDocument::projectNumber

The documentation for this class was generated from the following file: