/usr/include/caf/announce.hpp is in libcaf-dev 0.13.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 | /******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_ANNOUNCE_HPP
#define CAF_ANNOUNCE_HPP
#include <memory>
#include <typeinfo>
#include "caf/string_algorithms.hpp"
#include "caf/config.hpp"
#include "caf/uniform_type_info.hpp"
#include "caf/detail/abstract_uniform_type_info.hpp"
#include "caf/detail/safe_equal.hpp"
#include "caf/detail/default_uniform_type_info.hpp"
namespace caf {
/**
* @addtogroup TypeSystem
* @{
*/
/**
* A simple example for announce with public accessible members.
* The output of this example program is:
* > foo(1, 2)<br>
* > foo_pair(3, 4)
* @example announce_1.cpp
*/
/**
* An example for announce with getter and setter member functions.
* The output of this example program is:
*
* > foo(1, 2)
* @example announce_2.cpp
*/
/**
* An example for announce with overloaded getter and setter member functions.
* The output of this example program is:
*
* > foo(1, 2)
* @example announce_3.cpp
*/
/**
* An example for announce with non-primitive members.
* The output of this example program is:
*
* > bar(foo(1, 2), 3)
* @example announce_4.cpp
*/
/**
* An advanced example for announce implementing serialization
* for a user-defined tree data type.
* @example announce_5.cpp
*/
/**
* Adds a new mapping to the type system. Returns `utype.get()` on
* success, otherwise a pointer to the previously installed singleton.
* @warning `announce` is **not** thead-safe!
*/
const uniform_type_info* announce(const std::type_info& tinfo,
uniform_type_info_ptr utype);
// deals with member pointer
/**
* Creates meta information for a non-trivial `Member`,
* whereas `xs` are the "sub-members" of `Member`.
* @see {@link announce_4.cpp announce example 4}
*/
template <class Member, class Parent, class... Ts>
std::pair<Member Parent::*, detail::abstract_uniform_type_info<Member>*>
compound_member(Member Parent::*memptr, const Ts&... xs) {
return {memptr, new detail::default_uniform_type_info<Member>("???", xs...)};
}
// deals with getter returning a mutable reference
/**
* Creates meta information for a non-trivial `Member` accessed
* via the getter member function `getter` returning a mutable reference,
* whereas `xs` are the "sub-members" of `Member`.
* @see {@link announce_4.cpp announce example 4}
*/
template <class Member, class Parent, class... Ts>
std::pair<Member& (Parent::*)(), detail::abstract_uniform_type_info<Member>*>
compound_member(Member& (Parent::*getter)(), const Ts&... xs) {
return {getter, new detail::default_uniform_type_info<Member>("???", xs...)};
}
// deals with getter/setter pair
/**
* Creates meta information for a non-trivial `Member` accessed
* via the pair of getter and setter member function pointers `gspair`,
* whereas `xs` are the "sub-members" of `Member`.
* @see {@link announce_4.cpp announce example 4}
*/
template <class Parent, class GRes, class SRes, class SArg, class... Ts>
std::pair<std::pair<GRes (Parent::*)() const, SRes (Parent::*)(SArg)>,
detail::abstract_uniform_type_info<typename std::decay<GRes>::type>*>
compound_member(const std::pair<GRes (Parent::*)() const,
SRes (Parent::*)(SArg)>& gspair,
const Ts&... xs) {
using mtype = typename std::decay<GRes>::type;
return {gspair, new detail::default_uniform_type_info<mtype>("???", xs...)};
}
/**
* Adds a new type mapping for `T` to the type system using `tname`
* as its uniform name and the list of member pointers `xs`.
* @warning `announce` is **not** thead-safe!
*/
template <class T, class... Ts>
inline const uniform_type_info* announce(std::string tname, const Ts&... xs) {
auto ptr = new detail::default_uniform_type_info<T>(std::move(tname), xs...);
return announce(typeid(T), uniform_type_info_ptr{ptr});
}
/**
* @}
*/
} // namespace caf
#endif // CAF_ANNOUNCE_HPP
|