0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / BinMDF / BinMDF_ADriverTable.lxx
1 // Created on: 2002-10-29
2 // Created by: Michael SAZONOV
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //=======================================================================
17 //function : AssignId
18 //purpose  : Assigns the ID to the driver of the Type
19 //=======================================================================
20
21 inline void BinMDF_ADriverTable::AssignId
22                 (const Handle(Standard_Type)& theType,
23                  const Standard_Integer theId)
24 {
25   myMapId.Bind (theType, theId);
26 }
27
28 //=======================================================================
29 //function : GetDriver
30 //purpose  : Gets a driver <theDriver> according to <theType>.
31 //           Returns Type ID if the driver was assigned an ID; 0 otherwise.
32 //=======================================================================
33
34 inline Standard_Integer BinMDF_ADriverTable::GetDriver
35                 (const Handle(Standard_Type)&   theType,
36                  Handle(BinMDF_ADriver)&        theDriver) const
37 {
38   Standard_Integer anId = 0;
39   if (myMap.IsBound(theType)) {
40     theDriver = myMap (theType);
41     if (myMapId.IsBound1(theType))
42       anId = myMapId.Find1 (theType);
43   }
44   return anId;
45 }
46
47 //=======================================================================
48 //function : GetDriver
49 //purpose  : Returns a driver according to <theTypeId>.
50 //           Returns null handle if a driver is not found
51 //=======================================================================
52
53 inline Handle(BinMDF_ADriver) BinMDF_ADriverTable::GetDriver
54                 (const Standard_Integer theTypeId) const
55 {
56   Handle(BinMDF_ADriver) aDriver;
57   if (myMapId.IsBound2(theTypeId)) {
58     const Handle(Standard_Type)& aType = myMapId.Find2 (theTypeId);
59     aDriver = myMap (aType);
60   }
61   return aDriver;
62 }