1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <Standard_NoSuchObject.hxx>
17 #include <Standard_Persistent.hxx>
18 #include <Standard_Type.hxx>
19 #include <Storage_DataMapIteratorOfMapOfPers.hxx>
20 #include <Storage_Root.hxx>
21 #include <Storage_RootData.hxx>
22 #include <Storage_Schema.hxx>
23 #include <TCollection_AsciiString.hxx>
25 IMPLEMENT_STANDARD_RTTIEXT(Storage_RootData,MMgt_TShared)
27 Storage_RootData::Storage_RootData() : myErrorStatus(Storage_VSOk)
31 Standard_Integer Storage_RootData::NumberOfRoots() const
33 return myObjects.Extent();
36 void Storage_RootData::AddRoot(const Handle(Storage_Root)& aRoot)
38 myObjects.Bind(aRoot->Name(),aRoot);
41 Handle(Storage_HSeqOfRoot) Storage_RootData::Roots() const
43 Handle(Storage_HSeqOfRoot) anObjectsSeq = new Storage_HSeqOfRoot;
44 Storage_DataMapIteratorOfMapOfPers it(myObjects);
46 for(;it.More(); it.Next()) {
47 anObjectsSeq->Append(it.Value());
53 Handle(Storage_Root) Storage_RootData::Find(const TCollection_AsciiString& aName) const
55 Handle(Storage_Root) p;
57 if (myObjects.IsBound(aName)) {
58 p = myObjects.Find(aName);
64 Standard_Boolean Storage_RootData::IsRoot(const TCollection_AsciiString& aName) const
66 return myObjects.IsBound(aName);
69 void Storage_RootData::RemoveRoot(const TCollection_AsciiString& aName)
71 if (myObjects.IsBound(aName)) {
72 myObjects.UnBind(aName);
76 void Storage_RootData::UpdateRoot(const TCollection_AsciiString& aName,const Handle(Standard_Persistent)& aPers)
78 if (myObjects.IsBound(aName)) {
79 myObjects.ChangeFind(aName)->SetObject(aPers);
82 Standard_NoSuchObject::Raise();
86 Storage_Error Storage_RootData::ErrorStatus() const
91 void Storage_RootData::SetErrorStatus(const Storage_Error anError)
93 myErrorStatus = anError;
96 void Storage_RootData::ClearErrorStatus()
98 myErrorStatus = Storage_VSOk;
99 myErrorStatusExt.Clear();
102 TCollection_AsciiString Storage_RootData::ErrorStatusExtension() const
104 return myErrorStatusExt;
107 void Storage_RootData::SetErrorStatusExtension(const TCollection_AsciiString& anErrorExt)
109 myErrorStatusExt = anErrorExt;