2 * Copyright 2016, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
12 #include <ObjectList.h>
13 #include <Referenceable.h>
14 #include <util/DoublyLinkedList.h>
20 class TargetHost
: public BReferenceable
{
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;
43 typedef DoublyLinkedList
<Listener
> ListenerList
;
44 typedef BObjectList
<TeamInfo
> TeamInfoList
;
47 static int _CompareTeams(const TeamInfo
* a
,
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
);
59 ListenerList fListeners
;
64 class TargetHost::Listener
65 : public DoublyLinkedListLinkImpl
<TargetHost::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