SEDNL  .
Simple Event Driven Network Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Event.ipp
1 // SEDNL - Copyright (c) 2013 Jeremy S. Cochoy
2 //
3 // This software is provided 'as-is', without any express or implied warranty.
4 // In no event will the authors be held liable for any damages arising from
5 // the use of this software.
6 //
7 // Permission is granted to anyone to use this software for any purpose,
8 // including commercial applications, and to alter it and redistribute it
9 // freely, subject to the following restrictions:
10 //
11 // 1. The origin of this software must not be misrepresented; you must not
12 // claim that you wrote the original software. If you use this software
13 // in a product, an acknowledgment in the product documentation would
14 // be appreciated but is not required.
15 //
16 // 2. Altered source versions must be plainly marked as such, and must not
17 // be misrepresented as being the original software.
18 //
19 // 3. This notice may not be removed or altered from any source
20 // distribution.
21 
22 #ifndef EVENT_IPP_
23 #define EVENT_IPP_
24 
25 #include "SEDNL/Packet.hpp"
26 
27 namespace SedNL
28 {
29 
30 inline
31 void Event::swap(Event& event) noexcept
32 {
33  using std::swap;
34 
35  //basic_string's swap doesn't throw.
36  swap(event.m_name, m_name);
37  swap(event.m_packet, m_packet);
38 }
39 
40 inline
41 void swap(Event& a, Event& b) noexcept
42 {
43  a.swap(b);
44 }
45 
46 Event::Event(std::string name)
47  :m_name(name)
48 {}
49 
50 Event::Event(std::string name, const Packet& packet)
51  :m_name(name), m_packet(packet)
52 {}
53 
54 const std::string& Event::get_name() const noexcept
55 {
56  return m_name;
57 }
58 
59 const Packet& Event::get_packet() const noexcept
60 {
61  return m_packet;
62 }
63 
64 template<typename... Args>
65 inline
66 Event make_event(const std::string& event_name, Args... args)
67 {
68  return Event(event_name, make_packet(args...));
69 }
70 
71 } //namespace SedNL
72 
73 #endif /* !EVENT_IPP_ */