Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

vos/metaobjects/misc/services.hh

Go to the documentation of this file.
00001 /* $Id: services.hh,v 1.15 2003/07/24 05:18:20 tetron Exp $ */
00002 
00003 
00004 /* This file was generated by otd2cpp.pl.
00005 
00006     Copyright (C) 2002 Peter Amstutz <tetron@interreality.org>
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library 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 GNU
00016     Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with this library; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00021 */
00022 
00023 #ifndef _MISC_SERVICES_HH_
00024 #define _MISC_SERVICES_HH_
00025 
00026 #if defined(_WIN32) && defined(_MSC_VER)
00027 # ifdef MISC_EXPORTS
00028 #  define MISC_API __declspec(dllexport)
00029 # else
00030 #  define MISC_API __declspec(dllimport)
00031 # endif
00032 #else
00033 # define MISC_API
00034 #endif
00035 
00036 #include <vos/corelibs/vos/vos.hh>
00037 #include <vos/metaobjects/property/property.hh>
00038 #include <servicediscovery/servicedirectory.hh>
00039 
00040 /** MetaObject implementing the Services object type: make a service
00041     discovery system available through VOS.
00042 
00043     A services object contains a list of hypercards to services.  It
00044     is intended to be used as a registry of interesting VOS
00045     application running on a host, such as virtual
00046     worlds, GUI clients, chat clients, mp3 jukeboxes, print servers,
00047     etc to make it easy to discover these services.  
00048 
00049     The LocalServices object will typically be used by a service list
00050     daemon to hold a list of services for one host.  When queried,
00051     the daemon will search its local list as well as perform a 
00052     broadcast query to the local network, or into some other service
00053     discovery system such as SSDP or MDNS.  An application searching
00054     for services can simply connect to this default Services for
00055     its local host (the default URL is vop://localhost:4231/services)
00056     and perform the query via the query() method in the RemoteServices 
00057     interface.  An application wishing to register a service does the same, 
00058     using the registerService() method. As a shortcut, the static method
00059     registerServiceWithDefault() can be used as well.
00060 
00061     The hypercards in a services list will have, as co-types, a list of the 
00062     types of the objects that the hypercard links to prefixed with "linktype=".
00063     For example, a hypercard in a services directory points to a A3DL 
00064     virtual world.  The hypercard itself will have as types both
00065     "misc:hypercard" and "linktype=a3dl:world".  Note that the latter
00066     is a perfectly legal type!  This enables the user to do searches on
00067     a particular type string to look for particular services, but
00068     doesn't actually cause an application to try to load the hypercard as
00069     that type.
00070 
00071     @note This metaobject uses Hypercard and Property, so be sure to register
00072     those metaobject extenders as well.
00073 */
00074 class MISC_API Services : public virtual MetaObject
00075 {
00076 
00077 
00078 protected:
00079     PropertyAccessControl* accessControl;
00080     static Services* defaultServiceDir;
00081     static std::string serviceDirURL;
00082     std::map<int, LSD::ServiceAdvertismentListener*> queries;
00083 
00084 public:
00085 
00086     /** Constructor */
00087     Services(MetaObject* superobject);
00088 
00089     /** Destructor */
00090     virtual ~Services();
00091 
00092     /** Return type string ("misc:services") */
00093     virtual const std::string getType();
00094 
00095     /** Register Extenders */
00096     static void registerExtenders();
00097 
00098     /** Set default access control policy */
00099     virtual void setPropertyAccessControl(PropertyAccessControl* ac);
00100 
00101     /** Get default access control policy */
00102     virtual PropertyAccessControl* getPropertyAccessControl();
00103 
00104     /** @throw NoSuchObjectError (or possibly other exception) if services
00105         directory cannot be accessed */
00106     static Services* getDefaultServicesDir();
00107     static void setDefaultServiceDir(const std::string& url);
00108     static void registerServiceWithDefault(Vobject* service, const std::string& title, const std::string& desc = "");
00109 
00110     virtual void registerService(Vobject* service, const std::string& title, const std::string& desc = "");
00111 
00112     virtual int query(const std::string& typepattern,
00113                       const std::string& titlepattern,
00114                       const std::string& descpattern,
00115                       const std::string& urlpattern,
00116                       LSD::ServiceAdvertismentListener* cb) = 0;
00117     virtual void endQuery(int q) = 0;
00118 };
00119 
00120 class ServiceListenerSiteWrapper;
00121 
00122 /** Local version of Services. */
00123 class LocalServices : public virtual Services,
00124                       public virtual ChildChangeListener
00125 {
00126 public:
00127 
00128     /** Constructor */
00129     LocalServices(MetaObject* superobject);
00130 
00131     /** Destructor */
00132     ~LocalServices();
00133 
00134     /** Initialize required subproperties with given access control. */
00135     virtual void initialize(PropertyAccessControl* ac);
00136 
00137     /** Initialize required subproperties. If access control has been
00138     previously set with initialize(PropertyAccessControl*) or
00139     setPropertyAccessControl(), then that policy will be used. Otherwise,
00140     NoPropertyAccessControl will be used.
00141     */
00142     virtual void initialize();
00143 
00144     /** Static generator, for factory. */
00145     static MetaObject* new_LocalServices(MetaObject* superobject, const std::string& type);
00146 
00147     virtual void notifyChildInserted(VobjectEvent& event);
00148 
00149     virtual void notifyChildReplaced(VobjectEvent& event);
00150 
00151     virtual void notifyChildRemoved(VobjectEvent& event);
00152 
00153     /* override me */
00154     virtual int query(const std::string& typepattern,
00155                       const std::string& titlepattern,
00156                       const std::string& descpattern,
00157                       const std::string& urlpattern,
00158                       LSD::ServiceAdvertismentListener* cb);
00159 
00160     /* override me */
00161     virtual void endQuery(int q);
00162 
00163     virtual void handleQuery(Message* m);
00164     virtual void handleEndQuery(Message* m);
00165 
00166     friend class ServiceListenerSiteWrapper;
00167 };
00168 
00169 /** Remote version of Services. */
00170 class RemoteServices : public virtual Services
00171 {
00172 public:
00173 
00174     /** Constructor */
00175     RemoteServices(MetaObject* superobject);
00176 
00177     /** Destructor */
00178     virtual ~RemoteServices();
00179 
00180     /** Static generator, for factory. */
00181     static MetaObject* new_RemoteServices(MetaObject* superobject, const std::string& type);
00182 
00183     virtual int query(const std::string& typepattern,
00184                       const std::string& titlepattern,
00185                       const std::string& descpattern,
00186                       const std::string& urlpattern,
00187                       LSD::ServiceAdvertismentListener* cb);
00188 
00189     virtual void endQuery(int q);
00190 
00191     virtual void handleAdvertisement(Message* m);
00192 };
00193 
00194 class ServiceListenerSiteWrapper : public LSD::ServiceAdvertismentListener,
00195                                    public virtual ObjectExciseListener
00196 {
00197 private:
00198     LocalServices* services;
00199     Site* site;
00200     std::string nonce;
00201     int queryID;
00202 public:
00203     ServiceListenerSiteWrapper(LocalServices* sv, Site* st, const std::string& n);
00204     virtual ~ServiceListenerSiteWrapper();
00205     virtual void notifyNewService(int id, const LSD::Service& s);
00206     virtual void notifyObjectExcise(RefCounted* rc);
00207     virtual void setQueryID(int r) { queryID = r; }
00208 };
00209 
00210 #endif // #ifdef _SERVICES_HH_
00211 

Generated on Tue Aug 12 03:55:45 2003 for Interreality Project - VOS by doxygen 1.3.2