Logo ROOT   6.10/09
Reference Guide
TBonjourRegistrar.h
Go to the documentation of this file.
1 // @(#)root/bonjour:$Id$
2 // Author: Fons Rademakers 29/05/2009
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TBonjourRegistrar
13 #define ROOT_TBonjourRegistrar
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TBonjourRegistrar //
19 // //
20 // This class consists of one main member function, RegisterService(), //
21 // that registers the service. As long as the object is alive, the //
22 // service stays registered. The rest of the class wraps the various //
23 // bits of Bonjour service registration. The static callback function //
24 // is marked with the DNSSD_API macro to make sure that the callback //
25 // has the correct calling convention on Windows. //
26 // //
27 // Bonjour works out-of-the-box on MacOS X. On Linux you have to //
28 // install the Avahi package and run the avahi-daemon. To compile //
29 // these classes and run Avahi on Linux you need to install the: //
30 // avahi //
31 // avahi-compat-libdns_sd-devel //
32 // nss-mdns //
33 // packages. After installation make sure the avahi-daemon is started. //
34 // //
35 //////////////////////////////////////////////////////////////////////////
36 
37 #include "TObject.h"
38 #include "TQObject.h"
39 #include "TBonjourRecord.h"
40 
41 #if !defined(__CINT__)
42 #include <dns_sd.h>
43 #else
44 typedef ULong_t DNSServiceRef;
45 typedef UInt_t DNSServiceFlags;
46 typedef Int_t DNSServiceErrorType;
47 #endif
48 
49 class TFileHandler;
50 
51 
52 class TBonjourRegistrar : public TObject, public TQObject {
53 
54 private:
55  DNSServiceRef fDNSRef;
58 
59  void *GetSender() { return this; } // used to get gTQSender
60 
61 #if !defined(__CINT__)
62  static void DNSSD_API BonjourRegisterService(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType,
63  const char *, const char *, const char *, void *);
64 #else
65  static void BonjourRegisterService(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType,
66  const char *, const char *, const char *, void *);
67 #endif
68 
69 public:
71  virtual ~TBonjourRegistrar();
72 
73  Int_t RegisterService(const TBonjourRecord &record, UShort_t servicePort);
75 
76  void ServiceRegistered(TBonjourRecord *record); //*SIGNAL*
77 
78  void BonjourSocketReadyRead(); // private slot
79 
80  ClassDef(TBonjourRegistrar,0) // Register Bonjour service
81 };
82 
83 #endif
TBonjourRegistrar()
Default ctor.
unsigned short UShort_t
Definition: RtypesCore.h:36
Int_t RegisterService(const TBonjourRecord &record, UShort_t servicePort)
Register Bonjour service.
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:49
TFileHandler * fBonjourSocketHandler
int Int_t
Definition: RtypesCore.h:41
#define ClassDef(name, id)
Definition: Rtypes.h:297
DNSServiceRef fDNSRef
void BonjourSocketReadyRead()
The Bonjour socket is ready for reading.
virtual ~TBonjourRegistrar()
Cleanup.
TBonjourRecord RegisteredRecord() const
unsigned int UInt_t
Definition: RtypesCore.h:42
unsigned long ULong_t
Definition: RtypesCore.h:51
TBonjourRecord fFinalRecord
Mother of all ROOT objects.
Definition: TObject.h:37
static void DNSSD_API BonjourRegisterService(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType, const char *, const char *, const char *, void *)
Static Bonjour register callback function.
void ServiceRegistered(TBonjourRecord *record)
Emit ServiceRegistered signal.