dol: initial dol commit
[jump.git] / dol / src / dol / visitor / cell / lib / ppu / ProcessWrapper.cpp
1 #include "ProcessWrapper.h"
2
3 /**
4  *
5  */
6 ProcessWrapper::ProcessWrapper(char* name, int iteratorIndex[4]) {
7         //copy name, deliberately avoid using strlen and strcpy for code size
8         //minimization
9         int nameLength = 0;
10         while (name[nameLength] != 0) {
11                 nameLength++;
12         }
13         _name = new char[nameLength + 1];
14         for (int i = 0; i < nameLength; i++) {
15                 _name[i] = name[i];
16         }
17
18         _isDetached = false;
19         for (int i = 0; i < 4; i++) {
20                 _iteratorIndex[i] = iteratorIndex[i];
21         }
22
23         readPos = 0;
24         writePos = 0;
25 }
26
27 /**
28  *
29  */
30 ProcessWrapper::~ProcessWrapper() {
31         if (_name) {
32                 delete _name;
33         }
34 }
35
36 /**
37  *
38  */
39 void ProcessWrapper::init() {
40         _process.init(&_process);
41 }
42
43 /**
44  *
45  */
46 int ProcessWrapper::fire() {
47         return _process.fire(&_process);
48 }
49
50 /**
51  *
52  */
53 void ProcessWrapper::detach() {
54         _isDetached = true;
55 }
56
57 /**
58  * Get the index of this process.
59  * @param indexNumber position of index (starting at 0)
60  */
61 int ProcessWrapper::getIndex(unsigned indexNumber) const {
62         if (indexNumber < 4) {
63                 return _iteratorIndex[indexNumber];
64         }
65         return -1;
66 }