xref: /haiku/src/bin/debug/profile/Team.h (revision 3be9edf8da228afd9fec0390f408c964766122aa)
1 /*
2  * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef TEAM_H
6 #define TEAM_H
7 
8 #include <String.h>
9 
10 #include <debug_support.h>
11 #include <ObjectList.h>
12 #include <util/DoublyLinkedList.h>
13 
14 #include "Thread.h"
15 
16 
17 struct system_profiler_team_added;
18 
19 
20 class Team {
21 public:
22 								Team();
23 								~Team();
24 
25 			status_t			Init(team_id teamID, port_id debuggerPort);
26 			status_t			Init(system_profiler_team_added* addedInfo);
27 			status_t			InitThread(Thread* thread);
28 
29 			void				RemoveThread(Thread* thread);
30 
31 			void				Exec(int32 event, const char* args,
32 									const char* threadName);
33 
34 			status_t			AddImage(SharedImage* sharedImage,
35 									const image_info& imageInfo, team_id owner,
36 									int32 event);
37 			status_t			RemoveImage(image_id imageID, int32 event);
38 
39 	inline	const BObjectList<Image>&	Images() const;
40 			Image*				FindImage(image_id id) const;
41 
42 	inline	team_id				ID() const;
43 
44 private:
45 			void				_RemoveImage(int32 index, int32 event);
46 
47 			bool				_SynchronousProfiling() const
48 									{ return fDebugContext.nub_port < 0; }
49 
50 private:
51 	typedef DoublyLinkedList<Thread> ThreadList;
52 
53 			team_id				fID;
54 			BString				fArgs;
55 			port_id				fNubPort;
56 			debug_context		fDebugContext;
57 			ThreadList			fThreads;
58 			BObjectList<Image>	fImages;
59 };
60 
61 
62 // #pragma mark -
63 
64 
65 const BObjectList<Image>&
66 Team::Images() const
67 {
68 	return fImages;
69 }
70 
71 
72 team_id
73 Team::ID() const
74 {
75 	return fID;
76 }
77 
78 
79 #endif	// TEAM_H
80