flow  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
packet.h
Go to the documentation of this file.
1 #if !defined(FLOW_PACKET_H)
2  #define FLOW_PACKET_H
3 
4 #include <chrono>
5 #include <vector>
6 
10 
11 namespace flow
12 {
13 
19 template<typename T>
20 class packet
21 {
22 public:
24  typedef std::chrono::time_point<std::chrono::high_resolution_clock> time_point_type;
25 
26 private:
27  T d_data;
28 
29  time_point_type d_consumption_time;
30 
31 public:
37  : d_data(std::move(data)), d_consumption_time(consumption_time) {}
38 
39  virtual ~packet() {}
40 
42  virtual size_t size() const { return sizeof(T); }
43 
45  virtual T& data() { return d_data; }
46 
48  virtual const T& data() const { return d_data; }
49 
51  virtual time_point_type& consumption_time() { return d_consumption_time; }
52 };
53 
54 }
55 
56 #endif
57 
58 /*
59  (C) Copyright Thierry Seegers 2010-2012. Distributed under the following license:
60 
61  Boost Software License - Version 1.0 - August 17th, 2003
62 
63  Permission is hereby granted, free of charge, to any person or organization
64  obtaining a copy of the software and accompanying documentation covered by
65  this license (the "Software") to use, reproduce, display, distribute,
66  execute, and transmit the Software, and to prepare derivative works of the
67  Software, and to permit third-parties to whom the Software is furnished to
68  do so, all subject to the following:
69 
70  The copyright notices in the Software and this entire statement, including
71  the above license grant, this restriction and the following disclaimer,
72  must be included in all copies of the Software, in whole or in part, and
73  all derivative works of the Software, unless such copies or derivative
74  works are solely in the form of machine-executable object code generated by
75  a source language processor.
76 
77  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
78  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
79  FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
80  SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
81  FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
82  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
83  DEALINGS IN THE SOFTWARE.
84 */
85