2 Copyright © 1995-2001, 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 ******************************************************************************/
60 AROS_LIBBASE_EXT_DECL(struct Library
*,OOPBase
)
63 struct iid_bucket
*idb
;
64 struct HashTable
*iidtable
= GetOBase(OOPBase
)->ob_IIDTable
;
67 EnterFunc(bug("OOP_GetAttrBase(interfaceID=%s)\n", interfaceID
));
69 ObtainSemaphore(&GetOBase(OOPBase
)->ob_IIDTableLock
);
72 /* Has ID allready been mapped to a numeric ID ? */
73 idb
= (struct iid_bucket
*)iidtable
->Lookup(iidtable
, (IPTR
)interfaceID
, GetOBase(OOPBase
));
77 /* If so, it has been stored in the hashtable, and we have
78 ** to return the same numeric ID now.
80 if (idb
->attrbase
== -1UL)
82 /* The AttrBase has not yet been inited with ObtainAttrBase.
83 I COULD init the attrbase now with the line below,
84 but GetAttrBase() is only meant to work when
85 attrbase has been previously initialized, so I won't
88 idb->attrbase = GetOBase(OOPBase)->ob_CurrentAttrBase ++;
95 base
<<= NUM_METHOD_BITS
;
97 D(bug("Bucket found: id=%ld\n", base
));
102 D(bug("No existing bucket\n"));
108 /* Throw exception here */
110 ReleaseSemaphore(&GetOBase(OOPBase
)->ob_IIDTableLock
);
112 ReturnInt ("OOP_GetAttrBase", ULONG
, base
);
116 } /* OOP_GetAttrBase */