SHAPER 9.16.0
ModelAPI_Session.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef ModelAPI_Session_H_
21#define ModelAPI_Session_H_
22
23#include "ModelAPI.h"
24#include <string>
25#include <list>
26#include <memory>
27
29class ModelAPI_Plugin;
33
41class MODELAPI_EXPORT ModelAPI_Session
42{
43protected:
45
46 public:
48 static std::shared_ptr<ModelAPI_Session> get();
49
53 virtual bool load(const char* theFileName) = 0;
54
56 virtual bool isLoading() { return myIsLoading; };
57
62 virtual bool save(const char* theFileName, std::list<std::string>& theResults, bool isBackup=false) = 0;
63
65 virtual void closeAll() = 0;
66
72 virtual void startOperation(
73 const std::string& theId = "", const bool theAttachedToNested = false) = 0;
75 virtual void finishOperation() = 0;
77 virtual void abortOperation() = 0;
79 virtual bool isOperation() = 0;
81 virtual bool isModified() = 0;
82
84 virtual bool canUndo() = 0;
86 virtual void undo() = 0;
88 virtual bool canRedo() = 0;
90 virtual void redo() = 0;
92 virtual std::list<std::string> undoList() = 0;
94 virtual std::list<std::string> redoList() = 0;
96 virtual void clearUndoRedo() = 0;
97
101 virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0;
102
104 virtual bool checkLicense(const std::string& thePluginName) = 0;
105
107 virtual std::shared_ptr<ModelAPI_Document> moduleDocument() = 0;
108
110 virtual std::shared_ptr<ModelAPI_Document> document(int theDocID) = 0;
111
113 virtual bool hasModuleDocument() = 0;
114
116 virtual std::shared_ptr<ModelAPI_Document> activeDocument() = 0;
117
119 virtual void setActiveDocument(
120 std::shared_ptr<ModelAPI_Document> theDoc, bool theSendSignal = true) = 0;
121
123 virtual std::list<std::shared_ptr<ModelAPI_Document> > allOpenedDocuments() = 0;
124
126 virtual bool isLoadByDemand(const std::wstring theDocID, const int theDocIndex) = 0;
127
129 virtual std::shared_ptr<ModelAPI_Document> copy(
130 std::shared_ptr<ModelAPI_Document> theSource, const int theDestID) =0;
131
134
137
140 {
141 }
142
144 virtual int transactionID() = 0;
145
147 virtual bool isAutoUpdateBlocked() = 0;
148
150 virtual void blockAutoUpdate(const bool theBlock) = 0;
151
152 protected:
154 static void setSession(std::shared_ptr<ModelAPI_Session> theManager);
155};
156
157typedef std::shared_ptr<ModelAPI_Session> SessionPtr;
158
159#endif
Document for internal data structure of any object storage.
Definition: ModelAPI_Document.h:53
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:41
Manages registering of filters.
Definition: ModelAPI_FiltersFactory.h:35
Interface common for any plugin: allows to use plugin by the plugins manager.
Definition: ModelAPI_Plugin.h:34
Object that knows (from the initial XML file) which plugin contains which feature,...
Definition: ModelAPI_Session.h:42
virtual ModelAPI_FiltersFactory * filters()=0
Returns the filters factory: the only one instance per application.
virtual std::shared_ptr< ModelAPI_Document > document(int theDocID)=0
Returns the document by ID. Returns null if no such document.
virtual bool checkLicense(const std::string &thePluginName)=0
Verifies the license for the plugin is valid.
virtual std::list< std::string > undoList()=0
Returns stack of performed operations (from last to first)
virtual void registerPlugin(ModelAPI_Plugin *thePlugin)=0
Registers the plugin that creates features.
virtual void closeAll()=0
Closes all documents.
virtual bool isModified()=0
Returns true if document was modified (since creation/opening)
virtual int transactionID()=0
Returns the global identifier of the current transaction (needed for the update algo)
virtual bool isOperation()=0
Returns true if operation has been started, but not yet finished or aborted.
virtual ~ModelAPI_Session()
To virtually destroy the fields of successors.
Definition: ModelAPI_Session.h:139
virtual void setActiveDocument(std::shared_ptr< ModelAPI_Document > theDoc, bool theSendSignal=true)=0
Defines the current document that used for current work in the application.
virtual bool isLoading()
Returns true if a loading process is performed (so, no need to react on a new part creation)
Definition: ModelAPI_Session.h:56
virtual bool load(const char *theFileName)=0
Loads the OCAF document from the file.
virtual std::shared_ptr< ModelAPI_Document > copy(std::shared_ptr< ModelAPI_Document > theSource, const int theDestID)=0
Copies the document to the new one with the given id.
virtual bool hasModuleDocument()=0
Return true if root document has been already created.
virtual bool canUndo()=0
Returns True if there are available Undos.
virtual bool isAutoUpdateBlocked()=0
Returns true if auto-update in the application is blocked.
virtual ModelAPI_ValidatorsFactory * validators()=0
Returns the validators factory: the only one instance per application.
virtual void redo()=0
Redoes last operation.
virtual void clearUndoRedo()=0
Clears undo and redo lists of all documents in the session.
virtual bool isLoadByDemand(const std::wstring theDocID, const int theDocIndex)=0
Returns true if document is not loaded yet.
virtual bool save(const char *theFileName, std::list< std::string > &theResults, bool isBackup=false)=0
Saves the OCAF document to the file.
virtual bool canRedo()=0
Returns True if there are available Redos.
virtual std::list< std::string > redoList()=0
Returns stack of rolled back operations (from last rolled back to first)
virtual void startOperation(const std::string &theId="", const bool theAttachedToNested=false)=0
Starts a new operation (opens a transaction)
virtual void undo()=0
Undoes last operation.
virtual std::shared_ptr< ModelAPI_Document > activeDocument()=0
Returns the current document that used for current work in the application.
virtual std::shared_ptr< ModelAPI_Document > moduleDocument()=0
Returns the root document of the application (that may contains sub-documents)
virtual void blockAutoUpdate(const bool theBlock)=0
Set state of the auto-update of features result in the application.
bool myIsLoading
keeps the state of the loading of the document
Definition: ModelAPI_Session.h:44
virtual void abortOperation()=0
Aborts the operation.
virtual std::list< std::shared_ptr< ModelAPI_Document > > allOpenedDocuments()=0
Returns all the opened documents of the session (without postponed)
virtual void finishOperation()=0
Finishes the previously started operation (closes the transaction)
Manages the registered validators.
Definition: ModelAPI_Validator.h:66