yasmine
event_adjuster.hpp
Go to the documentation of this file.
1 // //
3 // This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). //
4 // Copyright (C) 2016-2017 Seadex GmbH //
5 // //
6 // Licensing information is available in the folder "license" which is part of this distribution. //
7 // The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. //
8 // //
10 
11 #ifndef EVENT_ADJUSTER_49D9A1B8_827D_4FE4_8789_07E6AA5A77E5
12 #define EVENT_ADJUSTER_49D9A1B8_827D_4FE4_8789_07E6AA5A77E5
13 
14 
15 #ifdef NDEBUG
16 #else
17 #include "essentials/base.hpp"
18 #include "hermes/log.hpp"
19 #endif
20 
21 
22 namespace sxy
23 {
24 
25 
26 template<typename _event_type>
27 const _event_type& adjust_event_type( const event& _event )
28 {
29 #ifdef NDEBUG
30  return( static_cast< const _event_type& >( _event ) );
31 #else
32  const _event_type* const specialized_event = dynamic_cast< const _event_type* const >( &_event );
33  const std::string message = "Event " + _event.get_name() + " is not of given type.";
34  if( !specialized_event )
35  {
36  SX_LOG( hermes::log_level::LL_ASSERT, message );
37  SX_ASSERT( false, "Invalid event type!" );
38  }
39  return( *specialized_event );
40 #endif
41 }
42 
43 
44 }
45 
46 
47 #endif
Interface of an event. An event has an ID, a name and a priority (for processing by the async state m...
Definition: event.hpp:28
const _event_type & adjust_event_type(const event &_event)
Definition: event_adjuster.hpp:27
Definition: adapter_cpp11.hpp:21
Class that inherits event_impl and provides a fixed event ID and priority as well as create methods f...
Definition: specialized_event.hpp:26
virtual std::string get_name() const =0
Getter of event&#39;s name.