![](/media/cache/profiles/94aef38441efa3380a3bed3faf1f9d5d.50x50_q85.jpg)
RTno/PortBase.h@1:7f0fc0d1f777, 2011-08-01 (annotated)
- Committer:
- nucho
- Date:
- Mon Aug 01 14:46:08 2011 +0000
- Revision:
- 1:7f0fc0d1f777
- Parent:
- 0:3c49891bc39d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:3c49891bc39d | 1 | /******************************************* |
nucho | 0:3c49891bc39d | 2 | * PortBase.h |
nucho | 0:3c49891bc39d | 3 | * @author Yuki Suga |
nucho | 0:3c49891bc39d | 4 | * @copyright Yuki Suga (ysuga.net) Nov, 10th, 2010. |
nucho | 0:3c49891bc39d | 5 | * @license LGPLv3 |
nucho | 0:3c49891bc39d | 6 | *****************************************/ |
nucho | 0:3c49891bc39d | 7 | |
nucho | 0:3c49891bc39d | 8 | #ifndef PORT_BASE_HEADER_INCLUDED |
nucho | 0:3c49891bc39d | 9 | #define PORT_BASE_HEADER_INCLUDED |
nucho | 0:3c49891bc39d | 10 | |
nucho | 0:3c49891bc39d | 11 | #include "BasicDataType.h" |
nucho | 0:3c49891bc39d | 12 | |
nucho | 0:3c49891bc39d | 13 | class PortBase { |
nucho | 0:3c49891bc39d | 14 | private: |
nucho | 0:3c49891bc39d | 15 | |
nucho | 0:3c49891bc39d | 16 | |
nucho | 0:3c49891bc39d | 17 | protected: |
nucho | 0:3c49891bc39d | 18 | void* m_pData; |
nucho | 0:3c49891bc39d | 19 | char* m_pName; |
nucho | 0:3c49891bc39d | 20 | char m_TypeCode; |
nucho | 0:3c49891bc39d | 21 | public: |
nucho | 0:3c49891bc39d | 22 | PortBase(char* name); |
nucho | 0:3c49891bc39d | 23 | ~PortBase(); |
nucho | 0:3c49891bc39d | 24 | |
nucho | 0:3c49891bc39d | 25 | public: |
nucho | 0:3c49891bc39d | 26 | char* GetName() {return m_pName;} |
nucho | 0:3c49891bc39d | 27 | char GetTypeCode() {return m_TypeCode;} |
nucho | 0:3c49891bc39d | 28 | |
nucho | 0:3c49891bc39d | 29 | int isSequenceType() { |
nucho | 0:3c49891bc39d | 30 | switch(m_TypeCode) { |
nucho | 1:7f0fc0d1f777 | 31 | /* |
nucho | 0:3c49891bc39d | 32 | case 'b': |
nucho | 0:3c49891bc39d | 33 | case 'B': |
nucho | 0:3c49891bc39d | 34 | case 'o': |
nucho | 0:3c49891bc39d | 35 | case 'O': |
nucho | 0:3c49891bc39d | 36 | case 'c': |
nucho | 0:3c49891bc39d | 37 | case 'C': |
nucho | 1:7f0fc0d1f777 | 38 | */ |
nucho | 1:7f0fc0d1f777 | 39 | case 'b': |
nucho | 1:7f0fc0d1f777 | 40 | case 'o': |
nucho | 1:7f0fc0d1f777 | 41 | case 'c': |
nucho | 1:7f0fc0d1f777 | 42 | case 'l': |
nucho | 1:7f0fc0d1f777 | 43 | case 'f': |
nucho | 1:7f0fc0d1f777 | 44 | case 'd': |
nucho | 0:3c49891bc39d | 45 | return 0; |
nucho | 0:3c49891bc39d | 46 | default: |
nucho | 0:3c49891bc39d | 47 | return 1; |
nucho | 0:3c49891bc39d | 48 | } |
nucho | 0:3c49891bc39d | 49 | } |
nucho | 0:3c49891bc39d | 50 | |
nucho | 0:3c49891bc39d | 51 | int GetLength() { |
nucho | 0:3c49891bc39d | 52 | if(!isSequenceType()) { |
nucho | 1:7f0fc0d1f777 | 53 | return 1; |
nucho | 0:3c49891bc39d | 54 | } else { |
nucho | 0:3c49891bc39d | 55 | return ((TimedDataSeq*)m_pData)->GetBuffer()->length(); |
nucho | 0:3c49891bc39d | 56 | } |
nucho | 0:3c49891bc39d | 57 | } |
nucho | 0:3c49891bc39d | 58 | |
nucho | 0:3c49891bc39d | 59 | void SetLength(int len) { |
nucho | 0:3c49891bc39d | 60 | if(!isSequenceType()) { |
nucho | 0:3c49891bc39d | 61 | return; |
nucho | 0:3c49891bc39d | 62 | } |
nucho | 0:3c49891bc39d | 63 | SequenceDataType *seqData = ((TimedDataSeq*)m_pData)->GetBuffer(); |
nucho | 0:3c49891bc39d | 64 | seqData->length(len); |
nucho | 0:3c49891bc39d | 65 | } |
nucho | 0:3c49891bc39d | 66 | |
nucho | 0:3c49891bc39d | 67 | void* GetBuffer() { |
nucho | 0:3c49891bc39d | 68 | void* pBuffer; |
nucho | 0:3c49891bc39d | 69 | if(!isSequenceType()) { |
nucho | 0:3c49891bc39d | 70 | // if (len != 1) return 0;// -INVALID_PACKET_DATASIZE; |
nucho | 0:3c49891bc39d | 71 | pBuffer = ((TimedData*)m_pData)->GetBuffer(); |
nucho | 0:3c49891bc39d | 72 | } else { |
nucho | 0:3c49891bc39d | 73 | SequenceDataType *seqData = ((TimedDataSeq*)m_pData)->GetBuffer(); |
nucho | 0:3c49891bc39d | 74 | pBuffer = seqData->GetBuffer(); |
nucho | 0:3c49891bc39d | 75 | } |
nucho | 0:3c49891bc39d | 76 | return pBuffer; |
nucho | 0:3c49891bc39d | 77 | } |
nucho | 0:3c49891bc39d | 78 | |
nucho | 0:3c49891bc39d | 79 | }; |
nucho | 0:3c49891bc39d | 80 | |
nucho | 0:3c49891bc39d | 81 | #endif |