]> SALOME platform Git repositories - modules/kernel.git/blob - src/DF/DF_Application.cxx
Salome HOME
CCAR: add a trace in beginService and endService even in no debug mode to give cpu...
[modules/kernel.git] / src / DF / DF_Application.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #include "DF_definitions.hxx"
23 #include "DF_Application.hxx"
24
25 using namespace std;
26
27 //Constructor
28 DF_Application::DF_Application()
29 {
30   _currentID = 0;
31 }
32   
33 DF_Application::~DF_Application()
34 {
35   _documents.clear();
36 }
37
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) 
41 {
42   DF_Document* aDoc = new DF_Document(theDocumentType);
43   aDoc->_id = ++_currentID;
44   _documents[aDoc->_id] = aDoc;
45   aDoc->_appli = this; 
46   return aDoc;
47 }
48
49 //Closes and removes the given Document
50 void DF_Application::Close(const DF_Document* theDocument)
51 {
52   int id = -1;
53   if(theDocument) id = theDocument->GetDocumentID();
54
55   if(_documents.find(id) != _documents.end()) {
56     _documents[id]->Clear();
57     _documents.erase(id);
58     delete theDocument;
59   }
60 }
61
62 //Returns a Document by Document's ID
63 DF_Document* DF_Application::GetDocument(int theDocumentID)
64 {
65   if(_documents.find(theDocumentID) == _documents.end()) return NULL;
66
67   return _documents[theDocumentID];
68 }
69
70 //Returns a list of IDs of all currently opened documents
71 vector<int> DF_Application::GetDocumentIDs()
72 {
73   vector<int> ids;
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);
77   return ids;
78 }
79
80 //Returns a number of existent documents
81 int DF_Application::NbDocuments()
82 {
83   return _documents.size();
84 }
85
86
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)
90 {
91   //Not implemented
92   return NULL;
93 }
94
95
96 //Saves a Document in a given file with name theFileName
97 void DF_Application::SaveAs(const DF_Document* theDocument, const string& theFileName)
98 {
99   //Not implemented
100 }