Fragmenter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __FRAGMENTER_H_248EC79C4F9347__
00043 #define __FRAGMENTER_H_248EC79C4F9347__
00044
00045
00046 #include "debug.h"
00047
00048 #include "assert/staticerror.h"
00049
00050 #include "mw/afp/Config.h"
00051 #include "mw/afp/FragPolicySelector.h"
00052
00053
00054 namespace famouso {
00055 namespace mw {
00056 namespace afp {
00057
00058
00070 template < class AFPFC, unsigned int mtu_compile_time = 0 >
00071 class Fragmenter {
00072
00073 typedef FragPolicySelector<AFPFC> FCP;
00074
00075 typedef class FCP::FragImplPolicy FragmenterImpl;
00076
00077 public:
00078
00079 typedef typename FCP::SizeProp::elen_t elen_t;
00080 typedef typename FCP::SizeProp::flen_t flen_t;
00081 typedef typename FCP::SizeProp::fcount_t fcount_t;
00082
00083 protected:
00084
00086 FragmenterImpl frag;
00087
00088 public:
00089
00095 Fragmenter(const uint8_t * event_data, elen_t event_length) {
00096
00097 FAMOUSO_STATIC_ASSERT_ERROR(mtu_compile_time > FragmenterImpl::min_header_length,
00098 MTU_is_too_small_for_this_configuration, ());
00099 frag.init(event_data, event_length, mtu_compile_time);
00100 }
00101
00108 Fragmenter(const uint8_t * event_data, elen_t event_length, flen_t mtu) {
00109 frag.init(event_data, event_length, mtu);
00110 }
00111
00117 bool error() {
00118 return frag.error();
00119 }
00120
00126 flen_t get_fragment(uint8_t * fragment_data) {
00127 return frag.get_fragment(fragment_data);
00128 }
00129 };
00130
00131
00135 template < unsigned int mtu_compile_time >
00136 class Fragmenter<Disable, mtu_compile_time> {
00137
00138 public:
00139
00140 typedef uint16_t elen_t;
00141 typedef uint16_t flen_t;
00142 typedef uint16_t fcount_t;
00143
00149 Fragmenter(const uint8_t * event_data, elen_t event_length) {
00150 ::logging::log::emit< ::logging::Warning>()
00151 << PROGMEMSTRING("Event is to big to deliver at once and fragmentation is disabled.")
00152 << ::logging::log::endl;
00153 }
00154
00161 Fragmenter(const uint8_t * event_data, elen_t event_length, flen_t mtu) {
00162 ::logging::log::emit< ::logging::Warning>()
00163 << PROGMEMSTRING("Event is to big to deliver at once and fragmentation is disabled.")
00164 << ::logging::log::endl;
00165 }
00166
00172 bool error() {
00173 return true;
00174 }
00175
00181 flen_t get_fragment(uint8_t * fragment_data) {
00182 return 0;
00183 }
00184 };
00185
00186 }
00187 }
00188 }
00189
00190
00191
00192 #endif // __FRAGMENTER_H_248EC79C4F9347__
00193