ScopedClient.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2021
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <set>
25#include <string>
26
27#include "Client.h"
28#include "Layer.h"
29
30namespace armarx::viz
31{
32 /**
33 * @brief `viz::Client` that will delete (clear) committed layers when destroyed.
34 *
35 * Note that, as a consequence, a network call will be performed in the destructor.
36 *
37 * This might be useful if you have a class `MyTask` perform visualizing while performing some task,
38 * but whose visualization should be removed when the task finished.
39 * In this case, `MyTask` can have a `viz::ScopedClient` (which can be created from a regular `viz::Client`).
40 * When destructing the instance of `MyTask`, all visualization done by `MyTask` will be cleared
41 * (as `viz::ScopedClient` will go out of scope as well).
42 *
43 */
44 class ScopedClient : virtual public Client
45 {
46 public:
47 using Client::Client;
48 ScopedClient(const Client& client);
49
50 Layer layer(std::string const& name) const override;
51
52 void clear();
53
54 virtual ~ScopedClient();
55
56 private:
57 mutable std::set<std::string> layers;
58 };
59} // namespace armarx::viz
Layer layer(std::string const &name) const override
ScopedClient(const Client &client)
This file is part of ArmarX.