0023024: Update headers of OCCT files
[occt.git] / src / CDF / CDF_Directory.cxx
1 // Created on: 1997-08-07
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <CDF_Directory.ixx>
24 #include <CDM_ListIteratorOfListOfDocument.hxx>
25 #include <Standard_NoSuchObject.hxx>
26 CDF_Directory::CDF_Directory () {}
27
28 void CDF_Directory::Add(const Handle(CDM_Document)& aDocument) {
29   if(!Contains(aDocument)) myDocuments.Append(aDocument);
30 }
31
32 void CDF_Directory::Remove(const Handle(CDM_Document)& aDocument) {
33
34   CDM_ListIteratorOfListOfDocument it(myDocuments);
35   
36   Standard_Boolean found = Standard_False;
37   for (; it.More() && !found;) {
38     found = aDocument == it.Value();
39     if(found) 
40       myDocuments.Remove(it);
41     else
42       it.Next();
43   }
44 }
45
46
47 Standard_Boolean CDF_Directory::Contains(const Handle(CDM_Document)& aDocument) const {
48
49   CDM_ListIteratorOfListOfDocument it(myDocuments);
50   Standard_Boolean found = Standard_False;
51   for (; it.More() && !found; it.Next()) {
52     found = aDocument == it.Value();
53   }
54   return found;
55 }
56
57
58 Standard_Integer CDF_Directory::Length() const {
59   return myDocuments.Extent();
60 }
61
62 const CDM_ListOfDocument& CDF_Directory::List() const {
63
64   return myDocuments;
65
66 }
67
68 Standard_Boolean CDF_Directory::IsEmpty() const {
69   return myDocuments.IsEmpty();
70 }
71 Handle(CDM_Document) CDF_Directory::Last() {
72   Standard_NoSuchObject_Raise_if(IsEmpty(),"CDF_Directory::Last: the directory does not contain any document");
73   return myDocuments.Last();
74 }