Dependencies:   mbed QEI

Revision:
0:3c49891bc39d
Child:
1:7f0fc0d1f777
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTno/PortBase.h	Fri Jul 29 11:23:44 2011 +0000
@@ -0,0 +1,73 @@
+/*******************************************
+ * PortBase.h
+ * @author Yuki Suga
+ * @copyright Yuki Suga (ysuga.net) Nov, 10th, 2010.
+ * @license LGPLv3
+ *****************************************/
+
+#ifndef PORT_BASE_HEADER_INCLUDED
+#define PORT_BASE_HEADER_INCLUDED
+
+#include "BasicDataType.h"
+
+class PortBase {
+ private:
+
+    
+ protected:
+  void* m_pData;
+  char* m_pName;
+  char m_TypeCode;
+ public:
+  PortBase(char* name);
+  ~PortBase();
+
+ public:
+  char* GetName() {return m_pName;}
+  char GetTypeCode() {return m_TypeCode;}
+
+  int isSequenceType() {
+    switch(m_TypeCode) {
+    case 'b':
+    case 'B':
+    case 'o':
+    case 'O':
+    case 'c':
+    case 'C':
+      return 0;
+    default:
+      return 1;
+    }
+  }
+
+  int GetLength() {
+    if(!isSequenceType()) {
+      return 1;
+    } else {
+      return ((TimedDataSeq*)m_pData)->GetBuffer()->length();
+    }
+  }
+
+  void SetLength(int len) {
+    if(!isSequenceType()) {
+      return;
+    }
+    SequenceDataType *seqData = ((TimedDataSeq*)m_pData)->GetBuffer();
+    seqData->length(len);
+  }
+
+  void* GetBuffer() {
+    void* pBuffer;
+      if(!isSequenceType()) {
+      //      if (len != 1) return 0;// -INVALID_PACKET_DATASIZE;
+      pBuffer = ((TimedData*)m_pData)->GetBuffer();
+    } else {
+      SequenceDataType *seqData = ((TimedDataSeq*)m_pData)->GetBuffer();
+      pBuffer = seqData->GetBuffer();
+    }
+    return pBuffer;
+  }
+
+};
+
+#endif