2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: OOP function OOP_GetAttrBase
11 /*****************************************************************************
14 #include <proto/exec.h>
15 #include <exec/memory.h>
16 #include <aros/libcall.h>
18 #include <aros/debug.h>
20 AROS_LH1(OOP_AttrBase
, OOP_GetAttrBase
,
23 AROS_LHA(STRPTR
, interfaceID
, A0
),
26 struct Library
*, OOPBase
, 15, OOP
)
29 Maps a globally unique string interface ID into
30 a numeric AttrBase ID that is unique on
31 pr. machine basis. IMPORTANT: You MUST
32 be sure that at least one class implementing
33 specified interface is initialized at the time calling
34 this function. This function is especially useful
35 for a class to get AttrBases of the interfaces
39 interfaceID - globally unique interface identifier.
42 Numeric AttrBase that is unique for this machine.
43 There are NO error conditions.
57 ******************************************************************************/
62 struct iid_bucket
*idb
;
63 struct HashTable
*iidtable
= GetOBase(OOPBase
)->ob_IIDTable
;
66 EnterFunc(bug("OOP_GetAttrBase(interfaceID=%s)\n", interfaceID
));
68 ObtainSemaphore(&GetOBase(OOPBase
)->ob_IIDTableLock
);
71 /* Has ID allready been mapped to a numeric ID ? */
72 idb
= (struct iid_bucket
*)iidtable
->Lookup(iidtable
, (IPTR
)interfaceID
, GetOBase(OOPBase
));
76 /* If so, it has been stored in the hashtable, and we have
77 ** to return the same numeric ID now.
79 if (idb
->attrbase
== (ULONG
)-1)
81 /* The AttrBase has not yet been inited with ObtainAttrBase.
82 I COULD init the attrbase now with the line below,
83 but GetAttrBase() is only meant to work when
84 attrbase has been previously initialized, so I won't
87 idb->attrbase = GetOBase(OOPBase)->ob_CurrentAttrBase ++;
94 base
<<= NUM_METHOD_BITS
;
96 D(bug("Bucket found: id=%ld\n", base
));
101 D(bug("No existing bucket\n"));
107 /* Throw exception here */
109 ReleaseSemaphore(&GetOBase(OOPBase
)->ob_IIDTableLock
);
111 ReturnInt ("OOP_GetAttrBase", ULONG
, base
);
115 } /* OOP_GetAttrBase */