OpenLexocad  27.1
Core::CoreApplication Class Reference

#include <CoreApplication.h>

Inheritance diagram for Core::CoreApplication:
Base::Subject< Core::AppChanges >

Public Member Functions

 CoreApplication (int argc, char **argv)
 
 ~CoreApplication ()
 
Base::String getApplicationName () const
 Returns the name of the application. More...
 
void setApplicationName (const Base::String &name)
 Sets the application name. More...
 
Core::CoreDocumentnewCoreDocument (const std::string &typeName, const Base::String &name=Base::String())
 Creates a new document without Gui. The new document becomes NOT the active document. The document has default objects. More...
 
Core::CoreDocumentnewDocument (const std::string &typeName, const Base::String &name=Base::String(), bool createGui=true, bool setAsActiveDocument=true, bool createDefaultObjects=true)
 
Core::CoreDocumentopenCoreDocument (const std::string &typeName, const Base::String &path)
 Opens a document without Gui. The document path is not saved. The new document becomes NOT the active document. More...
 
Core::CoreDocumentopenDocument (const std::string &typeName, const Base::String &path=Base::String(), bool createGui=true, bool savepath=true, bool setAsActiveDocument=true)
 Opens a document. If no path is provided and the application has a Gui the user is prompted with a file selection dialog. More...
 
bool closeDocument (Core::CoreDocument *doc)
 Closes the document. Returns 'true' if successful, 'false' if canceled. More...
 
Core::CoreDocumentgetActiveDocument () const
 Returns the active document. Returns Null if there is no active document. More...
 
bool setActiveDocument (Core::CoreDocument *doc)
 Sets the active document. More...
 
Core::CoreDocumentgetDocumentByName (const Base::String &name)
 Returns the document by name. More...
 
std::vector< Core::CoreDocument * > getDocuments () const
 get a list of all documents in the application More...
 
void closeApplication ()
 Closes the application. More...
 
Base::String getApplicationPath () const
 Get the Application-Path. More...
 
Base::String getTmpDirectory (Core::CoreDocument *doc)
 Gets the TempDir of the specified document. If doc = 0 takes the active document. More...
 
void setModulePreferenceValue (const std::string &moduleName, const std::string &key, const std::string &value)
 Sets a persistent preference key and value for a module. On Windows the key and value are stored in the registry. More...
 
std::string getModulePreferenceValue (const std::string &moduleName, const std::string &key)
 Returns the persistent value of a preference key for a module. Returns empty string if key or module was not found. More...
 
bool registerCommandObserver (CA_CommandObserver *observer)
 Register an Observer for Commands. More...
 
bool unregisterCommandObserver (CA_CommandObserver *observer)
 Unregister an Observer for Commands. More...
 
ca_CommandObserver_Vector getCommandObserver ()
 Returns a List of CA_CommandObserver. More...
 
bool add_TransactionObserver (CA_TransactionObserver *observer)
 
bool remove_TransactionObserver (CA_TransactionObserver *observer)
 
CA_TransactionObserver_Vector getTransactionObservers ()
 
void notifyObject (Core::CoreDocument *doc, Core::DocObject *obj, Core::Property *pro, CA_Transaction::why transaction)
 
void notifyDocumentCreated (Core::CoreDocument *doc)
 
void notifyDocumentDeleted (Core::CoreDocument *doc)
 
void notifyDocumentRenamed (Core::CoreDocument *doc)
 
void notifyDocumentOpened (Core::CoreDocument *doc)
 
void notifyDocumentClosed (Core::CoreDocument *doc)
 
void notifyDocumentSaved (Core::CoreDocument *doc)
 
void notifyDocumentFinishedRead (Core::CoreDocument *doc)
 
void notifyDocumentChanged (Core::CoreDocument *doc, Core::Property *pro)
 
void notifyDocumentSetActive (Core::CoreDocument *doc)
 
void notifyObjectCreated (Core::CoreDocument *doc, Core::DocObject *obj)
 
void notifyObjectDeleted (Core::CoreDocument *doc, Core::DocObject *obj)
 
void notifyObjectAdded (Core::CoreDocument *doc, Core::DocObject *obj)
 
void notifyObjectChanged (Core::CoreDocument *doc, Core::DocObject *obj, Core::Property *pro)
 
void notifyObjectHasError (Core::CoreDocument *doc, Core::DocObject *obj)
 
void notifyPropertyCreate (Core::CoreDocument *doc, Core::DocObject *obj, Core::Property *pro)
 
