b311480e |
1 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | #include <Storage_RootData.ixx> |
16 | #include <Storage_DataMapIteratorOfMapOfPers.hxx> |
17 | |
18 | Storage_RootData::Storage_RootData() : myErrorStatus(Storage_VSOk) |
19 | { |
20 | } |
21 | |
22 | Standard_Integer Storage_RootData::NumberOfRoots() const |
23 | { |
24 | return myObjects.Extent(); |
25 | } |
26 | |
27 | void Storage_RootData::AddRoot(const Handle(Storage_Root)& aRoot) |
28 | { |
29 | myObjects.Bind(aRoot->Name(),aRoot); |
30 | } |
31 | |
32 | Handle(Storage_HSeqOfRoot) Storage_RootData::Roots() const |
33 | { |
34 | Handle(Storage_HSeqOfRoot) anObjectsSeq = new Storage_HSeqOfRoot; |
35 | Storage_DataMapIteratorOfMapOfPers it(myObjects); |
36 | |
37 | for(;it.More(); it.Next()) { |
38 | anObjectsSeq->Append(it.Value()); |
39 | } |
40 | |
41 | return anObjectsSeq; |
42 | } |
43 | |
44 | Handle(Storage_Root) Storage_RootData::Find(const TCollection_AsciiString& aName) const |
45 | { |
46 | Handle(Storage_Root) p; |
47 | |
48 | if (myObjects.IsBound(aName)) { |
49 | p = myObjects.Find(aName); |
50 | } |
51 | |
52 | return p; |
53 | } |
54 | |
55 | Standard_Boolean Storage_RootData::IsRoot(const TCollection_AsciiString& aName) const |
56 | { |
57 | return myObjects.IsBound(aName); |
58 | } |
59 | |
60 | void Storage_RootData::RemoveRoot(const TCollection_AsciiString& aName) |
61 | { |
62 | if (myObjects.IsBound(aName)) { |
63 | myObjects.UnBind(aName); |
64 | } |
65 | } |
66 | |
67 | void Storage_RootData::UpdateRoot(const TCollection_AsciiString& aName,const Handle(Standard_Persistent)& aPers) |
68 | { |
69 | if (myObjects.IsBound(aName)) { |
70 | myObjects.ChangeFind(aName)->SetObject(aPers); |
71 | } |
72 | else { |
73 | Standard_NoSuchObject::Raise(); |
74 | } |
75 | } |
76 | |
77 | Storage_Error Storage_RootData::ErrorStatus() const |
78 | { |
79 | return myErrorStatus; |
80 | } |
81 | |
82 | void Storage_RootData::SetErrorStatus(const Storage_Error anError) |
83 | { |
84 | myErrorStatus = anError; |
85 | } |
86 | |
87 | void Storage_RootData::ClearErrorStatus() |
88 | { |
89 | myErrorStatus = Storage_VSOk; |
90 | myErrorStatusExt.Clear(); |
91 | } |
92 | |
93 | TCollection_AsciiString Storage_RootData::ErrorStatusExtension() const |
94 | { |
95 | return myErrorStatusExt; |
96 | } |
97 | |
98 | void Storage_RootData::SetErrorStatusExtension(const TCollection_AsciiString& anErrorExt) |
99 | { |
100 | myErrorStatusExt = anErrorExt; |
101 | } |