Extend ioutputparser interface to improve testability

This commit is contained in:
Tobias Hunger
2010-03-03 18:01:32 +01:00
parent d7b927f2d2
commit c59912819f
5 changed files with 28 additions and 2 deletions

View File

@@ -34,7 +34,6 @@ namespace ProjectExplorer {
IOutputParser::IOutputParser() : m_parser(0) IOutputParser::IOutputParser() : m_parser(0)
{ {
} }
IOutputParser::~IOutputParser() IOutputParser::~IOutputParser()
@@ -57,6 +56,18 @@ void IOutputParser::appendOutputParser(IOutputParser *parser)
this, SLOT(taskAdded(ProjectExplorer::TaskWindow::Task))); this, SLOT(taskAdded(ProjectExplorer::TaskWindow::Task)));
} }
IOutputParser *IOutputParser::takeOutputParserChain()
{
IOutputParser *parser = m_parser;
m_parser = 0;
return parser;
}
IOutputParser *IOutputParser::childParser() const
{
return m_parser;
}
void IOutputParser::stdOutput(const QString &line) void IOutputParser::stdOutput(const QString &line)
{ {
if (m_parser) if (m_parser)

View File

@@ -47,7 +47,15 @@ public:
/// Append a subparser to this parser. /// Append a subparser to this parser.
/// IOutputParser will take ownership. /// IOutputParser will take ownership.
void appendOutputParser(IOutputParser *parser); virtual void appendOutputParser(IOutputParser *parser);
/// Remove the appended outputparser chain frm this parser.
/// This method transferes ownership of the parser chain to the caller!
IOutputParser *takeOutputParserChain();
/// Return the head of this parsers output parser children
/// IOutputParser keeps ownership!
IOutputParser *childParser() const;
/// Called once for each line if standard output to parse. /// Called once for each line if standard output to parse.
virtual void stdOutput(const QString &line); virtual void stdOutput(const QString &line);

View File

@@ -40,6 +40,7 @@ class SessionManager;
class IApplicationOutput; class IApplicationOutput;
class IOutputParser; class IOutputParser;
class GlobalConfigManagerInterface; class GlobalConfigManagerInterface;
struct TaskWindow::Task;
namespace Internal { namespace Internal {
class CommandQObject; class CommandQObject;
@@ -56,5 +57,6 @@ Q_DECLARE_METATYPE(ProjectExplorer::IOutputParser*)
Q_DECLARE_METATYPE(ProjectExplorer::GlobalConfigManagerInterface*) Q_DECLARE_METATYPE(ProjectExplorer::GlobalConfigManagerInterface*)
Q_DECLARE_METATYPE(ProjectExplorer::TaskWindow::Task) Q_DECLARE_METATYPE(ProjectExplorer::TaskWindow::Task)
Q_DECLARE_METATYPE(QList<ProjectExplorer::TaskWindow::Task>)
#endif // PROJECTEXPLORERMETATYPEDECLARATIONS_H #endif // PROJECTEXPLORERMETATYPEDECLARATIONS_H

View File

@@ -492,6 +492,7 @@ TaskWindow::TaskWindow()
m_categoriesButton->setMenu(m_categoriesMenu); m_categoriesButton->setMenu(m_categoriesMenu);
qRegisterMetaType<ProjectExplorer::TaskWindow::Task>("ProjectExplorer::TaskWindow::Task"); qRegisterMetaType<ProjectExplorer::TaskWindow::Task>("ProjectExplorer::TaskWindow::Task");
qRegisterMetaType<QList<ProjectExplorer::TaskWindow::Task> >("QList<ProjectExplorer::TaskWindow::Task>");
updateActions(); updateActions();
} }

View File

@@ -71,6 +71,10 @@ public:
const QString &file_, int line_, const QString &category_) : const QString &file_, int line_, const QString &category_) :
type(type_), description(description_), file(file_), line(line_), category(category_) type(type_), description(description_), file(file_), line(line_), category(category_)
{ } { }
Task(const Task &source) :
type(source.type), description(source.description), file(source.file),
line(source.line), category(source.category)
{ }
~Task() ~Task()
{ } { }