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 <IceUtil/Handle.h>
26 #include <Ice/Proxy.h>
27 
28 #include <QWidget>
29 
30 #include <memory>
31 
32 
33 namespace Ui
34 {
35  class IceProxyFinder;
36 }
37 
38 namespace armarx
39 {
40  class IceManager;
42 
43  /**
44  * \class IceProxyFinderBase
45  * \brief The IceProxyFinderBase class provides a convenient way to query online proxies in the
46  * ice network, i.e. registered with IceGrid.
47  *
48  * This is just the non-template base class. For the real implementation refer to
49  * \ref armarx::IceProxyFinder and \ref armarx::IceTopicFinder.
50  *
51  * The selected proxy name can be queried with getSelectedProxyName().
52  */
54  public QWidget
55  {
56  Q_OBJECT
57 
58  public:
59  explicit IceProxyFinderBase(QWidget* parent = 0);
60  ~IceProxyFinderBase() override;
61 
62  virtual QStringList getProxyNameList(QString searchMask) const = 0;
63 
64  void setIceManager(IceManagerPtr icemanager, bool fetchProxies = true);
65  QString getSelectedProxyName() const;
66  void setDefaultSelectedProxy(const QString& proxyName);
67  void setDefaultSelectedProxyAsItem(const QString& proxyName);
68  void setSearchMask(const QString& searchMask);
69  void showSearchMaskField(bool show);
70  void showLabels(bool show);
71  Ui::IceProxyFinder* getUi();
72 
73  QWidget* getProxyNameComboBox();
74 
75  virtual std::string getTypedProxyName(Ice::ObjectPrx const& current) const
76  {
77  return "";
78  }
79 
80  QStringList getProxyNameListBase(QString searchMask) const;
81 
82  signals:
83  void updateProxyListComboBoxSignal(const QStringList& proxyList);
85  void validProxySelected(const QString& proxyName);
86 
87  public slots:
89  void comboBoxTextChanged(QString currentText);
90  void updateProxyListComboBox(const QStringList& proxyList);
91  void evaluateValidProxySelectedSignal(const QString& proxyName);
92 
93  protected:
94  void updateProxyList();
95  void setupUi();
96 
97  Ui::IceProxyFinder* ui;
98  struct Impl;
99  std::unique_ptr<Impl> impl;
100  };
101 
102  /**
103  * @class IceProxyFinder
104  * Widget to conveniently retrieve a proxy instance name of a specific interface type (the template parameter).
105  * The search mask supports wild cards (only one, \*Unit\* is not possible) and seperators (e.g. Unit|Result).
106  */
107  template <typename ProxyType>
108  class IceProxyFinder :
109  public IceProxyFinderBase
110  {
111  public:
112  IceProxyFinder(QWidget* parent = 0) :
113  IceProxyFinderBase(parent)
114  {}
115 
116  std::string getTypedProxyName(Ice::ObjectPrx const& current) const override
117  {
118  ProxyType object = ProxyType::checkedCast(current->ice_timeout(60));
119  if (object)
120  {
121  return current->ice_getIdentity().name;
122  }
123  return "";
124  }
125 
126  QStringList 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  public IceProxyFinderBase
138  {
139  public:
140  IceTopicFinder(QWidget* parent = 0);
141 
142  QStringList getProxyNameList(QString searchMask) const override;
143  };
144 
145 }
146 
armarx::IceProxyFinderBase::~IceProxyFinderBase
~IceProxyFinderBase() override
Definition: IceProxyFinder.cpp:55
armarx::IceManagerPtr
IceUtil::Handle< IceManager > IceManagerPtr
IceManager smart pointer.
Definition: ArmarXFwd.h:39
armarx::IceProxyFinderBase::setSearchMask
void setSearchMask(const QString &searchMask)
Definition: IceProxyFinder.cpp:88
armarx::IceProxyFinderBase::getUi
Ui::IceProxyFinder * getUi()
Definition: IceProxyFinder.cpp:105
armarx::IceProxyFinderBase::updateProxyList
void updateProxyList()
Definition: IceProxyFinder.cpp:244
armarx::IceTopicFinder::getProxyNameList
QStringList getProxyNameList(QString searchMask) const override
Definition: IceProxyFinder.cpp:276
armarx::IceProxyFinderBase::updateProxyListComboBoxSignal
void updateProxyListComboBoxSignal(const QStringList &proxyList)
armarx::IceProxyFinderBase::setIceManager
void setIceManager(IceManagerPtr icemanager, bool fetchProxies=true)
Definition: IceProxyFinder.cpp:64
armarx::IceProxyFinderBase
The IceProxyFinderBase class provides a convenient way to query online proxies in the ice network,...
Definition: IceProxyFinder.h:53
armarx::IceProxyFinderBase::Impl
Definition: IceProxyFinder.cpp:40
armarx::IceProxyFinderBase::triggerProxyListComboBoxUpdateSignal
void triggerProxyListComboBoxUpdateSignal()
armarx::IceProxyFinder::getTypedProxyName
std::string getTypedProxyName(Ice::ObjectPrx const &current) const override
Definition: IceProxyFinder.h:116
armarx::IceProxyFinderBase::IceProxyFinderBase
IceProxyFinderBase(QWidget *parent=0)
Definition: IceProxyFinder.cpp:47
armarx::IceProxyFinderBase::comboBoxTextChanged
void comboBoxTextChanged(QString currentText)
Definition: IceProxyFinder.cpp:196
armarx::IceProxyFinderBase::getTypedProxyName
virtual std::string getTypedProxyName(Ice::ObjectPrx const &current) const
Definition: IceProxyFinder.h:75
armarx::IceProxyFinder::getProxyNameList
QStringList getProxyNameList(QString searchMask) const override
Definition: IceProxyFinder.h:126
armarx::IceProxyFinderBase::setupUi
void setupUi()
Definition: IceProxyFinder.cpp:253
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
armarx::ProxyType
ProxyType
Definition: ProxyPropertyDefinition.h:41
armarx::IceTopicFinder::IceTopicFinder
IceTopicFinder(QWidget *parent=0)
Definition: IceProxyFinder.cpp:270
armarx::IceProxyFinderBase::evaluateValidProxySelectedSignal
void evaluateValidProxySelectedSignal(const QString &proxyName)
Definition: IceProxyFinder.cpp:223
armarx::IceProxyFinderBase::setDefaultSelectedProxy
void setDefaultSelectedProxy(const QString &proxyName)
Definition: IceProxyFinder.cpp:78
armarx::IceProxyFinderBase::getProxyNameList
virtual QStringList getProxyNameList(QString searchMask) const =0
armarx::IceProxyFinderBase::getSelectedProxyName
QString getSelectedProxyName() const
Definition: IceProxyFinder.cpp:73
armarx::IceProxyFinderBase::impl
std::unique_ptr< Impl > impl
Definition: IceProxyFinder.h:98
armarx::IceProxyFinderBase::updateProxyListComboBox
void updateProxyListComboBox(const QStringList &proxyList)
Definition: IceProxyFinder.cpp:201
armarx::IceProxyFinderBase::getProxyNameComboBox
QWidget * getProxyNameComboBox()
Definition: IceProxyFinder.cpp:110
IceUtil::Handle< IceManager >
armarx::IceTopicFinder
The IceTopicFinder class queries and show all available topic registered with IceStorm.
Definition: IceProxyFinder.h:136
armarx::IceProxyFinder
Definition: StatechartViewerController.h:51
armarx::IceProxyFinder::IceProxyFinder
IceProxyFinder(QWidget *parent=0)
Definition: IceProxyFinder.h:112
armarx::IceProxyFinderBase::validProxySelected
void validProxySelected(const QString &proxyName)
armarx::IceProxyFinderBase::showSearchMaskField
void showSearchMaskField(bool show)
Definition: IceProxyFinder.cpp:93
armarx::IceProxyFinderBase::triggerProxyListUpdate
void triggerProxyListUpdate()
Definition: IceProxyFinder.cpp:183
armarx::IceProxyFinderBase::ui
Ui::IceProxyFinder * ui
Definition: IceProxyFinder.h:97
armarx::IceProxyFinderBase::showLabels
void showLabels(bool show)
Definition: IceProxyFinder.cpp:99
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::IceProxyFinderBase::getProxyNameListBase
QStringList getProxyNameListBase(QString searchMask) const
Definition: IceProxyFinder.cpp:115
armarx::IceProxyFinderBase::setDefaultSelectedProxyAsItem
void setDefaultSelectedProxyAsItem(const QString &proxyName)
Definition: IceProxyFinder.cpp:83