disable debug
[AROS.git] / rom / hidds / hidd / hwroot.c
bloba80c8e6cf0e4ae2edee6b1428bf2d4180e90ef1c
1 /*
2 Copyright (C) 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <hidd/hidd.h>
7 #include <oop/oop.h>
8 #include <utility/tagitem.h>
9 #include <proto/oop.h>
11 #include "hiddclass_intern.h"
13 /*****************************************************************************************
15 NAME
16 --background_hwroot--
18 LOCATION
19 CLID_HW_Root
21 NOTES
22 This class represents a root of HIDD subsystem tree. In other words, it
23 represents your computer. Calling HW_EnumDrivers() on it will enumerate
24 installed subsystem classes.
26 By design this class is a singletone. In order to get access to it, just
27 call OOP_NewObject() on it. Every call will return the same pointer to
28 the same object. You do not need to call OOP_Dispose object on it. Such
29 calls will simply do nothing.
31 Subsystem classes need to register themselves in the tree by calling
32 HW_AddDriver() on this class. The class keeps an eye on the subsystem
33 usage and will allow to remove it using HW_RemoveDriver() only if the
34 subsystem being removed is not in use by any other components.
36 *****************************************************************************************/
38 OOP_Object *HWRoot__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
40 struct class_static_data *csd = CSD(cl);
43 * This singletone lacks semaphore protection. It is OK since
44 * our instance is created during initialization procedure.
46 if (!csd->hwroot)
48 struct TagItem new_tags[] =
50 {aHW_ClassName, (IPTR)"Computer"},
51 {TAG_DONE , 0 }
53 struct pRoot_New new_msg =
55 .mID = msg->mID,
56 .attrList = new_tags
59 csd->hwroot = (OOP_Object *)OOP_DoSuperMethod(cl, o, &new_msg.mID);
62 return csd->hwroot;
65 void HWRoot__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
67 /* Do nothing here */
70 BOOL HWRoot__HW__RemoveDriver(OOP_Class *cl, OOP_Object *o,
71 struct pHW_RemoveDriver *msg)
73 struct Library *OOPBase = CSD(cl)->cs_OOPBase;
74 IPTR used = TRUE;
76 OOP_GetAttr(msg->driverObject, aHW_InUse, &used);
77 if (used)
78 return FALSE;
80 return OOP_DoSuperMethod(cl, o, &msg->mID);
84 * TODO: Computer can have some OEM strings, like and vendor name.
85 * In future it would be nice to make use of them by implementing
86 * respective attributes of I_Hidd interface.
87 * Perhaps, in order to be able to retrieve this properties,
88 * this class will become hardware-specific, will be separated
89 * from hiddclass.hidd, and moved to BSP.