xref: /haiku/src/apps/debuganalyzer/util/DataSource.h (revision 602a9fe54dfd3679b083ae4bff48701e4267b330)
137ea7254SIngo Weinhold /*
237ea7254SIngo Weinhold  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
337ea7254SIngo Weinhold  * Distributed under the terms of the MIT License.
437ea7254SIngo Weinhold  */
537ea7254SIngo Weinhold #ifndef DATA_SOURCE_H
637ea7254SIngo Weinhold #define DATA_SOURCE_H
737ea7254SIngo Weinhold 
837ea7254SIngo Weinhold #include <Entry.h>
937ea7254SIngo Weinhold #include <File.h>
1037ea7254SIngo Weinhold #include <Path.h>
1137ea7254SIngo Weinhold 
1237ea7254SIngo Weinhold 
13*602a9fe5SIngo Weinhold struct BString;
14*602a9fe5SIngo Weinhold 
15*602a9fe5SIngo Weinhold 
1637ea7254SIngo Weinhold class DataSource {
1737ea7254SIngo Weinhold public:
1837ea7254SIngo Weinhold 								DataSource();
1937ea7254SIngo Weinhold 	virtual						~DataSource();
2037ea7254SIngo Weinhold 
2137ea7254SIngo Weinhold 	virtual	status_t			CreateDataIO(BDataIO** _io) = 0;
22*602a9fe5SIngo Weinhold 
23*602a9fe5SIngo Weinhold 	virtual	status_t			GetName(BString& name);
2437ea7254SIngo Weinhold };
2537ea7254SIngo Weinhold 
2637ea7254SIngo Weinhold 
2737ea7254SIngo Weinhold class FileDataSource : public DataSource {
2837ea7254SIngo Weinhold public:
2937ea7254SIngo Weinhold 	virtual	status_t			CreateDataIO(BDataIO** _io);
3037ea7254SIngo Weinhold 
3137ea7254SIngo Weinhold protected:
3237ea7254SIngo Weinhold 	virtual	status_t			OpenFile(BFile& file) = 0;
3337ea7254SIngo Weinhold };
3437ea7254SIngo Weinhold 
3537ea7254SIngo Weinhold 
3637ea7254SIngo Weinhold class PathDataSource : public FileDataSource {
3737ea7254SIngo Weinhold public:
3837ea7254SIngo Weinhold 			status_t			Init(const char* path);
3937ea7254SIngo Weinhold 
40*602a9fe5SIngo Weinhold 	virtual	status_t			GetName(BString& name);
41*602a9fe5SIngo Weinhold 
4237ea7254SIngo Weinhold protected:
4337ea7254SIngo Weinhold 	virtual	status_t			OpenFile(BFile& file);
4437ea7254SIngo Weinhold 
4537ea7254SIngo Weinhold private:
4637ea7254SIngo Weinhold 			BPath				fPath;
4737ea7254SIngo Weinhold };
4837ea7254SIngo Weinhold 
4937ea7254SIngo Weinhold 
5037ea7254SIngo Weinhold class EntryRefDataSource : public FileDataSource {
5137ea7254SIngo Weinhold public:
5237ea7254SIngo Weinhold 			status_t			Init(const entry_ref* ref);
5337ea7254SIngo Weinhold 
54*602a9fe5SIngo Weinhold 	virtual	status_t			GetName(BString& name);
55*602a9fe5SIngo Weinhold 
5637ea7254SIngo Weinhold protected:
5737ea7254SIngo Weinhold 	virtual	status_t			OpenFile(BFile& file);
5837ea7254SIngo Weinhold 
5937ea7254SIngo Weinhold private:
6037ea7254SIngo Weinhold 			entry_ref			fRef;
6137ea7254SIngo Weinhold };
6237ea7254SIngo Weinhold 
6337ea7254SIngo Weinhold 
6437ea7254SIngo Weinhold #endif	// DATA_SOURCE_H
65