void notifyPropertyChanged (Core::CoreDocument *doc, Core::DocObject *obj, Core::Property *pro)
 
void notifyPropertyDeleted (Core::CoreDocument *doc, Core::DocObject *obj, Core::Property *pro)
 
void notifyRecomputeSuccess (Core::CoreDocument *doc)
 
void notifyRecomputeFailed (Core::CoreDocument *doc)
 
void notifyApp (Core::CoreDocument *doc, AppChanges::why why, bool createGui, bool setAsActiveDocument=true)
 
void notifyCmdObservers (Core::CoreDocument *doc, bool createGui)
 
bool closeDocument (Core::CoreDocument *doc, bool forceClose, bool dontNotify=false)
 Closes a document. More...
 
bool isDocumentValid (Core::CoreDocument *testedDocument) const
 
bool onClose (bool forceClose, bool dontNotify, bool &hardClose)
 Gets the version number of the application. More...
 
bool closeApplication (bool forceClose, bool dontNotify, bool &hardClose)
 
Base::String getUniqueDocumentName (const Base::String &s) const
 
int getOpenDocuments (std::vector< Core::CoreDocument * > &vec)
 
void initPython () const
 Initialize the Python interpreter (if not already initialized). Call it before using any other Python/C API functions. More...
 
void finalizePython () const
 
bool runPythonString (const Base::String &str) const
 
bool runPythonString (const Base::String &str, Base::String &err) const
 
bool runPythonScript (const Base::String &scr, Base::String &err) const
 
bool runPythonScript (const Base::String &scr) const
 
bool isClosing () const
 
bool hasGui () const
 
void sethasGui (bool on)
 
void ref (void)
 Increments the reference count by one. More...
 
void unref (void)
 Decrements the reference count by one. More...
 
LoadedDllloadDllByName (const Base::String &name)
 
void setCommandFactory (Core::CommandFactory *commandFactory)
 
Core::CommandFactorygetCommandFactory () const
 
virtual const char * subject_name (void)
 
Application-wide trandaction setting
int setActiveTransaction (const char *name, bool persist=false)
 
const char * getActiveTransaction (int *tid=nullptr) const
 Return the current active transaction name and ID. More...
 
void closeActiveTransaction (bool abort=false, int id=0)
 
- Public Member Functions inherited from Base::Subject< Core::AppChanges >
 Subject ()
 
virtual ~Subject ()
 
void attach (Observer< Core::AppChanges > *ToObserv)
 
void detach (Observer< Core::AppChanges > *ToObserv)
 
void observerDeleted (Observer< Core::AppChanges > *ToObserv)
 
void detachAll ()
 
void notify_internal (Core::AppChanges &rcReason, size_t deep)
 
void notify (Core::AppChanges &rcReason)
 
Observer< Core::AppChanges > * get (const char *Name)
 
std::vector< Observer< Core::AppChanges > * > getAll ()
 
void resetObserverTime ()
 
std::map< std::string, double > getObserverTime ()
 

Static Public Member Functions

static CoreApplicationinstance (void)
 Returns the Singleton. More...
 
static void destroy ()
 Deletes the Singleton. More...
 
static void reset ()
 Resets the Singleton. More...
 
static unsigned int getVersionYear ()
 
static std::string getBuildDateTime ()
 
static std::string getDocumentVersion ()
 
static int getDocumentVersionAsInteger ()
 
static long getRefCount ()
 Returns the reference count of the Application. More...
 

Protected Member Functions

Core::CoreDocument_newDocument (const std::string &typeName, const Base::String &name, bool createGui)
 
void deleteDocument (Core::CoreDocument *doc)
 Physically deletes a document. The maps are not effected. More...
 
- Protected Member Functions inherited from Base::Subject< Core::AppChanges >
std::vector< ObserverHolder > getObserverSortedByPriority (const ObserverSetType &obs)
 

Protected Attributes

std::map< Base::String, Core::CoreDocument * > _documentMap
 Map of all documents. More...
 
- Protected Attributes inherited from Base::Subject< Core::AppChanges >
ObserverSetType _ObserverSet
 
ObserverSetType _ObserverSet_AddedLater
 Set of attached observers. More...
 
bool _running_notify
 Set of attached observers at running notify. More...
 
std::list< Core::AppChanges_messages_WhileRunningNotify
 
std::map< std::string, double > _observerTime
 

Friends

class AutoTransaction
 

Additional Inherited Members

