00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_CONCEPT_CLIENT_H 00006 #define BALL_CONCEPT_CLIENT_H 00007 00008 #ifndef BALL_COMMON_H 00009 # include <BALL/common.h> 00010 #endif 00011 00012 #ifndef BALL_CONCEPT_COMPOSITE_H 00013 # include <BALL/CONCEPT/composite.h> 00014 #endif 00015 00016 #ifndef BALL_SYSTEM_NETWORKING_H 00017 # include <BALL/SYSTEM/networking.h> 00018 #endif 00019 00020 #ifndef BALL_CONCEPT_PERSISTENTOBJECT_H 00021 # include <BALL/CONCEPT/persistentObject.h> 00022 #endif 00023 00024 #ifndef BALL_CONCET_TEXTPERSISTENCEMANAGER_H 00025 # include <BALL/CONCEPT/textPersistenceManager.h> 00026 #endif 00027 00028 #define DEFAULT_PORT 20000 00029 00030 namespace BALL 00031 { 00047 class BALL_EXPORT Client 00048 { 00049 public: 00050 00057 enum Command 00058 { 00060 COMMAND__UNKOWN = 0, 00061 00063 COMMAND__SEND_OBJECT = 1, 00064 00066 NUMBER_OF_COMMANDS 00067 }; 00068 00072 00078 class BALL_EXPORT InvalidClient: public Exception::GeneralException 00079 { 00080 public: 00081 00082 InvalidClient(const char* file, int line) 00083 ; 00084 }; 00085 00092 class BALL_EXPORT NoPersistentObject: public Exception::GeneralException 00093 { 00094 public: 00095 00096 NoPersistentObject(const char* file, int line) 00097 ; 00098 }; 00099 00101 00104 00111 Client() 00112 ; 00113 00125 Client(const String& host, int port = 20000) 00126 ; 00127 00129 00131 00134 virtual ~Client() 00135 ; 00136 00140 virtual void clear() 00141 ; 00142 00144 00147 00154 void connect(const String& host, int port = 20000) 00155 ; 00156 00171 void insert(Composite &composite) 00172 throw(InvalidClient, NoPersistentObject); 00174 00177 00186 virtual bool isValid() const 00187 ; 00188 00195 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const 00196 ; 00197 00199 00200 private: 00201 00202 String host_; 00203 int port_; 00204 00205 TextPersistenceManager pm_; 00206 }; 00207 00208 } // namespace BALL 00209 00210 #endif // BALL_CONCEPT_CLIENT_H