Webdar 1.0.0
Web user interface to libdar
events.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef EVENTS_HPP
25#define EVENTS_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <set>
36#include <map>
37#include <string>
38
39 // webdar headers
40#include "reference.hpp"
41#include "actor.hpp"
42
44
46
50
51class events : public reference
52{
53public:
54 events() = default;
55
57
61 events(const events & ref);
62 events(events && ref) noexcept(false) = default;
63 events & operator = (const events & ref) = default;
64 events & operator = (events && ref) noexcept(false);
65 ~events() = default;
66
68 void record_actor_on_event(actor *ptr, const std::string & name);
69
70protected:
72 virtual void broken_peering_from(reference *obj) override;
73
75 void register_name(const std::string & name);
76
78 void unregister_name(const std::string & name);
79
81
83 void rename_name(const std::string & old_name, const std::string & new_name);
84
86 void act(const std::string & name);
87
88private:
90 std::map< std::string , std::list<actor *> > carte;
91
92};
93
94#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class events
Definition: events.hpp:52
void act(const std::string &name)
trigger a given event
Definition: events.cpp:151
void record_actor_on_event(actor *ptr, const std::string &name)
record an actor for an given event
Definition: events.cpp:62
void register_name(const std::string &name)
add a new event for actors to register against
Definition: events.cpp:107
virtual void broken_peering_from(reference *obj) override
inherited from class reference
Definition: events.cpp:87
void unregister_name(const std::string &name)
remove an event and remove all actors that registed on it
Definition: events.cpp:120
void rename_name(const std::string &old_name, const std::string &new_name)
rename an event and keep all existing peering to this new event
Definition: events.cpp:133
class reference gives a mean to link objects by a peering method
Definition: reference.hpp:47