LayoutWorkerCreator.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include "Layout.h"
27 #include "LayoutController.h" //for MediatorPtr
28 #include "LayoutWorker.h"
29 
30 #include <QObject>
31 
32 #include <map>
33 #include <memory>
34 
35 namespace armarx
36 {
37 
38  using LayoutWorkerPtr = std::unique_ptr<LayoutWorker>;
39  using WorkerMap = std::map<size_t, LayoutWorkerPtr>;
40 
41  class LayoutWorkerCreator;
42  using LayoutWorkerCreatorPtr = std::unique_ptr<LayoutWorkerCreator>;
43 
44  class LayoutWorkerCreator : public QObject
45  {
46  Q_OBJECT
47 
48  public:
50 
51  signals:
52  /**
53  * @brief connectedWorkerAndMediator Notifies that the worker's signals and slots are now
54  * connected to its mediator.
55  * @param id The id of the worker and mediator.
56  */
57  void connectedWorkerAndMediator(size_t id);
58 
59  public slots:
60  /**
61  * @brief createWorker Create worker with given id and connect it to mediator via signals and slots.
62  * @param mediator Manages the communication between the new worker and the associated state.
63  * @param id The mediator's and worker's id.
64  */
65  void createWorker(MediatorPtr mediator, size_t id, QString name);
66 
67  /**
68  * @brief deleteWorker Calls the destructor of the worker with the given id.
69  * @param id ID of the worker that is to be deleted.
70  */
71  void deleteWorker(size_t id);
72 
73  /**
74  * @brief deleteWorkers Calls the destructor of every worker.
75  */
76  void deleteWorkers();
77 
78  private:
79  /**
80  * @brief workers Maps the ids to the workers.
81  */
82  WorkerMap workers;
83 
84  /**
85  * @brief graphvizContext Needed for layouting the graphs.
86  */
87  GvcPtr graphvizContext;
88  };
89 } //namespace armarx
90 
armarx::GvcPtr
GVC_t * GvcPtr
Definition: Layout.h:39
armarx::LayoutWorkerPtr
std::unique_ptr< LayoutWorker > LayoutWorkerPtr
Definition: LayoutWorkerCreator.h:38
armarx::LayoutWorkerCreator::connectedWorkerAndMediator
void connectedWorkerAndMediator(size_t id)
connectedWorkerAndMediator Notifies that the worker's signals and slots are now connected to its medi...
Layout.h
armarx::LayoutWorkerCreator
Definition: LayoutWorkerCreator.h:44
LayoutController.h
armarx::WorkerMap
std::map< size_t, LayoutWorkerPtr > WorkerMap
Definition: LayoutWorkerCreator.h:39
armarx::LayoutWorkerCreator::createWorker
void createWorker(MediatorPtr mediator, size_t id, QString name)
createWorker Create worker with given id and connect it to mediator via signals and slots.
Definition: LayoutWorkerCreator.cpp:43
armarx::LayoutWorkerCreatorPtr
std::unique_ptr< LayoutWorkerCreator > LayoutWorkerCreatorPtr
Definition: LayoutWorkerCreator.h:42
armarx::LayoutWorkerCreator::deleteWorkers
void deleteWorkers()
deleteWorkers Calls the destructor of every worker.
Definition: LayoutWorkerCreator.cpp:116
armarx::MediatorPtr
std::shared_ptr< StateModelLayoutMediator > MediatorPtr
Definition: LayoutController.h:41
armarx::LayoutWorkerCreator::deleteWorker
void deleteWorker(size_t id)
deleteWorker Calls the destructor of the worker with the given id.
Definition: LayoutWorkerCreator.cpp:111
armarx::LayoutWorkerCreator::LayoutWorkerCreator
LayoutWorkerCreator()
Definition: LayoutWorkerCreator.cpp:32
LayoutWorker.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28