/usr/include/cwidget/generic/util/slotarg.h is in libcwidget-dev 0.5.16-3.1ubuntu1.
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 | // slotarg.h -*-c++-*-
//
// Copyright 2000 Daniel Burrows
//
// Provides a mechanism for nicely passing in optional slots to a function.
// (you can pass either a reference to one or a pointer (which can be NULL))
//
// Eg: some_slot_function(slotarg, slotarg, slotarg) can be called as:
// some_slot_function(arg(slota), NULL, arg(slotb)) to omit the second slot.
/** \file slotarg.h
*
* \brief Provides a simple mechanism for passing in optional slots
* to a function.
*/
#ifndef SLOTARG_H
#define SLOTARG_H
#include <sigc++/functors/slot.h>
namespace cwidget
{
/** \brief Miscellaneous utility functions that are not directly
* related to the core functionality of cwidget.
*/
namespace util
{
/** \brief Wraps a slot that may not be present.
*
* \tparam T The slot type that is wrapped by this argument.
*
* See also cwidget::util::arg, cwidget::util::slot0arg.
*/
template<typename T>
class slotarg
{
bool hasslot;
T theslot;
public:
/** \brief Create a slotarg from an optional slot.
*
* \param slot The slot to store, or NULL to store no slot.
*/
slotarg(const T *slot)
{
if(slot)
{
theslot=*slot;
hasslot=true;
}
else
hasslot=false;
}
/** \brief Create a slotarg from an existing slot. */
slotarg(const T &slot)
:hasslot(true), theslot(slot)
{
}
/** \brief Convert between compatible slotarg types. */
template <typename S>
operator slotarg<S>() const
{
if(hasslot)
return slotarg<S>(theslot);
else
return slotarg<S>(NULL);
}
/** \brief Return \b true if this argument stores a slot. */
operator bool() const {return hasslot;}
/** \brief Return the encapsulated slot, if any. */
const T & operator*() const {return theslot;}
/** \brief Return the encapsulated slot, if any. */
T & operator*() {return theslot;}
};
/** \brief Convenience typedefs for slot arguments that take no
* parameters and return nothing.
*/
typedef slotarg<sigc::slot0<void> > slot0arg;
/** \brief Convenience routine to construct a slotarg.
*
* The purpose of this routine is to allow C++'s local type
* inference to determine the template parameters to slotarg.
* It is the recommended way to construct slotarg objects when
* passing them as parameters to a function.
*
* \tparam T The slot type that is wrapped by the returned
* slotarg object.
*
* \param slot The slot that is to be wrapped.
*/
template<typename T>
slotarg<T> arg(const T &slot)
{
return slotarg<T>(slot);
}
}
}
#endif
|