- Public Types inherited from Base::Subject< Core::AppChanges >
typedef Observer< Core::AppChangesObserverType
 
typedef Core::AppChanges MessageType
 
typedef Subject< Core::AppChangesSubjectType
 
- Protected Types inherited from Base::Subject< Core::AppChanges >
typedef std::set< ObserverHolder, CompareObservers > ObserverSetType
 

Constructor & Destructor Documentation

◆ CoreApplication()

Core::CoreApplication::CoreApplication ( int  argc,
char **  argv 
)

◆ ~CoreApplication()

Core::CoreApplication::~CoreApplication ( )

Member Function Documentation

◆ _newDocument()

Core::CoreDocument* Core::CoreApplication::_newDocument ( const std::string &  typeName,
const Base::String name,
bool  createGui 
)
protected

◆ add_TransactionObserver()

bool Core::CoreApplication::add_TransactionObserver ( CA_TransactionObserver observer)

◆ closeActiveTransaction()

void Core::CoreApplication::closeActiveTransaction ( bool  abort = false,
int  id = 0 
)

Commit/abort current active transactions

Parameters
abortwhether to abort or commit the transactions

Bsides calling this function directly, it will be called by automatically if 1) any new transaction is created with a different ID, or 2) any transaction with the current active transaction ID is either committed or aborted

◆ closeApplication() [1/2]

void Core::CoreApplication::closeApplication ( )

Closes the application.

◆ closeApplication() [2/2]

bool Core::CoreApplication::closeApplication ( bool  forceClose,
bool  dontNotify,
bool &  hardClose 
)

◆ closeDocument() [1/2]

bool Core::CoreApplication::closeDocument ( Core::CoreDocument doc)

Closes the document. Returns 'true' if successful, 'false' if canceled.

◆ closeDocument() [2/2]

bool Core::CoreApplication::closeDocument ( Core::CoreDocument doc,
bool  forceClose,
bool  dontNotify = false 
)

Closes a document.

◆ deleteDocument()

void Core::CoreApplication::deleteDocument ( Core::CoreDocument doc)
protected

Physically deletes a document. The maps are not effected.

◆ destroy()

static void Core::CoreApplication::destroy ( )
static

Deletes the Singleton.

◆ finalizePython()

void Core::CoreApplication::finalizePython ( ) const

Undo all initializations made in initPython() and subsequent use of Python/C API functions. Useful to restart Python without having to restart the application itself.

◆ getActiveDocument()

Core::CoreDocument* Core::CoreApplication::getActiveDocument ( ) const

Returns the active document. Returns Null if there is no active document.

◆ getActiveTransaction()

const char* Core::CoreApplication::getActiveTransaction ( int *  tid = nullptr) const

Return the current active transaction name and ID.

◆ getApplicationName()

Base::String Core::CoreApplication::getApplicationName ( ) const

Returns the name of the application.

◆ getApplicationPath()

Base::String Core::CoreApplication::getApplicationPath ( ) const

Get the Application-Path.

◆ getBuildDateTime()

static std::string Core::CoreApplication::getBuildDateTime ( )
static

◆ getCommandFactory()

Core::CommandFactory* Core::CoreApplication::getCommandFactory ( ) const
inline

◆ getCommandObserver()

ca_CommandObserver_Vector Core::CoreApplication::getCommandObserver ( )

Returns a List of CA_CommandObserver.

◆ getDocumentByName()

Core::CoreDocument* Core::CoreApplication::getDocumentByName ( const Base::String name)

Returns the document by name.

◆ getDocuments()

std::vector<Core::CoreDocument*> Core::CoreApplication::getDocuments ( ) const

get a list of all documents in the application

◆ getDocumentVersion()

static std::string Core::CoreApplication::getDocumentVersion ( )
static

◆ getDocumentVersionAsInteger()

static int Core::CoreApplication::getDocumentVersionAsInteger ( )
static

◆ getModulePreferenceValue()

std::string Core::CoreApplication::getModulePreferenceValue ( const std::string &  moduleName,
const std::string &  key 
)

Returns the persistent value of a preference key for a module. Returns empty string if key or module was not found.

◆ getOpenDocuments()

int Core::CoreApplication::getOpenDocuments ( std::vector< Core::CoreDocument * > &  vec)

◆ getRefCount()

static long Core::CoreApplication::getRefCount ( )
static

Returns the reference count of the Application.

◆ getTmpDirectory()

Base::String Core::CoreApplication::getTmpDirectory ( Core::CoreDocument doc)

