xref: /haiku/headers/private/debugger/target_host_interface/TargetHostInterfaceRoster.h (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
1 /*
2  * Copyright 2016, Rene Gollent, rene@gollent.com.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef TARGET_HOST_INTERFACE_ROSTER_H
6 #define TARGET_HOST_INTERFACE_ROSTER_H
7 
8 #include <OS.h>
9 
10 #include <Locker.h>
11 #include <ObjectList.h>
12 
13 #include "TargetHostInterface.h"
14 
15 
16 class Settings;
17 class TargetHostInterfaceInfo;
18 
19 
20 class TargetHostInterfaceRoster : private TargetHostInterface::Listener {
21 public:
22 	class Listener;
23 								TargetHostInterfaceRoster();
24 	virtual						~TargetHostInterfaceRoster();
25 
26 	static	TargetHostInterfaceRoster* Default();
27 	static	status_t			CreateDefault(Listener* listener);
28 	static	void				DeleteDefault();
29 
Lock()30 			bool				Lock()		{ return fLock.Lock(); }
Unlock()31 			void				Unlock()	{ fLock.Unlock(); }
32 
33 			status_t			Init(Listener* listener);
34 			status_t			RegisterInterfaceInfos();
35 
36 			int32				CountInterfaceInfos() const;
37 			TargetHostInterfaceInfo*
38 								InterfaceInfoAt(int32 index) const;
39 
40 			status_t			CreateInterface(TargetHostInterfaceInfo* info,
41 									Settings* settings,
42 									TargetHostInterface*& _interface);
43 
44 			int32				CountActiveInterfaces() const;
45 			TargetHostInterface* ActiveInterfaceAt(int32 index) const;
46 
CountRunningTeamDebuggers()47 			int32				CountRunningTeamDebuggers() const
48 									{ return fRunningTeamDebuggers; }
49 
50 	// TargetHostInterface::Listener
51 	virtual	void				TeamDebuggerStarted(TeamDebugger* debugger);
52 	virtual	void 				TeamDebuggerQuit(TeamDebugger* debugger);
53 	virtual	void				TargetHostInterfaceQuit(
54 									TargetHostInterface* interface);
55 
56 private:
57 			typedef BObjectList<TargetHostInterfaceInfo> InfoList;
58 			typedef BObjectList<TargetHostInterface> InterfaceList;
59 
60 private:
61 			BLocker				fLock;
62 	static	TargetHostInterfaceRoster* sDefaultInstance;
63 
64 			int32				fRunningTeamDebuggers;
65 			InfoList			fInterfaceInfos;
66 			InterfaceList		fActiveInterfaces;
67 			Listener*			fListener;
68 };
69 
70 
71 class TargetHostInterfaceRoster::Listener {
72 public:
73 	virtual						~Listener();
74 
75 	virtual	void				TeamDebuggerCountChanged(int32 newCount);
76 };
77 
78 
79 #endif	// TARGET_HOST_INTERFACE_ROSTER_H
80