_screen is only valid between show/hide.
[AROS.git] / rom / oop / getattrbase.c
blobf456ffbaed3169e798de4ab0eb91128716f6e99e
1 /*
2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: OOP function OOP_GetAttrBase
6 Lang: english
7 */
9 #include "intern.h"
10 #include "hash.h"
11 /*****************************************************************************
13 NAME */
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,
22 /* SYNOPSIS */
23 AROS_LHA(CONST_STRPTR , interfaceID, A0),
25 /* LOCATION */
26 struct Library *, OOPBase, 15, OOP)
28 /* FUNCTION
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
36 it implements.
38 INPUTS
39 interfaceID - globally unique interface identifier.
41 RESULT
42 Numeric AttrBase that is unique for this machine.
43 There are NO error conditions.
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
53 INTERNALS
55 HISTORY
57 ******************************************************************************/
59 AROS_LIBFUNC_INIT
61 /* Look up ID */
62 struct iid_bucket *idb;
63 struct HashTable *iidtable = GetOBase(OOPBase)->ob_IIDTable;
64 ULONG base = (ULONG)-1;
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));
73 if (idb)
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
85 support this.
87 idb->attrbase = ++GetOBase(OOPBase)->ob_CurrentAttrBase;
90 base = 0;
93 base = idb->attrbase;
94 base <<= NUM_METHOD_BITS;
96 D(bug("Bucket found: id=%ld\n", base));
98 else
100 base = 0;
101 D(bug("No existing bucket\n"));
105 if (base == 0)
107 /* Throw exception here */
109 ReleaseSemaphore(&GetOBase(OOPBase)->ob_IIDTableLock);
111 ReturnInt ("OOP_GetAttrBase", ULONG, base);
113 AROS_LIBFUNC_EXIT
115 } /* OOP_GetAttrBase */