Gets the TempDir of the specified document. If doc = 0 takes the active document.

◆ getTransactionObservers()

CA_TransactionObserver_Vector Core::CoreApplication::getTransactionObservers ( )

◆ getUniqueDocumentName()

Base::String Core::CoreApplication::getUniqueDocumentName ( const Base::String s) const

◆ getVersionYear()

static unsigned int Core::CoreApplication::getVersionYear ( )
static

◆ hasGui()

bool Core::CoreApplication::hasGui ( ) const

◆ initPython()

void Core::CoreApplication::initPython ( ) const

Initialize the Python interpreter (if not already initialized). Call it before using any other Python/C API functions.

◆ instance()

static CoreApplication* Core::CoreApplication::instance ( void  )
static

Returns the Singleton.

◆ isClosing()

bool Core::CoreApplication::isClosing ( ) const

◆ isDocumentValid()

bool Core::CoreApplication::isDocumentValid ( Core::CoreDocument testedDocument) const

◆ loadDllByName()

LoadedDll* Core::CoreApplication::loadDllByName ( const Base::String name)

◆ newCoreDocument()

Core::CoreDocument* Core::CoreApplication::newCoreDocument ( const std::string &  typeName,
const Base::String name = Base::String() 
)

Creates a new document without Gui. The new document becomes NOT the active document. The document has default objects.

◆ newDocument()

Core::CoreDocument* Core::CoreApplication::newDocument ( const std::string &  typeName,
const Base::String name = Base::String(),
bool  createGui = true,
bool  setAsActiveDocument = true,
bool  createDefaultObjects = true 
)

Creates a new document. If 'createGui = true' a GUI is created. If 'setAsActiveDocument = true' the new document becomes the active document. If 'createDefaultObjects = true' default objects are created.

◆ notifyApp()

void Core::CoreApplication::notifyApp ( Core::CoreDocument doc,
AppChanges::why  why,
bool  createGui,
bool  setAsActiveDocument = true 
)

◆ notifyCmdObservers()

void Core::CoreApplication::notifyCmdObservers ( Core::CoreDocument doc,
bool  createGui 
)

◆ notifyDocumentChanged()

void Core::CoreApplication::notifyDocumentChanged ( Core::CoreDocument doc,
Core::Property pro 
)

◆ notifyDocumentClosed()

void Core::CoreApplication::notifyDocumentClosed ( Core::CoreDocument doc)

◆ notifyDocumentCreated()

void Core::CoreApplication::notifyDocumentCreated ( Core::CoreDocument doc)

◆ notifyDocumentDeleted()

void Core::CoreApplication::notifyDocumentDeleted ( Core::CoreDocument doc)

◆ notifyDocumentFinishedRead()

void Core::CoreApplication::notifyDocumentFinishedRead ( Core::CoreDocument doc)

◆ notifyDocumentOpened()

void Core::CoreApplication::notifyDocumentOpened ( Core::CoreDocument doc)

◆ notifyDocumentRenamed()

void Core::CoreApplication::notifyDocumentRenamed ( Core::CoreDocument doc)

◆ notifyDocumentSaved()

void Core::CoreApplication::notifyDocumentSaved ( Core::CoreDocument doc)

◆ notifyDocumentSetActive()

void Core::CoreApplication::notifyDocumentSetActive ( Core::CoreDocument doc)

◆ notifyObject()

void Core::CoreApplication::notifyObject ( Core::CoreDocument doc,
Core::DocObject obj,
Core::Property pro,
CA_Transaction::why  transaction 
)

◆ notifyObjectAdded()

void Core::CoreApplication::notifyObjectAdded ( Core::CoreDocument doc,
Core::DocObject obj 
)

◆ notifyObjectChanged()

void Core::CoreApplication::notifyObjectChanged ( Core::CoreDocument doc,
Core::DocObject obj,
Core::Property pro 
)

◆ notifyObjectCreated()

void Core::CoreApplication::notifyObjectCreated ( Core::CoreDocument doc,
Core::DocObject obj 
)

◆ notifyObjectDeleted()

void Core::CoreApplication::notifyObjectDeleted ( Core::CoreDocument doc,
Core::DocObject obj 
)

◆ notifyObjectHasError()

void Core::CoreApplication::notifyObjectHasError ( Core::CoreDocument doc,
Core::DocObject obj 
)

◆ notifyPropertyChanged()

void Core::CoreApplication::notifyPropertyChanged ( Core::CoreDocument doc,
Core::DocObject obj,
Core::Property pro 
)

