edits
[iotcloud.git] / version2 / src / C / ArbitrationRound.cc
index 8b847855d3858f3eb59ef4503f13786cc8c2a7a9..f7886711cd4c819f11fd34c941535f6b0caabbe1 100644 (file)
@@ -1,25 +1,29 @@
-#include"ArbitrationRound.h"
+#include "ArbitrationRound.h"
+#include "Commit.h"
 
-ArbitrationRound::ArbitrationRound(Commit * _commit, Set<Abort *> * _abortsBefore) {
-  parts = new ArrayList<Entry>();
-  commit = _commit;
-  abortsBefore = _abortsBefore;
+ArbitrationRound::ArbitrationRound(Commit * _commit, Hashset<Abort *> * _abortsBefore) :
+       abortsBefore(_abortsBefore),
+  parts(new Vector<Entry *>()),
+  commit(_commit),
+       currentSize(0),
+       didSendPart(false),
+       didGenerateParts(false) {
   
   if (commit != NULL) {
-    commit.createCommitParts();
-    currentSize += commit.getNumberOfParts();
-    }
+    commit->createCommitParts();
+    currentSize += commit->getNumberOfParts();
+       }
   
-  currentSize += abortsBefore.size();
+  currentSize += abortsBefore->size();
 }
 
 void ArbitrationRound::generateParts() {
   if (didGenerateParts) {
     return;
   }
-  parts = new ArrayList<Entry>(abortsBefore);
+  parts = new Vector<Entry>(abortsBefore);
   if (commit != NULL) {
-    parts.addAll(commit.getParts().values());
+    parts->addAll(commit->getParts()->values());
   }
 }
 
@@ -28,16 +32,16 @@ List<Entry *> * ArbitrationRound::getParts() {
 }
 
 void ArbitrationRound::removeParts(List<Entry *> * removeParts) {
-  parts.removeAll(removeParts);
+  parts->removeAll(removeParts);
   didSendPart = true;
 }
 
 bool ArbitrationRound::isDoneSending() {
-  if ((commit == NULL) && abortsBefore.isEmpty()) {
+  if ((commit == NULL) && abortsBefore->isEmpty()) {
     return true;
   }
   
-  return parts.isEmpty();
+  return parts->isEmpty();
 }
 
 Commit * ArbitrationRound::getCommit() {
@@ -46,31 +50,31 @@ Commit * ArbitrationRound::getCommit() {
   
 void ArbitrationRound::setCommit(Commit * _commit) {
   if (commit != NULL) {
-    currentSize -= commit.getNumberOfParts();
+    currentSize -= commit->getNumberOfParts();
   }
   commit = _commit;
   
   if (commit != NULL) {
-    currentSize += commit.getNumberOfParts();
+    currentSize += commit->getNumberOfParts();
   }
 }
 
 void ArbitrationRound::addAbort(Abort * abort) {
-  abortsBefore.add(abort);
+  abortsBefore->add(abort);
   currentSize++;
 }
   
-void ArbitrationRound::addAborts(Set<Abort *> * aborts) {
-  abortsBefore.addAll(aborts);
-  currentSize += aborts.size();
+void ArbitrationRound::addAborts(Hashset<Abort *> * aborts) {
+  abortsBefore->addAll(aborts);
+  currentSize += aborts->size();
 }
   
-Set<Abort> ArbitrationRound::getAborts() {
+Hashset<Abort *> * ArbitrationRound::getAborts() {
   return abortsBefore;
 }
 
 int ArbitrationRound::getAbortsCount() {
-  return abortsBefore.size();
+  return abortsBefore->size();
 }
 
 int ArbitrationRound::getCurrentSize() {
@@ -81,7 +85,7 @@ bool ArbitrationRound::isFull() {
   return currentSize >= MAX_PARTS;
 }
   
-bool ArbitrationRound::didSendPart() {
+bool ArbitrationRound::getDidSendPart() {
   return didSendPart;
 }