1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "DF_definitions.hxx"
21 #include "DF_Application.hxx"
24 DF_Application::DF_Application()
29 DF_Application::~DF_Application()
34 //Creates a new document with given type, returns a smart pointer to
35 //newly created document.
36 DF_Document* DF_Application::NewDocument(const std::string& theDocumentType)
38 DF_Document* aDoc = new DF_Document(theDocumentType);
39 aDoc->_id = ++_currentID;
40 _documents[aDoc->_id] = aDoc;
45 //Closes and removes the given Document
46 void DF_Application::Close(const DF_Document* theDocument)
49 if(theDocument) id = theDocument->GetDocumentID();
51 if(_documents.find(id) != _documents.end()) {
52 _documents[id]->Clear();
58 //Returns a Document by Document's ID
59 DF_Document* DF_Application::GetDocument(int theDocumentID)
61 if(_documents.find(theDocumentID) == _documents.end()) return NULL;
63 return _documents[theDocumentID];
66 //Returns a list of IDs of all currently opened documents
67 std::vector<int> DF_Application::GetDocumentIDs()
70 typedef std::map<int, DF_Document*>::const_iterator DI;
71 for(DI p = _documents.begin(); p!=_documents.end(); p++)
72 ids.push_back(p->first);
76 //Returns a number of existent documents
77 int DF_Application::NbDocuments()
79 return _documents.size();
83 //Restores a Document from the given file, returns a smart
84 //pointer to opened document.
85 DF_Document* DF_Application::Open(const std::string& theFileName)
92 //Saves a Document in a given file with name theFileName
93 void DF_Application::SaveAs(const DF_Document* theDocument, const std::string& theFileName)