1 #include "DF_definitions.hxx"
2 #include "DF_Application.hxx"
7 DF_Application::DF_Application()
12 DF_Application::~DF_Application()
17 //Creates a new document with given type, returns a smart pointer to
18 //newly created document.
19 DF_Document* DF_Application::NewDocument(const string& theDocumentType)
21 DF_Document* aDoc = new DF_Document(theDocumentType);
22 aDoc->_id = ++_currentID;
23 _documents[aDoc->_id] = aDoc;
28 //Closes and removes the given Document
29 void DF_Application::Close(const DF_Document* theDocument)
32 if(theDocument) id = theDocument->GetDocumentID();
34 if(_documents.find(id) != _documents.end()) {
35 _documents[id]->Clear();
41 //Returns a Document by Document's ID
42 DF_Document* DF_Application::GetDocument(int theDocumentID)
44 if(_documents.find(theDocumentID) == _documents.end()) return NULL;
46 return _documents[theDocumentID];
49 //Returns a list of IDs of all currently opened documents
50 vector<int> DF_Application::GetDocumentIDs()
53 typedef map<int, DF_Document*>::const_iterator DI;
54 for(DI p = _documents.begin(); p!=_documents.end(); p++)
55 ids.push_back(p->first);
59 //Returns a number of existent documents
60 int DF_Application::NbDocuments()
62 return _documents.size();
66 //Restores a Document from the given file, returns a smart
67 //pointer to opened document.
68 DF_Document* DF_Application::Open(const string& theFileName)
75 //Saves a Document in a given file with name theFileName
76 void DF_Application::SaveAs(const DF_Document* theDocument, const string& theFileName)