00001
00002
00003
00004
00005 #ifndef BALL_VIEW_KERNEL_SERVERWIDGET_H
00006 #define BALL_VIEW_KERNEL_SERVERWIDGET_H
00007
00008 #ifndef BALL_COMMON_H
00009 # include <BALL/common.h>
00010 #endif
00011
00012 #ifndef BALL_DATATYPE_HASHMAP_H
00013 # include <BALL/DATATYPE/hashMap.h>
00014 #endif
00015
00016 #ifndef BALL_VIEW_KERNEL_MODULARWIDGET_H
00017 # include <BALL/VIEW/KERNEL/modularWidget.h>
00018 #endif
00019
00020 #ifndef BALL_CONCEPT_OBJECTCREATOR_H
00021 # include <BALL/CONCEPT/objectCreator.h>
00022 #endif
00023
00024 #ifndef BALL_SYSTEM_NETWORKING_H
00025 # include <BALL/SYSTEM/networking.h>
00026 #endif
00027
00028 #ifndef BALL_VIEW_KERNEL_THREADS_H
00029 # include <BALL/VIEW/KERNEL/threads.h>
00030 #endif
00031
00032 #include <QtCore/qtimer.h>
00033 #include <QtGui/QLabel>
00034
00035 class QLabel;
00036
00037 namespace BALL
00038 {
00039 class Composite;
00040
00041 namespace VIEW
00042 {
00043 class ServerPreferences;
00044 class Preferences;
00045
00059 class BALL_VIEW_EXPORT ServerWidget
00060 : public QObject,
00061 public ModularWidget
00062 {
00063 Q_OBJECT
00064
00065 public:
00066
00067 BALL_EMBEDDABLE(ServerWidget,ModularWidget)
00068
00069
00072
00073
00078 class BALL_VIEW_EXPORT NotCompositeObject: public Exception::GeneralException
00079 {
00080 public:
00081
00082 NotCompositeObject(const char* file, int line);
00083 };
00084
00086
00090 class BALLViewServer
00091 : public virtual BALLThread,
00092 public virtual TCPServerThread
00093 {
00094 public:
00095 BALLViewServer(ServerWidget* parent, Size port, bool restart = true);
00096
00099 void sendObject()
00100 throw(NotCompositeObject);
00101
00102 virtual void run();
00103
00115 virtual void handleConnection();
00116
00118 void setLocked(bool is_locked);
00119
00120 protected:
00121 ServerWidget* parent_widget_;
00122 Composite* received_composite_;
00123
00124 typedef HashMap<unsigned long, Composite *> CompositeHashMap;
00125 CompositeHashMap composite_hashmap_;
00126
00127 Size port_;
00128 bool is_locked_;
00129 };
00130
00134
00142 ServerWidget(QWidget* parent = 0, const char* name = 0);
00143
00144
00145 ServerWidget(const ServerWidget& server);
00146
00148
00151
00154 virtual ~ServerWidget();
00155
00160 virtual void clear();
00162
00166
00169 virtual void activate() {};
00170
00173 virtual void deactivate() {};
00174
00178 void setPort(const int port);
00179
00184 int getPort() const;
00185
00191 void registerObjectCreator(const ObjectCreator& s);
00192
00198 void unregisterObjectCreator();
00199
00202 ObjectCreator& getObjectCreator();
00203
00206 const ObjectCreator& getObjectCreator() const;
00207
00215 virtual void initializeWidget(MainControl& main_control);
00216
00225 virtual void finalizeWidget(MainControl& main_control);
00226
00239 virtual void initializePreferencesTab(Preferences &preferences);
00240
00253 virtual void finalizePreferencesTab(Preferences &preferences);
00254
00266 virtual void applyPreferences();
00267
00269
00272
00278 virtual bool isValid() const;
00279
00286 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
00287
00295 virtual void changeLock(bool lock);
00296
00298
00301 public slots:
00302 void handleLocking(bool lock);
00303
00304 signals:
00305 void lockRequested(bool lock);
00306
00308 private:
00309
00311 BALLViewServer server_;
00312
00315 ObjectCreator *object_creator_;
00316
00317
00318 int port_;
00319
00320 ServerPreferences *server_preferences_;
00321 QLabel *server_icon_;
00322 static const char *mini_ray_xpm_[];
00323 };
00324
00325
00326 # ifndef BALL_NO_INLINE_FUNCTIONS
00327 # include <BALL/VIEW/KERNEL/serverWidget.iC>
00328 # endif
00329
00330 }
00331 }
00332
00333 #endif // BALL_VIEW_KERNEL_SERVER_H