IceProxyFinder.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* @package ArmarX::
17* @author Mirko Waechter ( mirko.waechter at kit dot edu)
18* @date 2014
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
25#include <memory>
26
27#include <QWidget>
28
29#include <Ice/Proxy.h>
30#include <IceUtil/Handle.h>
31
32namespace Ui
33{
34 class IceProxyFinder;
35}
36
37namespace armarx
38{
39 class IceManager;
40 using IceManagerPtr = IceUtil::Handle<IceManager>;
41
42 /**
43 * \class IceProxyFinderBase
44 * \brief The IceProxyFinderBase class provides a convenient way to query online proxies in the
45 * ice network, i.e. registered with IceGrid.
46 *
47 * This is just the non-template base class. For the real implementation refer to
48 * \ref armarx::IceProxyFinder and \ref armarx::IceTopicFinder.
49 *
50 * The selected proxy name can be queried with getSelectedProxyName().
51 */
52 class IceProxyFinderBase : public QWidget
53 {
54 Q_OBJECT
55
56 public:
57 explicit IceProxyFinderBase(QWidget* parent = 0);
58 ~IceProxyFinderBase() override;
59
60 virtual QStringList getProxyNameList(QString searchMask) const = 0;
61
62 void setIceManager(IceManagerPtr icemanager, bool fetchProxies = true);
63 QString getSelectedProxyName() const;
64 void setDefaultSelectedProxy(const QString& proxyName);
65 void setDefaultSelectedProxyAsItem(const QString& proxyName);
66 void setSearchMask(const QString& searchMask);
67 void showSearchMaskField(bool show);
68 void showLabels(bool show);
69 Ui::IceProxyFinder* getUi();
70
71 QWidget* getProxyNameComboBox();
72
73 virtual std::string
74 getTypedProxyName(Ice::ObjectPrx const& current) const
75 {
76 return "";
77 }
78
79 QStringList getProxyNameListBase(QString searchMask) const;
80
81 signals:
82 void updateProxyListComboBoxSignal(const QStringList& proxyList);
84 void validProxySelected(const QString& proxyName);
85
86 public slots:
88 void comboBoxTextChanged(QString currentText);
89 void updateProxyListComboBox(const QStringList& proxyList);
90 void evaluateValidProxySelectedSignal(const QString& proxyName);
91
92 protected:
93 void updateProxyList();
94 void setupUi();
95
96 Ui::IceProxyFinder* ui;
97 struct Impl;
98 std::unique_ptr<Impl> impl;
99 };
100
101 /**
102 * @class IceProxyFinder
103 * Widget to conveniently retrieve a proxy instance name of a specific interface type (the template parameter).
104 * The search mask supports wild cards (only one, \*Unit\* is not possible) and seperators (e.g. Unit|Result).
105 */
106 template <typename ProxyType>
108 {
109 public:
110 IceProxyFinder(QWidget* parent = 0) : IceProxyFinderBase(parent)
111 {
112 }
113
114 std::string
115 getTypedProxyName(Ice::ObjectPrx const& current) const override
116 {
117 ProxyType object = ProxyType::checkedCast(current->ice_timeout(60));
118 if (object)
119 {
120 return current->ice_getIdentity().name;
121 }
122 return "";
123 }
124
125 QStringList
126 getProxyNameList(QString searchMask) const override
127 {
128 return getProxyNameListBase(searchMask);
129 }
130 };
131
132 /**
133 * @class IceTopicFinder
134 * @brief The IceTopicFinder class queries and show all available topic registered with IceStorm.
135 */
137 {
138 public:
139 IceTopicFinder(QWidget* parent = 0);
140
141 QStringList getProxyNameList(QString searchMask) const override;
142 };
143
144} // namespace armarx
The IceManager class provides simplified access to commonly used Ice features.
Definition IceManager.h:106
void updateProxyListComboBoxSignal(const QStringList &proxyList)
IceProxyFinderBase(QWidget *parent=0)
void showSearchMaskField(bool show)
QStringList getProxyNameListBase(QString searchMask) const
virtual QStringList getProxyNameList(QString searchMask) const =0
void setDefaultSelectedProxy(const QString &proxyName)
void setDefaultSelectedProxyAsItem(const QString &proxyName)
void evaluateValidProxySelectedSignal(const QString &proxyName)
void triggerProxyListComboBoxUpdateSignal()
void validProxySelected(const QString &proxyName)
Ui::IceProxyFinder * getUi()
std::unique_ptr< Impl > impl
void setIceManager(IceManagerPtr icemanager, bool fetchProxies=true)
void setSearchMask(const QString &searchMask)
void comboBoxTextChanged(QString currentText)
virtual std::string getTypedProxyName(Ice::ObjectPrx const &current) const
QString getSelectedProxyName() const
void updateProxyListComboBox(const QStringList &proxyList)
Ui::IceProxyFinder * ui
IceProxyFinder(QWidget *parent=0)
std::string getTypedProxyName(Ice::ObjectPrx const &current) const override
QStringList getProxyNameList(QString searchMask) const override
IceTopicFinder(QWidget *parent=0)
QStringList getProxyNameList(QString searchMask) const override
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< IceManager > IceManagerPtr
IceManager smart pointer.
Definition ArmarXFwd.h:39