◆ notifyPropertyCreate()

void Core::CoreApplication::notifyPropertyCreate ( Core::CoreDocument doc,
Core::DocObject obj,
Core::Property pro 
)

◆ notifyPropertyDeleted()

void Core::CoreApplication::notifyPropertyDeleted ( Core::CoreDocument doc,
Core::DocObject obj,
Core::Property pro 
)

◆ notifyRecomputeFailed()

void Core::CoreApplication::notifyRecomputeFailed ( Core::CoreDocument doc)

◆ notifyRecomputeSuccess()

void Core::CoreApplication::notifyRecomputeSuccess ( Core::CoreDocument doc)

◆ onClose()

bool Core::CoreApplication::onClose ( bool  forceClose,
bool  dontNotify,
bool &  hardClose 
)

Gets the version number of the application.

◆ openCoreDocument()

Core::CoreDocument* Core::CoreApplication::openCoreDocument ( const std::string &  typeName,
const Base::String path 
)

Opens a document without Gui. The document path is not saved. The new document becomes NOT the active document.

◆ openDocument()

Core::CoreDocument* Core::CoreApplication::openDocument ( const std::string &  typeName,
const Base::String path = Base::String(),
bool  createGui = true,
bool  savepath = true,
bool  setAsActiveDocument = true 
)

Opens a document. If no path is provided and the application has a Gui the user is prompted with a file selection dialog.

◆ ref()

void Core::CoreApplication::ref ( void  )

Increments the reference count by one.

◆ registerCommandObserver()

bool Core::CoreApplication::registerCommandObserver ( CA_CommandObserver observer)

Register an Observer for Commands.

◆ remove_TransactionObserver()

bool Core::CoreApplication::remove_TransactionObserver ( CA_TransactionObserver observer)

◆ reset()

static void Core::CoreApplication::reset ( )
static

Resets the Singleton.

◆ runPythonScript() [1/2]

bool Core::CoreApplication::runPythonScript ( const Base::String scr,
Base::String err 
) const

◆ runPythonScript() [2/2]

bool Core::CoreApplication::runPythonScript ( const Base::String scr) const

◆ runPythonString() [1/2]

bool Core::CoreApplication::runPythonString ( const Base::String str) const

◆ runPythonString() [2/2]

bool Core::CoreApplication::runPythonString ( const Base::String str,
Base::String err 
) const

◆ setActiveDocument()

bool Core::CoreApplication::setActiveDocument ( Core::CoreDocument doc)

Sets the active document.

◆ setActiveTransaction()

int Core::CoreApplication::setActiveTransaction ( const char *  name,
bool  persist = false 
)

Setup a pending application-wide active transaction

Parameters
namenew transaction name
persistby default, if the calling code is inside any invocation of a command, it will be auto closed once all command within the current stack exists. To disable auto closing, set persist=true
Returns
The new transaction ID.

Call this function to setup an application-wide transaction. All current pending transactions of opening documents will be committed first. However, no new transaction is created by this call. Any subsequent changes in any current opening document will auto create a transaction with the given name and ID. If more than one document is changed, the transactions will share the same ID, and will be undo/redo together.

◆ setApplicationName()

void Core::CoreApplication::setApplicationName ( const Base::String name)

Sets the application name.

◆ setCommandFactory()

void Core::CoreApplication::setCommandFactory ( Core::CommandFactory commandFactory)
inline

◆ sethasGui()

void Core::CoreApplication::sethasGui ( bool  on)

◆ setModulePreferenceValue()

void Core::CoreApplication::setModulePreferenceValue ( const std::string &  moduleName,
const std::string &  key,
const std::string &  value 
)

Sets a persistent preference key and value for a module. On Windows the key and value are stored in the registry.

◆ subject_name()

virtual const char* Core::CoreApplication::subject_name ( void  )
inlinevirtual

Reimplemented from Base::Subject< Core::AppChanges >.

◆ unref()

void Core::CoreApplication::unref ( void  )

Decrements the reference count by one.

◆ unregisterCommandObserver()

bool Core::CoreApplication::unregisterCommandObserver ( CA_CommandObserver observer)

Unregister an Observer for Commands.

Friends And Related Function Documentation

◆ AutoTransaction

friend class AutoTransaction
friend

Member Data Documentation

◆ _documentMap

std::map<Base::String, Core::CoreDocument*> Core::CoreApplication::_documentMap
protected

Map of all documents.


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