00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SERVICE_H
00025 #define SERVICE_H
00026
00027 #include <string>
00028 #include <list>
00029 #include <map>
00030
00031 #include "ServiceChangeListener.h"
00032
00036 namespace dnssd {
00037
00038 class Service;
00039 class Manager;
00040
00046 class Service
00047 {
00048 public:
00049
00050
00054 const static std::string kTCP;
00055
00059 const static std::string kUDP;
00060
00064 const static std::string kLOCAL;
00065
00069 const static std::string kSEPARATOR;
00070
00071
00072
00084 Service(int aIface,
00085 std::string& aSrvType,
00086 std::string& aRegistrationType,
00087 std::string& aDomain,
00088 std::string& aName,
00089 std::string& aHost,
00090 int aPort,
00091 std::map<std::string,std::string>& aResources);
00092
00093 ~Service();
00094
00095
00096
00103 int stop();
00104
00105
00106
00114 void setResource(const std::string& aName,
00115 const std::string& aValue);
00116
00122 std::map<std::string,std::string> getResources();
00123
00129 void setResources(std::map<std::string,std::string> aResources);
00130
00137 std::string& getResource(const std::string& aName);
00138
00146 int removeResource(const std::string& aName);
00147
00153 int getIface();
00154
00159 std::string getServiceType();
00160
00165 std::string getRegistrationType();
00166
00171 std::string getDomain();
00172
00177 std::string getName();
00178
00184 int getPort();
00185
00191 std::string getHostname();
00192
00198 std::string getNodeName();
00199
00206 void addServiceChangeListener(const ServiceChangeListener* aListener);
00207
00213 void removeServiceChangeListener(const ServiceChangeListener* aListener);
00214
00220 std::string toString();
00221
00222 private:
00223 Service();
00224
00232 void firePropertyChanged(const std::string& aPropertyName,
00233 const std::string& aOldValue,
00234 const std::string& aNewValue);
00235
00242 void firePropertiesChanged(const std::map<std::string,std::string> aOldResources,
00243 const std::map<std::string,std::string> aNewResources);
00244
00245 int mIface;
00246 std::string mHost;
00247 std::string mSrvType;
00248 std::string mRegistrationType;
00249 std::string mDomain;
00250 std::string mName;
00251 int mPort;
00252 std::map<std::string,std::string> mResources;
00253 Manager* mManager;
00254 std::list<const ServiceChangeListener*> mListeners;
00255 };
00256 }
00257
00258 #define SERVICE_H
00259 #endif