0030773: Application Framework - To allow to inherit existing attributes to reuse...
[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)
37 {
38   if (!myMap.IsBound (theType)) // try to assign driver for derived type
39   {
40     AddDerivedDriver (theType->Name());
41   }
42
43   Standard_Integer anId = 0;
44   if (myMap.IsBound(theType)) {
45     theDriver = myMap (theType);
46     if (myMapId.IsBound1(theType))
47       anId = myMapId.Find1 (theType);
48   }
49   return anId;
50 }
51
52 //=======================================================================
53 //function : GetDriver
54 //purpose  : Returns a driver according to <theTypeId>.
55 //           Returns null handle if a driver is not found
56 //=======================================================================
57
58 inline Handle(BinMDF_ADriver) BinMDF_ADriverTable::GetDriver
59                 (const Standard_Integer theTypeId)
60 {
61   Handle(BinMDF_ADriver) aDriver;
62   if (myMapId.IsBound2(theTypeId)) {
63     const Handle(Standard_Type)& aType = myMapId.Find2 (theTypeId);
64     aDriver = myMap (aType);
65   }
66   return aDriver;
67 }