This file is indexed.

/usr/include/sigx-2.0/sigx/connection_handler.h is in libsigx-2.0-dev 2.0.2-3.

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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#ifndef _SIGX_CONNECTION_HANDLER_HPP_
#define _SIGX_CONNECTION_HANDLER_HPP_

/*
 * Copyright 2005 Klaus Triendl
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free 
 * Software Foundation, 51 Franklin Street, Fifth Floor, 
 * Boston, MA 02110-1301, USA.
 */

#include <tr1/memory>	// std::tr1::shared_ptr
#include <map>
#include <sigc++/signal.h>
#include <glib.h>	// message macros
#include <glibmm/thread.h> // Glib::StaticPrivate
#include <glibmm/main.h>
#include <sigxconfig.h>
#include <sigx/fwddecl.h>
#include <sigx/noninstantiatable.h>
#include <sigx/signal_traits.h>
#include <sigx/signal_source_base.h>
#include <sigx/connection_wrapper.h>


namespace sigx
{

/**	@short Stores connections of any client thread to a server thread's signal and destroys them along with the 
 *	thread's lifetime.
 *	@note A static class only.
 */
class SIGX_API connection_handler: noninstantiatable
{
public:
	/**	@short Destroys a sigc::connection in the context of the server thread.
	 *	
	 *	Called when the last connection sharing a sigc::connection
	 *	goes out of scope and tunnels a message.
	 *	
	 *	@note message handler for sigx::connection_wrapper::~connection_wrapper().
	 */
	static void destroy(const sigc_connection_ptr* handle);

	/**	@short Stores a sigc::connection in the context of the server thread.
	 *	@param _A_refconn Shared connection pointer
	 *	@param c The connection
	 */
	static void store(
		const std::tr1::shared_ptr<sigc_connection_ptr>& _A_refconn, 
		const sigc::connection& c);


protected:
	/**	A wrapper for a container of sigc::connectionS.
	 *	This wrapper is necessary because the destructor ensures 
	 *	disconnecting the connections when the owner thread 
	 *	finishes.
	 *	Disconnecting the connections explicitly is only necessary if the signals
	 *	don't live in the server thread's local storage but in the thread managed
	 *	dispatchable which is a wrapper object surviving the thread itself.
	 */
	struct connections_container_wrapper
	{
		/**	@short a map of connections living in the context of the
		 *	owner thread.
		 *	@note We must use a shared_ptr because auto_ptr doesn't meet the copy-constructible requirement
		 */
		typedef std::map<const sigc_connection_ptr* const /*handle*/, std::tr1::shared_ptr<sigc_connection_ptr> > container_type;

		container_type m_connections;
		~connections_container_wrapper();
	};

	static Glib::StaticPrivate<connections_container_wrapper> thread_specific_connections;
};


template<typename T_signal, internal::signal_group I_oneof>
class typed_connection_handler;

template<typename T_signal>
class typed_connection_handler<T_signal, internal::SIGGROUP_SIGC>: noninstantiatable
{
public:
	typedef T_signal signal_type;
	typedef typename signal_type::slot_type slot_type;

	/**	@param _A_refconnptr A prepared connection pointer
	 *	@param psigsource Shared signal source
	 *	@note Executed by the server thread only.
	 */
	static void connect(const std::tr1::shared_ptr<sigc_connection_ptr>& _A_refconnptr, const std::tr1::shared_ptr<signal_source_base>& psigsource, const slot_type& _A_slot)
	{
		// must have a valid signal source
		g_return_if_fail(psigsource.get());

		// get the signal from the signal source ...
		typedef signal_type (*fp_sig_getter)(signal_source_ptr);
		const fp_sig_getter getsig = 
			reinterpret_cast<fp_sig_getter>(psigsource->getter());

		// ... and connect the slot
		const sigc::connection& c = getsig(psigsource.get()).connect(_A_slot);
		// ... store the resulting connection in the container of the thread's connections
		connection_handler::store(_A_refconnptr, c);
	}
};

/**	@short Specialization for a Glib::SignalProxyN
 */
template<typename T_signal>
class typed_connection_handler<T_signal, internal::SIGGROUP_GLIB_PROXY>: noninstantiatable
{
public:
	typedef T_signal signal_type;
	typedef typename signal_type::SlotType slot_type;
	typedef typename signal_type::VoidSlotType void_slot_type;

