1 #ifndef _Q_GLOBAL_READER_HH_
2 #define _Q_GLOBAL_READER_HH_
54 template<
class Q>
const Q*
Get(
const std::string& name,
QError&
err)
const
58 qobj =
dynamic_cast<const Q*
>(obj);
61 std::stringstream msg;
62 msg<<
"Requested type: "<<
Demangle(qobj)<<
" found type: "<<obj->ClassName();
63 err.SetDescription(msg.str());
70 template<
class Q>
const Q*
Get(
const Diana::QGlobalLabel& label,
QError&
err)
const
74 qobj =
dynamic_cast<const Q*
>(obj);
77 std::stringstream msg;
78 msg<<
"Requested type: "<<
Demangle(qobj)<<
" found type: "<<obj->ClassName();
79 err.SetDescription(msg.str());
91 err.SetDescription(
GetName(),0,
"GetQObject not implemented");
95 virtual const Diana::QObject*
GetQObject(
const Diana::QGlobalLabel& label,
const std::string& className,
QError&
err)
const
101 virtual QError Open(
const std::string& filename,
const std::string& opt =
"") = 0;
129 #define CREATE_GOLBAL_READER_IMPL(clazz,ext) \
130 class clazz ## Factory: public QGlobalReaderFactory{\
132 clazz ## Factory() : QGlobalReaderFactory(#clazz,ext) {}\
133 QGlobalReader *Create(){ return new clazz; }\
136 #define REGISTER_GLOBAL_READER(clazz, ext) \
137 CREATE_GOLBAL_READER_IMPL(clazz, ext);\
138 extern "C" void registerInFactory ## clazz() {\
139 QGlobalReaderFactory* pt = new clazz ## Factory;\
140 QGlobalRWFactory::GetInstance().RegisterGlobalReader(pt);\
std::string Demangle(const C &obj, int firstChar=0)
error class with error type and description
This class take care of plugin registration and creation.
Class that returns a pointer to the reader matching the given input filename.
abstract factory for QGlobalReader.
QGlobalReaderFactory(const std::string &name, const std::string &ext)
virtual ~QGlobalReaderFactory()
virtual QGlobalReader * Create()=0
const std::string & GetExt() const
const std::string & GetName() const
Abstract class for global readers.
const Q * Get(const std::string &name, QError &err) const
Get QObject, owned by this reader.
virtual const Diana::QObject * GetQObject(const Diana::QGlobalLabel &label, const std::string &className, QError &err) const
const Q * Get(const Diana::QGlobalLabel &label, QError &err) const
Get QObject, owned by this reader.
virtual QError Close()=0
Close file, called by QGlobalReaderDispatcher.
virtual const Diana::QObject * GetQObject(const std::string &, const std::string &, QError &err) const
virtual ~QGlobalReader()
destructor
virtual QError Open(const std::string &filename, const std::string &opt="")=0
Open file, called by QGlobalReaderDispatcher.
QGlobalReader(const std::string &name)
constructor
base class for anything that has a name
const std::string & GetName() const