xref: /haiku/headers/private/debugger/model/FileSourceCode.h (revision 5e7964b0a929555415798dea3373db9ac4611caa)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef FILE_SOURCE_CODE_H
6 #define FILE_SOURCE_CODE_H
7 
8 
9 #include <Locker.h>
10 
11 #include <Array.h>
12 
13 #include "SourceCode.h"
14 
15 
16 class LocatableFile;
17 class SourceFile;
18 
19 
20 class FileSourceCode : public SourceCode {
21 public:
22 								FileSourceCode(LocatableFile* file,
23 									SourceFile* sourceFile,
24 									SourceLanguage* language);
25 	virtual						~FileSourceCode();
26 
27 			status_t			Init();
28 			status_t			AddSourceLocation(
29 									const SourceLocation& location);
30 
31 	virtual	bool				Lock();
32 	virtual	void				Unlock();
33 
34 	virtual	SourceLanguage*		GetSourceLanguage() const;
35 
36 	virtual	bool				GetStatementLocationRange(
37 									const SourceLocation& location,
38 									SourceLocation& _start,
39 									SourceLocation& _end) const;
40 
41 	virtual	LocatableFile*		GetSourceFile() const;
42 
43 	// LineDataSource
44 	virtual	int32				CountLines() const;
45 	virtual	const char*			LineAt(int32 index) const;
46 	virtual int32				LineLengthAt(int32 index) const;
47 
48 private:
49 			int32				_FindSourceLocationIndex(
50 									const SourceLocation& location,
51 									bool& _foundMatch) const;
52 
53 private:
54 			BLocker				fLock;
55 			LocatableFile*		fFile;
56 			SourceFile*			fSourceFile;
57 			SourceLanguage*		fLanguage;
58 			Array<SourceLocation> fSourceLocations;
59 };
60 
61 
62 #endif	// FILE_BASED_SOURCE_CODE_H
63