	/**	@note Executed by the server thread only.
	 */
	static void connect(const std::tr1::shared_ptr<sigc_connection_ptr>& _A_refconnptr, const std::tr1::shared_ptr<signal_source_base>& psigsource, const slot_type& _A_slot, bool after)
	{
		// must have a valid signal source
		g_return_if_fail(psigsource.get());

		// get the signal from the signal source ...
		typedef signal_type (*fp_sig_getter)(signal_source_ptr);
		const fp_sig_getter getsig = 
			reinterpret_cast<fp_sig_getter>(psigsource->getter());

		// ... and connect the slot
		const sigc::connection& c = getsig(psigsource.get()).connect(_A_slot, after);
		// ... store the resulting connection in the container of the thread's connections
		connection_handler::store(_A_refconnptr, c);
	}

	/**	@note Executed by the server thread only.
	 */
	static void connect_notify(const std::tr1::shared_ptr<sigc_connection_ptr>& _A_refconnptr, const std::tr1::shared_ptr<signal_source_base>& psigsource, const void_slot_type& _A_slot, bool after)
	{
		// must have a valid signal source
		g_return_if_fail(psigsource.get());

		// get the signal from the signal source ...
		typedef signal_type (*fp_sig_getter)(signal_source_ptr);
		const fp_sig_getter getsig = 
			reinterpret_cast<fp_sig_getter>(psigsource->getter());

		// ... and connect the slot
		const sigc::connection& c = getsig(psigsource.get()).connect_notify(_A_slot, after);
		// ... store the resulting connection in the container of the thread's connections
		connection_handler::store(_A_refconnptr, c);
	}
};

/**	@short Specialization for a Glib::SignalIdle
 */
template<>
class SIGX_API typed_connection_handler<Glib::SignalIdle, internal::SIGGROUP_IRRELEVANT>: noninstantiatable
{
public:
	typedef Glib::SignalIdle signal_type;
	typedef sigc::slot<bool> slot_type;

	/**	@note Executed by the server thread only.
	 */
	static void connect(const std::tr1::shared_ptr<sigc_connection_ptr>& _A_refconnptr, const std::tr1::shared_ptr<signal_source_base>& psigsource, const slot_type& _A_slot, int priority);
};


/**	@short Specialization for a Glib::SignalTimeout
 */
template<>
class SIGX_API typed_connection_handler<Glib::SignalTimeout, internal::SIGGROUP_IRRELEVANT>: noninstantiatable
{
public:
	typedef Glib::SignalTimeout signal_type;
	typedef sigc::slot<bool> slot_type;

	/**	@note Executed by the server thread only.
	 */
	static void connect(const std::tr1::shared_ptr<sigc_connection_ptr>& _A_refconnptr, const std::tr1::shared_ptr<signal_source_base>& psigsource, const slot_type& _A_slot, unsigned int interval, int priority);
};


/**	@short Specialization for a Glib::SignalIO
 */
template<>
class SIGX_API typed_connection_handler<Glib::SignalIO, internal::SIGGROUP_IRRELEVANT>: noninstantiatable
{
public:
	typedef Glib::SignalIO signal_type;
	typedef sigc::slot<bool, Glib::IOCondition> slot_type;

	/**	@note Executed by the server thread only.
	 */
	static void connect(const std::tr1::shared_ptr<sigc_connection_ptr>& _A_refconnptr, const std::tr1::shared_ptr<signal_source_base>& psigsource, const slot_type& _A_slot, int fd, Glib::IOCondition condition, int priority);
};


/**	@short Specialization for a Glib::SignalChildWatch
 */
template<>
class SIGX_API typed_connection_handler<Glib::SignalChildWatch, internal::SIGGROUP_IRRELEVANT>: noninstantiatable
{
public:
	typedef Glib::SignalChildWatch signal_type;
	typedef sigc::slot<void, GPid, int> slot_type;

	/**	@note Executed by the server thread only.
	 */
	static void connect(const std::tr1::shared_ptr<sigc_connection_ptr>& _A_refconnptr, const std::tr1::shared_ptr<signal_source_base>& psigsource, const slot_type& _A_slot, GPid pid, int priority);
};


} // namespace sigx


#endif // end file guard