2016-04-07 03:58:01 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2016, Rene Gollent, rene@gollent.com.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef TARGET_HOST_INTERFACE_ROSTER_H
|
|
|
|
#define TARGET_HOST_INTERFACE_ROSTER_H
|
|
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
#include <Locker.h>
|
|
|
|
#include <ObjectList.h>
|
|
|
|
|
2016-04-21 03:11:51 +03:00
|
|
|
#include "TargetHostInterface.h"
|
|
|
|
|
2016-04-07 03:58:01 +03:00
|
|
|
|
|
|
|
class Settings;
|
|
|
|
class TargetHostInterfaceInfo;
|
|
|
|
|
|
|
|
|
2016-04-21 03:11:51 +03:00
|
|
|
class TargetHostInterfaceRoster : private TargetHostInterface::Listener {
|
2016-04-07 03:58:01 +03:00
|
|
|
public:
|
2016-04-21 03:43:15 +03:00
|
|
|
class Listener;
|
2016-04-07 03:58:01 +03:00
|
|
|
TargetHostInterfaceRoster();
|
|
|
|
virtual ~TargetHostInterfaceRoster();
|
|
|
|
|
|
|
|
static TargetHostInterfaceRoster* Default();
|
2016-04-21 03:43:15 +03:00
|
|
|
static status_t CreateDefault(Listener* listener);
|
2016-04-07 03:58:01 +03:00
|
|
|
static void DeleteDefault();
|
|
|
|
|
2016-04-12 23:58:02 +03:00
|
|
|
bool Lock() { return fLock.Lock(); }
|
|
|
|
void Unlock() { fLock.Unlock(); }
|
|
|
|
|
2016-04-21 03:43:15 +03:00
|
|
|
status_t Init(Listener* listener);
|
2016-04-07 03:58:01 +03:00
|
|
|
status_t RegisterInterfaceInfos();
|
|
|
|
|
2016-04-12 23:58:02 +03:00
|
|
|
int32 CountInterfaceInfos() const;
|
2016-04-07 03:58:01 +03:00
|
|
|
TargetHostInterfaceInfo*
|
|
|
|
InterfaceInfoAt(int32 index) const;
|
|
|
|
|
|
|
|
status_t CreateInterface(TargetHostInterfaceInfo* info,
|
|
|
|
Settings* settings,
|
2016-04-12 23:58:02 +03:00
|
|
|
TargetHostInterface*& _interface);
|
2016-04-07 03:58:01 +03:00
|
|
|
|
2016-04-12 23:58:02 +03:00
|
|
|
int32 CountActiveInterfaces() const;
|
2016-04-07 03:58:01 +03:00
|
|
|
TargetHostInterface* ActiveInterfaceAt(int32 index) const;
|
|
|
|
|
2016-04-21 03:11:51 +03:00
|
|
|
int32 CountRunningTeamDebuggers() const
|
|
|
|
{ return fRunningTeamDebuggers; }
|
|
|
|
|
|
|
|
// TargetHostInterface::Listener
|
|
|
|
virtual void TeamDebuggerStarted(TeamDebugger* debugger);
|
|
|
|
virtual void TeamDebuggerQuit(TeamDebugger* debugger);
|
|
|
|
virtual void TargetHostInterfaceQuit(
|
|
|
|
TargetHostInterface* interface);
|
Debugger: Rework to fully use TargetHostInterface.
Application objects:
- Rework and simplify to take into account that they will no longer be
directly managing the team debugger list. Requests to start a new debugger
are still funnelled through here however, and as such, said requests must
now provide the appropriate target host to start with. Adjust StartTeamWindow
and TeamsWindow accordingly.
- On global init, always create an instance of the local interface.
TargetHostInterface:
- Convert to BLooper and implement TeamDebugger's Listener interface.
TargetHostInterfaces now directly manage their TeamDebugger instances,
and consequently take over the equivalent duties that the main application
previously had.
- Adjust signatures of Attach/CreateTeam to add const. Adjust
LocalTargetHostInterface accordingly.
- Add accessor to determine if a given interface is local or not. Will be
needed for the TeamDebugger's file manager eventually so it knows if it
needs to request remote files if no matching local file is found.
- Add accessor to start a TeamDebugger instance, and corresponding options
structure.
TargetHostInterfaceRoster:
- Minor adjustments to host interface initialization to take into account
needing to start the looper.
- Add accessor for number of running team debuggers, for the main app to
use when deciding to quit.
TeamDebugger:
- Add accessor for SettingsManager. Needed for the case of a restart request,
as the host interfaces do not have direct access to it.
TeamsWindow:
- For now, always grab the local host interface when initializing the window.
Once the remote interface is implemented, this will need to be adjusted, but
the appropriate UI for creating/selecting it is needed first anyways.
With these changes, the main application is fully host-agnostic, and all
management of actual debuggers is delegated to their parent host interfaces.
There still needs to be a listener interface for the host interface and/or
roster though, so that the application can be made aware of when debuggers
quit, as this drives whether it's time to terminate the app or not.
2016-04-21 02:23:01 +03:00
|
|
|
|
2016-04-07 03:58:01 +03:00
|
|
|
private:
|
|
|
|
typedef BObjectList<TargetHostInterfaceInfo> InfoList;
|
|
|
|
typedef BObjectList<TargetHostInterface> InterfaceList;
|
|
|
|
|
|
|
|
private:
|
|
|
|
BLocker fLock;
|
|
|
|
static TargetHostInterfaceRoster* sDefaultInstance;
|
|
|
|
|
2016-04-21 03:11:51 +03:00
|
|
|
int32 fRunningTeamDebuggers;
|
2016-04-07 03:58:01 +03:00
|
|
|
InfoList fInterfaceInfos;
|
|
|
|
InterfaceList fActiveInterfaces;
|
2016-04-21 03:43:15 +03:00
|
|
|
Listener* fListener;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TargetHostInterfaceRoster::Listener {
|
|
|
|
public:
|
|
|
|
virtual ~Listener();
|
|
|
|
|
|
|
|
virtual void TeamDebuggerCountChanged(int32 newCount);
|
2016-04-07 03:58:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // TARGET_HOST_INTERFACE_ROSTER_H
|