Bug fixes + tabbing
[iotcloud.git] / version2 / src / C / ArbitrationRound.cc
index da21dda20218dcdd7939d3538730d69b94ee6df1..f5a1521722e444bbeff3e2d841a23dfce3e6a8c5 100644 (file)
@@ -17,33 +17,43 @@ ArbitrationRound::ArbitrationRound(Commit *_commit, Hashset<Abort *> *_abortsBef
        currentSize += abortsBefore->size();
 }
 
-/*
-   void ArbitrationRound::generateParts() {
-   if (didGenerateParts) {
-    return;
-   }
-   parts = new Vector<Entry *>((Vector<Entry *> *)abortsBefore);
-   if (commit != NULL) {
-    parts->addAll(commit->getParts()->values());
-   }
-   }*/
+ArbitrationRound::~ArbitrationRound() {
+       delete abortsBefore;
+       delete parts;
+}
+
+void ArbitrationRound::generateParts() {
+       if (didGenerateParts) {
+               return;
+       }
+       parts = new Vector<Entry *>();
+       SetIterator<Abort *, Abort *> *abit = abortsBefore->iterator();
+       while (abit->hasNext())
+               parts->add((Entry *)abit->next());
+       delete abit;
+       if (commit != NULL) {
+               Vector<CommitPart *> *cParts = commit->getParts();
+               uint cPartsSize = cParts->size();
+               for (uint i = 0; i < cPartsSize; i++) {
+                       parts->add((Entry *)cParts->get(i));
+               }
+       }
+}
 
 Vector<Entry *> *ArbitrationRound::getParts() {
        return parts;
 }
 
-/*
-   void ArbitrationRound::removeParts(Vector<Entry *> * removeParts) {
-   parts->removeAll(removeParts);
-   didSendPart = true;
-   }
- */
+void ArbitrationRound::removeParts(Vector<Entry *> *removeParts) {
+       parts->removeAll(removeParts);
+       didSendPart = true;
+}
+
 
 bool ArbitrationRound::isDoneSending() {
        if ((commit == NULL) && abortsBefore->isEmpty()) {
                return true;
        }
-
        return parts->isEmpty();
 }
 
@@ -85,10 +95,9 @@ int ArbitrationRound::getCurrentSize() {
 }
 
 bool ArbitrationRound::isFull() {
-       return currentSize >= MAX_PARTS;
+       return currentSize >= ArbitrationRound_MAX_PARTS;
 }
 
 bool ArbitrationRound::getDidSendPart() {
        return didSendPart;
 }
-