1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "DF_definitions.hxx"
23 #include "DF_Application.hxx"
28 DF_Application::DF_Application()
33 DF_Application::~DF_Application()
38 //Creates a new document with given type, returns a smart pointer to
39 //newly created document.
40 DF_Document* DF_Application::NewDocument(const string& theDocumentType)
42 DF_Document* aDoc = new DF_Document(theDocumentType);
43 aDoc->_id = ++_currentID;
44 _documents[aDoc->_id] = aDoc;
49 //Closes and removes the given Document
50 void DF_Application::Close(const DF_Document* theDocument)
53 if(theDocument) id = theDocument->GetDocumentID();
55 if(_documents.find(id) != _documents.end()) {
56 _documents[id]->Clear();
62 //Returns a Document by Document's ID
63 DF_Document* DF_Application::GetDocument(int theDocumentID)
65 if(_documents.find(theDocumentID) == _documents.end()) return NULL;
67 return _documents[theDocumentID];
70 //Returns a list of IDs of all currently opened documents
71 vector<int> DF_Application::GetDocumentIDs()
74 typedef map<int, DF_Document*>::const_iterator DI;
75 for(DI p = _documents.begin(); p!=_documents.end(); p++)
76 ids.push_back(p->first);
80 //Returns a number of existent documents
81 int DF_Application::NbDocuments()
83 return _documents.size();
87 //Restores a Document from the given file, returns a smart
88 //pointer to opened document.
89 DF_Document* DF_Application::Open(const string& theFileName)
96 //Saves a Document in a given file with name theFileName
97 void DF_Application::SaveAs(const DF_Document* theDocument, const string& theFileName)