/usr/include/caf/actor_namespace.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 | /******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| 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_ACTOR_NAMESPACE_HPP
#define CAF_ACTOR_NAMESPACE_HPP
#include <map>
#include <utility>
#include <functional>
#include "caf/node_id.hpp"
#include "caf/actor_cast.hpp"
#include "caf/actor_proxy.hpp"
namespace caf {
class serializer;
class deserializer;
/**
* Groups a (distributed) set of actors and allows actors
* in the same namespace to exchange messages.
*/
class actor_namespace {
public:
using key_type = node_id;
/**
* The backend of an actor namespace is responsible for creating proxy actors.
*/
class backend {
public:
virtual ~backend();
/**
* Creates a new proxy instance.
*/
virtual actor_proxy_ptr make_proxy(const key_type&, actor_id) = 0;
};
actor_namespace(backend& mgm);
/**
* Writes an actor address to `sink` and adds the actor
* to the list of known actors for a later deserialization.
*/
void write(serializer* sink, const actor_addr& ptr);
/**
* Reads an actor address from `source,` creating
* addresses for remote actors on the fly if needed.
*/
actor_addr read(deserializer* source);
/**
* A map that stores all proxies for known remote actors.
*/
using proxy_map = std::map<actor_id, actor_proxy::anchor_ptr>;
/**
* Returns the number of proxies for `node`.
*/
size_t count_proxies(const key_type& node);
/**
* Returns all proxies for `node`.
*/
std::vector<actor_proxy_ptr> get_all();
/**
* Returns all proxies for `node`.
*/
std::vector<actor_proxy_ptr> get_all(const key_type& node);
/**
* Returns the proxy instance identified by `node` and `aid`
* or `nullptr` if the actor either unknown or expired.
*/
actor_proxy_ptr get(const key_type& node, actor_id aid);
/**
* Returns the proxy instance identified by `node` and `aid`
* or creates a new (default) proxy instance.
*/
actor_proxy_ptr get_or_put(const key_type& node, actor_id aid);
/**
* Deletes all proxies for `node`.
*/
void erase(const key_type& node);
/**
* Deletes the proxy with id `aid` for `node`.
*/
void erase(const key_type& node, actor_id aid);
/**
* Queries whether there are any proxies left.
*/
bool empty() const;
/**
* Deletes all proxies.
*/
void clear();
private:
backend& m_backend;
std::map<key_type, proxy_map> m_proxies;
};
} // namespace caf
#endif
|