vfs: check userland buffers before reading them.
[haiku.git] / headers / private / debugger / model / TargetHost.h
blobad63df25ce770171a036bdf9ceab72c0d0adb001
1 /*
2 * Copyright 2016, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef TARGET_HOST_H
6 #define TARGET_HOST_H
8 #include <Locker.h>
9 #include <OS.h>
10 #include <String.h>
12 #include <ObjectList.h>
13 #include <Referenceable.h>
14 #include <util/DoublyLinkedList.h>
17 class TeamInfo;
20 class TargetHost : public BReferenceable {
21 public:
22 class Listener;
23 public:
24 TargetHost(const BString& name);
25 virtual ~TargetHost();
27 bool Lock() { return fLock.Lock(); }
28 void Unlock() { fLock.Unlock(); }
30 const BString& Name() const { return fName; }
32 void AddListener(Listener* listener);
33 void RemoveListener(Listener* listener);
35 int32 CountTeams() const;
36 status_t AddTeam(const team_info& info);
37 void RemoveTeam(team_id team);
38 void UpdateTeam(const team_info& info);
39 TeamInfo* TeamInfoAt(int32 index) const;
40 TeamInfo* TeamInfoByID(team_id team) const;
42 private:
43 typedef DoublyLinkedList<Listener> ListenerList;
44 typedef BObjectList<TeamInfo> TeamInfoList;
46 private:
47 static int _CompareTeams(const TeamInfo* a,
48 const TeamInfo* b);
49 static int _FindTeamByKey(const team_id* id,
50 const TeamInfo* info);
52 void _NotifyTeamAdded(TeamInfo* info);
53 void _NotifyTeamRemoved(team_id team);
54 void _NotifyTeamRenamed(TeamInfo* info);
56 private:
57 BString fName;
58 BLocker fLock;
59 ListenerList fListeners;
60 TeamInfoList fTeams;
64 class TargetHost::Listener
65 : public DoublyLinkedListLinkImpl<TargetHost::Listener> {
66 public:
67 virtual ~Listener();
69 virtual void TeamAdded(TeamInfo* info);
70 virtual void TeamRemoved(team_id team);
71 virtual void TeamRenamed(TeamInfo* info);
74 #endif // TARGET_HOST_H