xref: /haiku/src/apps/debuganalyzer/util/DataSource.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef DATA_SOURCE_H
6 #define DATA_SOURCE_H
7 
8 #include <Entry.h>
9 #include <File.h>
10 #include <Path.h>
11 
12 
13 struct BString;
14 
15 
16 class DataSource {
17 public:
18 								DataSource();
19 	virtual						~DataSource();
20 
21 	virtual	status_t			CreateDataIO(BDataIO** _io) = 0;
22 
23 	virtual	status_t			GetName(BString& name);
24 };
25 
26 
27 class FileDataSource : public DataSource {
28 public:
29 	virtual	status_t			CreateDataIO(BDataIO** _io);
30 
31 protected:
32 	virtual	status_t			OpenFile(BFile& file) = 0;
33 };
34 
35 
36 class PathDataSource : public FileDataSource {
37 public:
38 			status_t			Init(const char* path);
39 
40 	virtual	status_t			GetName(BString& name);
41 
42 protected:
43 	virtual	status_t			OpenFile(BFile& file);
44 
45 private:
46 			BPath				fPath;
47 };
48 
49 
50 class EntryRefDataSource : public FileDataSource {
51 public:
52 			status_t			Init(const entry_ref* ref);
53 
54 	virtual	status_t			GetName(BString& name);
55 
56 protected:
57 	virtual	status_t			OpenFile(BFile& file);
58 
59 private:
60 			entry_ref			fRef;
61 };
62 
63 
64 #endif	// DATA_SOURCE_H
65