Main Page | Namespace List | Class List | File List | Class Members | Related Pages

src/Service.h

00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: GPL 2.0
00004  *
00005  * K-10 Distributed Processing - Lium, Le Mans
00006  * Copyright (C) 2006 Cedric CHANTEPIE
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021  *
00022  * ***** END LICENSE BLOCK ***** */
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; // forward declaration
00039   class Manager; // forward declaration
00040 
00046   class Service 
00047   {
00048   public:
00049     // --- Constants ---
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     // --- Ctor / Dtor ---
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     // --- Properties accessors ---
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

Generated on Fri May 19 23:27:33 2006 for Tiny DNSSD by  doxygen 1.4.4