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 
26 #include "Client.h"
27 
28 namespace armarx::viz
29 {
30  /**
31  * @brief `viz::Client` that will delete (clear) committed layers when destroyed.
32  *
33  * Note that, as a consequence, a network call will be performed in the destructor.
34  *
35  * This might be useful if you have a class `MyTask` perform visualizing while performing some task,
36  * but whose visualization should be removed when the task finished.
37  * In this case, `MyTask` can have a `viz::ScopedClient` (which can be created from a regular `viz::Client`).
38  * When destructing the instance of `MyTask`, all visualization done by `MyTask` will be cleared
39  * (as `viz::ScopedClient` will go out of scope as well).
40  *
41  */
42  class ScopedClient: virtual public Client
43  {
44  public:
45  using Client::Client;
46  ScopedClient(const Client& client);
47 
48  Layer layer(std::string const& name) const;
49 
50  void clear();
51 
52  virtual ~ScopedClient();
53 
54  private:
55  mutable std::set<std::string> layers;
56  };
57 } // namespace armarx::viz
Client.h
armarx::viz::ScopedClient::clear
void clear()
Definition: ScopedClient.cpp:48
armarx::viz::ScopedClient
viz::Client that will delete (clear) committed layers when destroyed.
Definition: ScopedClient.h:42
armarx::viz::Client::Client
Client()=default
armarx::viz::ScopedClient::~ScopedClient
virtual ~ScopedClient()
Definition: ScopedClient.cpp:41
armarx::viz::ScopedClient::ScopedClient
ScopedClient(const Client &client)
Definition: ScopedClient.cpp:29
armarx::viz::ScopedClient::layer
Layer layer(std::string const &name) const
Definition: ScopedClient.cpp:34
armarx::viz::Client
Definition: Client.h:109
armarx::viz::Layer
Definition: Layer.h:12
armarx::viz
This file is part of ArmarX.
Definition: ArVizStorage.cpp:370