Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rtos
Sequence.h
00001 #ifndef SEQUENCE_HEADER_INCLUDED 00002 #define SEQUENCE_HEADER_INCLUDED 00003 00004 #include <stdint.h> 00005 #include <stdlib.h> 00006 00007 class SequenceBase { 00008 protected: 00009 uint8_t m_length; 00010 00011 public: 00012 virtual uint8_t length() { 00013 return m_length; 00014 } 00015 00016 virtual void length(uint8_t len) {}; 00017 00018 virtual void* getData() = 0; 00019 }; 00020 00021 00022 template<typename T> 00023 class Sequence : public SequenceBase { 00024 T *m_ptr; 00025 00026 public: 00027 Sequence() {m_ptr = 0;} 00028 virtual void length(uint8_t len) { 00029 m_length = len; 00030 free((void*)m_ptr); 00031 m_ptr = (T*)malloc(len * sizeof(T)); 00032 } 00033 00034 virtual uint8_t length() { 00035 return SequenceBase::length(); 00036 } 00037 T& operator[](uint8_t index) { 00038 return m_ptr[index]; 00039 } 00040 00041 virtual void* getData() { return m_ptr; } 00042 }; 00043 00044 00045 #endif //#ifndef SEQUENCE_HEADER_INCLUDED
Generated on Fri Jul 22 2022 21:22:49 by
1.7.2