/usr/include/Gyoto/GyotoHooks.h is in libgyoto4-dev 1.0.2-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | /**
* \file GyotoHooks.h
* \brief Tellers tell Listeners when they mutate
*
* A Listener can hook() to a Teller. The Teller will tell it when
* it mutates using Listener::tell(), usually through the highter
* lever Teller::tellListeners(). The Listener can later
* unhook(). The Listener must therefore implement Listener::tell()
* to react when it is told.
*/
/*
Copyright 2012-2013 Thibaut Paumard
This file is part of Gyoto.
Gyoto is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gyoto is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GyotoHooks_h
#define __GyotoHooks_h
/**
* \namespace Gyoto::Hook
* \brief Listeners attach to Tellers
*
* A Listener can hook() to a Teller. The Teller will tell it when
* it mutates using Listener::tell(), usually through the highter
* lever Teller::tellListeners(). The Listener can later
* unhook(). The Listener must therefore implement Listener::tell()
* to react when it is told.
*/
namespace Gyoto {
namespace Hook {
/**
* \class Teller
* \brief Listen to me and I'll warn you when I change
*
* Listen to me by calling my hook() method.
*/
class Teller;
/**
* \class Listener
* \brief I might listen to a Teller
*
* Whisper to my ear by using my tell() method.
*/
class Listener;
}
}
class Gyoto::Hook::Listener {
friend class Gyoto::Hook::Teller;
public:
Listener(); ///< Constructor
virtual ~Listener(); ///< Destructor
protected:
/**
* \brief This is how a Teller tells
*
* A teller will basically call listener->tell(this).
*
* \param msg Teller* the Teller who is telling... Useful if the
* Listener listens to several Tellers.
*/
virtual void tell(Gyoto::Hook::Teller *msg);
};
class Gyoto::Hook::Teller {
friend class Gyoto::Hook::Listener;
private:
/**
* \class ListenerItem
* \brief Private (undocumented) class to hold listeners_
*/
class ListenerItem;
/**
* \brief Linked list of Listener items
*/
ListenerItem *listeners_;
public:
Teller(); ///< Default constructor
Teller(const Teller &); ///< Copy constructor
virtual ~Teller(); ///< Destructor
/**
* \brief Start listening
*
* Use from a Hook::Listener object method:
* \code
* teller->hook(this)
* \endcode
* where "this" is a Listener and "teller" is a Teller.
*
* Use unhook() later to stop listening to a given Teller.
*
* \param listener pointer to the new listener
*/
virtual void hook (Listener * listener);
/**
* \brief Stop listening
*
* Use from a Hook::Listener object method:
* \code
* teller->unhook(this)
* \endcode
* where "this" is a Listener, "teller" is a Teller, and "this" has
* called teller->hook(this) previously.
*
* \param listener pointer to the listener
*/
virtual void unhook (Listener * listener);
protected:
/**
* \brief Call tell() on each hooked Listener
*
* Whenever a Teller mutates, it should warn any Listener hooked to
* it using tellListeners().
*/
virtual void tellListeners();
};
#endif
|