1 /*
2  * Hydrogen
3  * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4  *
5  * http://www.hydrogen-music.org
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY, without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22 
23 #ifndef NSM_CLIENT_H
24 #define NSM_CLIENT_H
25 
26 #if defined(H2CORE_HAVE_OSC) || _DOXYGEN_
27 
28 #include <hydrogen/object.h>
29 #include <cassert>
30 
31 
32 /**
33 * @class NsmClient
34 *
35 * @brief Non session manager client implementation
36 *
37 *
38 * @author Sebastian Moors
39 *
40 */
41 
42 class NsmClient : public H2Core::Object
43 {
44 	H2_OBJECT
45 	public:
46 		/**
47 		 * Object holding the current NsmClient singleton. It
48 		 * is initialized with NULL, set with
49 		 * create_instance(), and accessed with
50 		 * get_instance().
51 		 */
52 		static NsmClient* __instance;
53 		~NsmClient();
54 
55 		pthread_t m_NsmThread;
56 		/**
57 		 * If #__instance equals 0, a new NsmClient singleton
58 		 * will be created and stored in it.
59 		 *
60 		 * It is called in
61 		 * H2Core::Hydrogen::create_instance().
62 		 */
63 		static void create_instance();
64 		/**
65 		 * Returns a pointer to the current NsmClient
66 		 * singleton stored in #__instance.
67 		 */
get_instance()68 		static NsmClient* get_instance() { assert(__instance); return __instance; }
69 
70 		void createInitialClient();
71 
72 		void shutdown();
73 
74 		/**
75 		 * To determine whether Hydrogen is under Non session management,
76 		 * it is not sufficient to check whether the NSM_URL environmental
77 		 * variable is set but also whether the NSM server did respond
78 		 * to the announce message appropriately. Therefore,
79 		 * createInitialClient() has to be called first.
80 		 */
81 		bool m_bUnderSessionManagement;
82 
83 	private:
84 		NsmClient();
85 
86 };
87 
88 #endif /* H2CORE_HAVE_OSC */
89 
90 #endif // NSM_CLIENT_H
91