Official reference client implementation for Cumulocity SmartREST on u-blox C027.

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Vincent Wochnik

Revision:
93:0acd11870c6a
Parent:
92:48069375dffa
Child:
94:61d44636f020
--- a/operation/OperationStore.cpp	Fri Mar 20 14:27:10 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-#include "OperationStore.h"
-#include <stdlib.h>
-#include <string.h>
-
-/*#define OPERATION_PENDING    0
-#define OPERATION_EXECUTING  1
-#define OPERATION_SUCCESS    2
-#define OPERATION_FAILURE    3
-#define OPERATION_STORE_SIZE 128*/
-
-OperationStore::OperationStore() :
-    _count(0),
-    _offset(0)
-{
-}
-
-bool OperationStore::enqueue(Operation& operation)
-{
-    _mutex.lock();
-    if ((full()) || (getByIdentifier(operation.identifier) != NULL) ||
-            (operation.state != OPERATION_PENDING)) {
-        _mutex.unlock();
-        return false;
-    }
-    
-    memcpy(get(_count++), &operation, sizeof(OperationStore::Operation));
-    _mutex.unlock();
-    return true;
-}
-
-bool OperationStore::takePending(Operation& operation)
-{
-    size_t n;
-    Operation *tmp;
-
-    _mutex.lock();
-    for (n = 0; n < _count; n++) {
-        tmp = get(n);
-        if (tmp->state != OPERATION_PENDING)
-            continue;
-        
-        tmp->state = OPERATION_EXECUTING;
-        memcpy(&operation, tmp, sizeof(OperationStore::Operation));
-
-        _mutex.unlock();
-        return true;
-    }
-
-    _mutex.unlock();    
-    return false;
-}
-
-bool OperationStore::hasPending()
-{
-    size_t n;
-    Operation *tmp;
-
-    _mutex.lock();
-    for (n = 0; n < _count; n++) {
-        tmp = get(n);
-        if (tmp->state != OPERATION_PENDING)
-            continue;
-        
-        _mutex.unlock();
-        return true;
-    }
-
-    _mutex.unlock();    
-    return false;
-}
-    
-bool OperationStore::markAsDone(Operation& operation, bool successful)
-{
-    Operation *tmp;
-
-    _mutex.lock();    
-    tmp = getByIdentifier(operation.identifier);
-    if ((tmp == NULL) || (tmp->state != OPERATION_EXECUTING)) {
-        _mutex.unlock();
-        return false;
-    }
-    
-    tmp->state = (successful) ? OPERATION_SUCCESSFUL : OPERATION_FAILED;
-    _mutex.unlock();
-    return true;
-}
-    
-bool OperationStore::takeDone(Operation& operation)
-{
-    Operation *tmp;
-    
-    _mutex.lock();
-    tmp = get(0);
-    if ((tmp == NULL) || ((tmp->state != OPERATION_SUCCESSFUL) &&
-            (tmp->state != OPERATION_FAILED))) {
-        _mutex.unlock();
-        return false;
-    }
-    
-    if (++_offset == OPERATION_STORE_SIZE)
-        _offset = 0;
-    _count--;
-    
-    memcpy(&operation, tmp, sizeof(OperationStore::Operation));
-
-    _mutex.unlock();
-    return true;
-}
-    
-bool OperationStore::full()
-{
-    bool ret;
-    
-    _mutex.lock();
-    ret = (_count == OPERATION_STORE_SIZE);
-    _mutex.unlock();
-
-    return ret;
-}
-
-bool OperationStore::empty()
-{
-    bool ret;
-    
-    _mutex.lock();
-    ret = (_count == 0);
-    _mutex.unlock();
-    
-    return ret;
-}
-
-OperationStore::Operation * OperationStore::get(size_t index)
-{
-    size_t i;
-    
-    if (_offset + index < OPERATION_STORE_SIZE)
-        i = _offset + index;
-    else
-        i = index - (OPERATION_STORE_SIZE - _offset);
-    
-    return &_store[i];
-}
-
-OperationStore::Operation * OperationStore::getByIdentifier(long identifier)
-{
-    size_t n;
-    Operation *tmp;
-    
-    for (n = 0; n < _count; n++) {
-        tmp = get(n);
-        if (tmp->identifier == identifier)
-            return tmp;
-    }
-
-    return NULL;
-}