LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
eventbase.h
1
8
9#ifndef LDNDC_INPUT_EVENTBASE_H_
10#define LDNDC_INPUT_EVENTBASE_H_
11
12#include "crabmeat-common.h"
13
14#include "string/cbm_string.h"
15#include "utils/cbm_utils.h"
16#include "memory/cbm_mem.h"
17
18namespace ldndc{ namespace event{
19#include "event.h.inc"
20
21struct event_attribute_t
22{
23 virtual ~event_attribute_t() = 0;
24};
25
26#define LMANA_EVENT_TYPE(__ev_class__,__ev_attr_t__,__ev_type__) \
27 public: \
28 typedef __ev_attr_t__ attributes_type; \
29 enum \
30 { \
31 event_type_ = __ev_type__ \
32 }; \
33 event_type_e event_type() \
34 const \
35 { \
36 return static_cast< event_type_e >( event_type_); \
37 } \
38 char const * name() const \
39 { return EVENT_NAMES[event_type_]; } \
40 std::string to_string() const; \
41 public: \
42 __ev_class__( \
43 lid_t const & _id, __ev_attr_t__ const * _attribs) \
44 : Event( _id), attribs_( _attribs) { } \
45 ~__ev_class__() \
46 { \
47 if ( attribs_) \
48 { \
49 CBM_DefaultAllocator->destroy( attribs_); \
50 } \
51 } \
52 private: \
53 __ev_attr_t__ const * attribs_; \
54 /* hide copy constructor and assignment operator */ \
55 __ev_class__( __ev_class__ const &); \
56 __ev_class__ & operator=( __ev_class__ const &);
57
58
59#define EVENT_COMMON_DECL(__ev_name__) \
60 LMANA_EVENT_TYPE(__event_class_name(__ev_name__),__event_attrib_class_name(__ev_name__),TOKENPASTE(__EVENT_ENUM_,__ev_name__))
61
62#define LEVENT_WRITE_ATTRIB_TXT_(__ss__,__key__,__value_prefix__,__value__) \
63 /*if ( cbm::is_valid( __value__))*/ \
64 { \
65 __ss__ << ((cbm::is_empty( (__ss__).str())) ? "" : "; ") \
66 << __key__ \
67 << " = " \
68 << "\"" << __value_prefix__ << __value__ << "\""; \
69 } \
70 CRABMEAT_FIX_UNUSED(__ss__)/*;*/
71
72#define LEVENT_WRITE_ATTRIB_TXT(__ss__,__key__,__value__) \
73 LEVENT_WRITE_ATTRIB_TXT_(__ss__,__key__,"",this->attribs_->__value__)
74#define LEVENT_WRITE_ATTRIB_PREFIX_TXT(__ss__,__key__,__value_prefix__,__value__) \
75 LEVENT_WRITE_ATTRIB_TXT_(__ss__,__key__,__value_prefix__,this->attribs_->__value__)
76
77/* ldndc event base class */
78class CBM_API Event
79{
80 public:
81 enum lmana_flag_e
82 {
83 EVFLAG_NONE = 0u,
84 EVFLAG_ = 1u << 0
85 };
86 public:
87 virtual event_type_e event_type() const = 0;
88 virtual char const * name() const = 0;
89
90 public:
91 Event( lid_t const &);
92 virtual ~Event() = 0;
93
94 lid_t const & id()
95 const { return m_id; }
96
97 virtual std::string to_string() const = 0;
98
99 private:
100 lid_t m_id;
101
102 Event( Event const &);
103 Event & operator=( Event const &);
104};
105
106#define __event_class_name(__event_name__) TOKENPASTE(Event__,__event_name__)
107#define __event_attrib_class_name(__event_name__) TOKENPASTE3(event_,__event_name__,_attribute_t)
108
109
110#define EVENT_FACTORY_DECL(__event_name__) \
111 /* factory */ \
112 extern event_factory_t< __event_class_name(__event_name__), __event_attrib_class_name(__event_name__) > const TOKENPASTE(event_factory_,__event_name__);\
113 /* default attributes */ \
114 extern __event_attrib_class_name(__event_name__) const TOKENPASTE(event_attribute_default_,__event_name__);
115
116#define EVENT_FACTORY_DEFN(__event_name__) \
117 /* factory */ \
118 event_factory_t< __event_class_name(__event_name__), __event_attrib_class_name(__event_name__) > const TOKENPASTE(event_factory_,__event_name__);\
119 /* default attributes */ \
120 __event_attrib_class_name(__event_name__) const TOKENPASTE(event_attribute_default_,__event_name__);
121
122#include "eventbase.h.inc"
123
124}}
125
126#endif /* !LDNDC_INPUT_EVENTBASE_H_ */
127
Spatially explicit groundwater model.
Definition airchemistryput.h:15