OpenLexocad
28.0
|
#include <CoreApplication.h>
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::CoreDocument * | 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. More... | |
Core::CoreDocument * | newDocument (const std::string &typeName, const Base::String &name=Base::String(), bool createGui=true, bool setAsActiveDocument=true, bool createDefaultObjects=true) |
Core::CoreDocument * | 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. More... | |
Core::CoreDocument * | 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. More... | |
bool | closeDocument (Core::CoreDocument *doc) |
Closes the document. Returns 'true' if successful, 'false' if canceled. More... | |
Core::CoreDocument * | getActiveDocument () 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::CoreDocument * | getDocumentByName (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... | |
LoadedDll * | loadDllByName (const Base::String &name) |
void | setCommandFactory (Core::CommandFactory *commandFactory) |
Core::CommandFactory * | getCommandFactory () const |
Core::Command * | createCommand (const std::string &commandName) |
void | setCreateCommandFunction (std::function< Core::Command *(const std::string &)> f) |
virtual const char * | subject_name (void) |
![]() | |
Subject () | |
virtual | ~Subject () |
void | attach (Observer< Core::AppChanges > *ToObserv) |
void | detach (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) |
void | resetObserverTime () |
std::map< std::string, double > | getObserverTime () |
Static Public Member Functions | |
static CoreApplication * | instance (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... | |
Application-wide trandaction setting | |
std::map< Base::String, Core::CoreDocument * > | _documentMap |
Map of all documents. More... | |
class | AutoTransaction |
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) |
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... | |
Additional Inherited Members | |
![]() | |
typedef Observer< Core::AppChanges > | ObserverType |
typedef Core::AppChanges | MessageType |
typedef Subject< Core::AppChanges > | SubjectType |
![]() | |
typedef std::set< ObserverHolder, CompareObservers > | ObserverSetType |
![]() | |
ObserverSetType | _ObserverSet |
ObserverSetType | _ObserverSet_AddedLater |
Set of attached observers. More... | |
ObserverSetType | _ObserverSet_AddedLaterCopy |
Set of attached observers at running notify. More... | |
bool | _running_notify |
bool | _allDetachedWhileRunningNotify |
std::list< Core::AppChanges > | _messages_WhileRunningNotify |
std::map< std::string, double > | _observerTime |
Core::CoreApplication::CoreApplication | ( | int | argc, |
char ** | argv | ||
) |
Core::CoreApplication::~CoreApplication | ( | ) |
|
protected |
bool Core::CoreApplication::add_TransactionObserver | ( | CA_TransactionObserver * | observer | ) |
void Core::CoreApplication::closeActiveTransaction | ( | bool | abort = false , |
int | id = 0 |
||
) |
Commit/abort current active transactions
abort | whether 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
void Core::CoreApplication::closeApplication | ( | ) |
Closes the application.
bool Core::CoreApplication::closeApplication | ( | bool | forceClose, |
bool | dontNotify, | ||
bool & | hardClose | ||
) |
bool Core::CoreApplication::closeDocument | ( | Core::CoreDocument * | doc | ) |
Closes the document. Returns 'true' if successful, 'false' if canceled.
bool Core::CoreApplication::closeDocument | ( | Core::CoreDocument * | doc, |
bool | forceClose, | ||
bool | dontNotify = false |
||
) |
Closes a document.
|
inline |
|
protected |
Physically deletes a document. The maps are not effected.
|
static |
Deletes the Singleton.
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.
Core::CoreDocument* Core::CoreApplication::getActiveDocument | ( | ) | const |
Returns the active document. Returns Null if there is no active document.
const char* Core::CoreApplication::getActiveTransaction | ( | int * | tid = nullptr | ) | const |
Return the current active transaction name and ID.
Base::String Core::CoreApplication::getApplicationName | ( | ) | const |
Returns the name of the application.
Base::String Core::CoreApplication::getApplicationPath | ( | ) | const |
Get the Application-Path.
|
static |
|
inline |
ca_CommandObserver_Vector Core::CoreApplication::getCommandObserver | ( | ) |
Returns a List of CA_CommandObserver.
Core::CoreDocument* Core::CoreApplication::getDocumentByName | ( | const Base::String & | name | ) |
Returns the document by name.
std::vector<Core::CoreDocument*> Core::CoreApplication::getDocuments | ( | ) | const |
get a list of all documents in the application
|
static |
|
static |
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.
int Core::CoreApplication::getOpenDocuments | ( | std::vector< Core::CoreDocument * > & | vec | ) |
|
static |
Returns the reference count of the Application.
Base::String Core::CoreApplication::getTmpDirectory | ( | Core::CoreDocument * | doc | ) |
Gets the TempDir of the specified document. If doc = 0 takes the active document.
CA_TransactionObserver_Vector Core::CoreApplication::getTransactionObservers | ( | ) |
Base::String Core::CoreApplication::getUniqueDocumentName | ( | const Base::String & | s | ) | const |
|
static |
bool Core::CoreApplication::hasGui | ( | ) | const |
void Core::CoreApplication::initPython | ( | ) | const |
Initialize the Python interpreter (if not already initialized). Call it before using any other Python/C API functions.
|
static |
Returns the Singleton.
bool Core::CoreApplication::isClosing | ( | ) | const |
bool Core::CoreApplication::isDocumentValid | ( | Core::CoreDocument * | testedDocument | ) | const |
LoadedDll* Core::CoreApplication::loadDllByName | ( | const Base::String & | name | ) |
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.
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.
void Core::CoreApplication::notifyApp | ( | Core::CoreDocument * | doc, |
AppChanges::why | why, | ||
bool | createGui, | ||
bool | setAsActiveDocument = true |
||
) |
void Core::CoreApplication::notifyCmdObservers | ( | Core::CoreDocument * | doc, |
bool | createGui | ||
) |
void Core::CoreApplication::notifyDocumentChanged | ( | Core::CoreDocument * | doc, |
Core::Property * | pro | ||
) |
void Core::CoreApplication::notifyDocumentClosed | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyDocumentCreated | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyDocumentDeleted | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyDocumentFinishedRead | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyDocumentOpened | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyDocumentRenamed | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyDocumentSaved | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyDocumentSetActive | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyObject | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj, | ||
Core::Property * | pro, | ||
CA_Transaction::why | transaction | ||
) |
void Core::CoreApplication::notifyObjectAdded | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj | ||
) |
void Core::CoreApplication::notifyObjectChanged | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj, | ||
Core::Property * | pro | ||
) |
void Core::CoreApplication::notifyObjectCreated | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj | ||
) |
void Core::CoreApplication::notifyObjectDeleted | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj | ||
) |
void Core::CoreApplication::notifyObjectHasError | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj | ||
) |
void Core::CoreApplication::notifyPropertyChanged | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj, | ||
Core::Property * | pro | ||
) |
void Core::CoreApplication::notifyPropertyCreate | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj, | ||
Core::Property * | pro | ||
) |
void Core::CoreApplication::notifyPropertyDeleted | ( | Core::CoreDocument * | doc, |
Core::DocObject * | obj, | ||
Core::Property * | pro | ||
) |
void Core::CoreApplication::notifyRecomputeFailed | ( | Core::CoreDocument * | doc | ) |
void Core::CoreApplication::notifyRecomputeSuccess | ( | Core::CoreDocument * | doc | ) |
bool Core::CoreApplication::onClose | ( | bool | forceClose, |
bool | dontNotify, | ||
bool & | hardClose | ||
) |
Gets the version number of the application.
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.
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.
void Core::CoreApplication::ref | ( | void | ) |
Increments the reference count by one.
bool Core::CoreApplication::registerCommandObserver | ( | CA_CommandObserver * | observer | ) |
Register an Observer for Commands.
bool Core::CoreApplication::remove_TransactionObserver | ( | CA_TransactionObserver * | observer | ) |
|
static |
Resets the Singleton.
bool Core::CoreApplication::runPythonScript | ( | const Base::String & | scr | ) | const |
bool Core::CoreApplication::runPythonScript | ( | const Base::String & | scr, |
Base::String & | err | ||
) | const |
bool Core::CoreApplication::runPythonString | ( | const Base::String & | str | ) | const |
bool Core::CoreApplication::runPythonString | ( | const Base::String & | str, |
Base::String & | err | ||
) | const |
bool Core::CoreApplication::setActiveDocument | ( | Core::CoreDocument * | doc | ) |
Sets the active document.
int Core::CoreApplication::setActiveTransaction | ( | const char * | name, |
bool | persist = false |
||
) |
Setup a pending application-wide active transaction
name | new transaction name |
persist | by 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 |
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.
void Core::CoreApplication::setApplicationName | ( | const Base::String & | name | ) |
Sets the application name.
|
inline |
|
inline |
void Core::CoreApplication::sethasGui | ( | bool | on | ) |
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.
|
inlinevirtual |
Reimplemented from Base::Subject< Core::AppChanges >.
void Core::CoreApplication::unref | ( | void | ) |
Decrements the reference count by one.
bool Core::CoreApplication::unregisterCommandObserver | ( | CA_CommandObserver * | observer | ) |
Unregister an Observer for Commands.
|
friend |
|
protected |
Map of all documents.