Making C++ classes final
[iot2.git] / iotjava / iotrmi / C++ / ConcurrentLinkedListQueue.hpp
index e18e5e44f4991da763655a996dc2ae1b529438bf..6c9220a6648a048b49b3c87304e3fb5476f95606 100644 (file)
@@ -3,10 +3,12 @@
 #include <iostream>
 #include <mutex>
 
+#include "IoTRMIUtil.hpp"
+
 /** Class ConcurrentLinkedListQueue is a queue that can handle
  *  concurrent requests and packets for IoT communication via socket.
  *  <p>
- *  It stores object through a void pointer.
+ *  It stores object through a char pointer.
  *
  * @author      Rahmadi Trimananda <rtrimana @ uci.edu>
  * @version     1.0
 
 using namespace std;
 
-mutex mtx;
+mutex queueMutex;
 
-class Node {
+class Node final {
 
        private:
                Node* next;
-               void* value;
+               char* value;
+               int length;
 
        public:
-               Node(void* val);
+               Node(char* val, int len);
                ~Node();
-               void* getValue();
+               char* getValue();
+               int getLength();
                Node* getNext();
                void setNext(Node* nxt);
 
 };
 
 
-class ConcurrentLinkedListQueue {
+class ConcurrentLinkedListQueue final {
 
        private:
                Node* tail;
@@ -42,7 +46,8 @@ class ConcurrentLinkedListQueue {
        public:
                ConcurrentLinkedListQueue();
                ~ConcurrentLinkedListQueue();
-               void enqueue(void* value);      // Enqueue to tail
-               void* dequeue();                        // Dequeue from tail
+               void enqueue(char* value, int length);  // Enqueue to tail
+               char* dequeue();                                                // Dequeue from tail
+               char* deQAndGetLength(int* length);             // Dequeue from tail and return length
 };
 #endif