LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
eventfactory.h
1/*
2 * SPDX-FileCopyrightText: Karlsruhe Institute of Technology (KIT)
3 * SPDX-License-Identifier: LicenseRef-Crabmeat
4 * This file is part of Crabmeat. Redistribution or commercial use is
5 * prohibited without express written permission. See LICENCE.
6 */
7
15
16#ifndef LDNDC_INPUT_EVENT_FACTORIES_H_
17#define LDNDC_INPUT_EVENT_FACTORIES_H_
18
19#include "event/events/eventbase.h"
20
21namespace ldndc{ namespace event{
23struct CBM_API abstract_event_factory_t
24{
25 abstract_event_factory_t() {}
26 virtual ~abstract_event_factory_t() = 0;
27 virtual ldndc::event::event_type_e event_type() const = 0;
28
29 virtual Event * construct(
30 lid_t const &, event_attribute_t **) const = 0;
31 static void destroy( Event * _event)
32 {
33 CBM_DefaultAllocator->destroy( _event);
34 }
35};
36
37template < typename _E, typename _A >
38struct event_factory_t : public abstract_event_factory_t
39{
40 event_factory_t()
42 { }
43
44 ldndc::event::event_type_e event_type()
45 const
46 {
47 return (ldndc::event::event_type_e)_E::event_type_;
48 }
49
50 Event * construct( lid_t const & _id,
51 event_attribute_t ** _attribs)
52 const
53 {
54 _A * attr = CBM_DefaultAllocator->construct< _A >();
55 if ( _attribs)
56 {
57 *_attribs = static_cast< event_attribute_t * >( attr);
58 }
59 return static_cast< Event * >( CBM_DefaultAllocator->construct_args< _E >(
60 static_cast< size_t >( 1), _id, attr));
61 }
62};
63
64extern CBM_API abstract_event_factory_t const * event_factory[EVENT_CNT];
65extern CBM_API event_attribute_t const * event_attribute_defaults[EVENT_CNT];
66}}
67
68#endif /* !LDNDC_INPUT_EVENT_FACTORIES_H_ */
69
Spatially explicit groundwater model.
Definition airchemistryput.h:21
Abstract event factory.
Definition eventfactory.h:24