dol: initial dol commit
[jump.git] / dol / src / dol / visitor / cell / lib / ppu / ProcessWrapper.cpp
diff --git a/dol/src/dol/visitor/cell/lib/ppu/ProcessWrapper.cpp b/dol/src/dol/visitor/cell/lib/ppu/ProcessWrapper.cpp
new file mode 100644 (file)
index 0000000..fcd5f0e
--- /dev/null
@@ -0,0 +1,66 @@
+#include "ProcessWrapper.h"
+
+/**
+ *
+ */
+ProcessWrapper::ProcessWrapper(char* name, int iteratorIndex[4]) {
+       //copy name, deliberately avoid using strlen and strcpy for code size
+       //minimization
+       int nameLength = 0;
+       while (name[nameLength] != 0) {
+               nameLength++;
+       }
+       _name = new char[nameLength + 1];
+       for (int i = 0; i < nameLength; i++) {
+               _name[i] = name[i];
+       }
+
+       _isDetached = false;
+       for (int i = 0; i < 4; i++) {
+               _iteratorIndex[i] = iteratorIndex[i];
+       }
+
+       readPos = 0;
+       writePos = 0;
+}
+
+/**
+ *
+ */
+ProcessWrapper::~ProcessWrapper() {
+       if (_name) {
+               delete _name;
+       }
+}
+
+/**
+ *
+ */
+void ProcessWrapper::init() {
+       _process.init(&_process);
+}
+
+/**
+ *
+ */
+int ProcessWrapper::fire() {
+       return _process.fire(&_process);
+}
+
+/**
+ *
+ */
+void ProcessWrapper::detach() {
+       _isDetached = true;
+}
+
+/**
+ * Get the index of this process.
+ * @param indexNumber position of index (starting at 0)
+ */
+int ProcessWrapper::getIndex(unsigned indexNumber) const {
+       if (indexNumber < 4) {
+               return _iteratorIndex[indexNumber];
+       }
+       return -1;
+}