2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
5 Desc: Parallel hidd class implementation.
9 #define __OOP_NOATTRBASES__
11 #include <proto/exec.h>
12 #include <proto/utility.h>
13 #include <proto/oop.h>
14 #include <exec/libraries.h>
16 #include <utility/tagitem.h>
17 #include <hidd/parallel.h>
20 #include "parallel_intern.h"
22 #include <aros/debug.h>
25 /*static AttrBase HiddGCAttrBase;*/
27 static OOP_AttrBase HiddParallelUnitAB
;
29 /*** HIDDParallel::NewUnit() *********************************************************/
32 OOP_Object
*AmigaPar__Hidd_Parallel__NewUnit(OOP_Class
*cl
, OOP_Object
*obj
,
33 struct pHidd_Parallel_NewUnit
*msg
)
35 OOP_Object
*su
= NULL
;
36 struct HIDDParallelData
* data
= OOP_INST_DATA(cl
, obj
);
39 EnterFunc(bug("HIDDParallel::NewParallel()\n"));
41 D(bug("Request for unit number %d\n",msg
->unitnum
));
43 if (msg
->unitnum
>= 0 && msg
->unitnum
< PAR_MAX_UNITS
) {
44 unitnum
= msg
->unitnum
;
46 if (0 != (data
->usedunits
& (1 << unitnum
))) {
49 } else if (msg
->unitnum
== -1) {
50 /* search for the next available unit */
53 while (unitnum
< PAR_MAX_UNITS
) {
54 if (0 == (data
->usedunits
& (1 << unitnum
))) {
62 if (unitnum
>= 0 && unitnum
< PAR_MAX_UNITS
) {
63 struct TagItem tags
[] =
65 {aHidd_ParallelUnit_Unit
, unitnum
},
69 su
= OOP_NewObject(NULL
, CLID_Hidd_ParallelUnit
, tags
);
70 data
->ParallelUnits
[unitnum
] = su
;
75 data
->usedunits
|= (1 << unitnum
);
78 ReturnPtr("HIDDParallel::NewParallel", OOP_Object
*, su
);
82 /*** HIDDParallel::DisposeUnit() ****************************************************/
84 VOID
AmigaPar__Hidd_Parallel__DisposeUnit(OOP_Class
*cl
, OOP_Object
*obj
,
85 struct pHidd_Parallel_DisposeUnit
*msg
)
87 OOP_Object
* pu
= msg
->unit
;
88 struct HIDDParallelData
* data
= OOP_INST_DATA(cl
, obj
);
90 EnterFunc(bug("HIDDParallel::DisposeUnit()\n"));
95 while (unitnum
< PAR_MAX_UNITS
) {
96 if (data
->ParallelUnits
[unitnum
] == pu
) {
97 D(bug("Disposing ParallelUnit!\n"));
98 OOP_DisposeObject(pu
);
99 data
->ParallelUnits
[unitnum
] = NULL
;
100 data
->usedunits
&= ~(1 << unitnum
);
108 ReturnVoid("HIDDParallel::DisposeUnit");