|
From: <got...@us...> - 2009-03-14 18:25:47
|
Revision: 203
http://scstudio.svn.sourceforge.net/scstudio/?rev=203&view=rev
Author: gotthardp
Date: 2009-03-14 18:25:33 +0000 (Sat, 14 Mar 2009)
Log Message:
-----------
Based on a subset of VSL reporting functions implemented generic reporting system.
Modified formatter.h interface: 1) integrated with reporting system, 2) load_msc takes filename as a parameter.
Z120 parser integrated into the Visio application.
Implemented z120_test program.
Modified Paths:
--------------
trunk/CMakeLists.txt
trunk/src/data/CMakeLists.txt
trunk/src/data/Z120/CMakeLists.txt
trunk/src/data/Z120/z120.h
trunk/src/data/engmann/engmann.cpp
trunk/src/data/engmann/engmann.h
trunk/src/data/formatter.h
trunk/src/view/visio/addon/dllmodule.rc
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/addon/reportview.cpp
trunk/src/view/visio/addon/reportview.h
trunk/src/view/visio/scstudio.nsi
trunk/tests/CMakeLists.txt
trunk/tests/engmann_test.cpp
Added Paths:
-----------
trunk/src/data/Z120/z120_load.cpp
trunk/src/data/reporter.h
trunk/tests/z120_test.cpp
Removed Paths:
-------------
trunk/src/data/Z120/Z120.cpp
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/CMakeLists.txt 2009-03-14 18:25:33 UTC (rev 203)
@@ -16,6 +16,10 @@
FIND_PACKAGE(Boost REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
+FIND_PACKAGE(Java)
+# do not make antlr a mandatory prerequisite
+FIND_PACKAGE(ANTLR)
+
INCLUDE_DIRECTORIES(src)
INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/include)
Modified: trunk/src/data/CMakeLists.txt
===================================================================
--- trunk/src/data/CMakeLists.txt 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/data/CMakeLists.txt 2009-03-14 18:25:33 UTC (rev 203)
@@ -3,6 +3,7 @@
msc.cpp
msc.h
msc_visual.h
+ reporter.h
formatter.h
checker.h
dfs_area_traverser.cpp
Modified: trunk/src/data/Z120/CMakeLists.txt
===================================================================
--- trunk/src/data/Z120/CMakeLists.txt 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/data/Z120/CMakeLists.txt 2009-03-14 18:25:33 UTC (rev 203)
@@ -1,6 +1,3 @@
-FIND_PACKAGE(Java)
-FIND_PACKAGE(ANTLR)
-
# do not make antlr a mandatory prerequisite
IF(ANTLR_FOUND)
ADD_DEFINITIONS(-DHAVE_ANTLR)
@@ -12,6 +9,7 @@
DEPENDS Z120.g)
SET(PARSER_SOURCES
+ z120_load.cpp
Z120.g
Context.cpp
Z120Lexer.c
Deleted: trunk/src/data/Z120/Z120.cpp
===================================================================
--- trunk/src/data/Z120/Z120.cpp 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/data/Z120/Z120.cpp 2009-03-14 18:25:33 UTC (rev 203)
@@ -1,109 +0,0 @@
-/*
- * scstudio - Sequence Chart Studio
- * http://scstudio.sourceforge.net
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * Copyright (c) 2008 Petr Gotthard <pet...@ce...>
- *
- * $Id$
- */
-
-#include "Z120.h"
-
-// Process "Z120.g" with antlr-2008-05-07 to produce the following files.
-#include "Z120Lexer.h"
-#include "Z120Parser.h"
-
-#include <assert.h>
-
-inline std::string getTokenString(pANTLR3_COMMON_TOKEN token)
-{
- return std::string((char*)token->getStartIndex(token),
- token->getStopIndex(token)-token->getStartIndex(token)+1);
-}
-
-static void walk(pANTLR3_BASE_TREE tree)
-{
- assert(tree != NULL);
- switch(tree->getType(tree))
- {
- case NAME:
- {
- std::string pp = getTokenString(tree->getToken(tree));
- printf("NAME %s\n", pp.c_str());
- break;
- }
-
- case MSC:
- printf("MSC\n");
- walk((pANTLR3_BASE_TREE)tree->getChild(tree, 0));
- printf(";\n\n");
- break;
-
- default:
- fprintf(stderr, "Unexpected node<%d>\n", tree->getType(tree));
- break;
- }
-}
-
-int Z120::readFile(const std::string& filename)
-{
- pANTLR3_INPUT_STREAM input =
- antlr3AsciiFileStreamNew((pANTLR3_UINT8)filename.c_str());
- if (input == NULL || (int)input < 0)
- {
- fprintf(stderr, "Unable to open file %s\n", filename.c_str());
- exit(1);
- }
-
- pZ120Lexer lxr = Z120LexerNew(input);
-
- if (lxr == NULL)
- {
- fprintf(stderr, "Unable to create the lexer\n");
- exit(1);
- }
-
- pANTLR3_COMMON_TOKEN_STREAM tstream =
- antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, lxr->pLexer->rec->state->tokSource);
- if (tstream == NULL)
- {
- fprintf(stderr, "Out of memory trying to allocate token stream\n");
- exit(1);
- }
-
- pZ120Parser psr = Z120ParserNew(tstream);
- if (psr == NULL)
- {
- fprintf(stderr, "Out of memory trying to allocate parser\n");
- exit(1);
- }
-
- struct Z120Parser_textual_msc_file_return_struct langAST =
- psr->textual_msc_file(psr);
- if (psr->pParser->rec->state->errorCount > 0)
- {
- fprintf(stderr, "The parser returned %d errors, tree walking aborted.\n", psr->pParser->rec->state->errorCount);
- }
- else
- {
- walk(langAST.tree);
- }
-
- psr->free(psr); psr = NULL;
- tstream->free(tstream); tstream = NULL;
- lxr->free(lxr); lxr = NULL;
- input->close(input); input = NULL;
-
- return 0;
-}
-
-// end of file
Modified: trunk/src/data/Z120/z120.h
===================================================================
--- trunk/src/data/Z120/z120.h 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/data/Z120/z120.h 2009-03-14 18:25:33 UTC (rev 203)
@@ -22,7 +22,11 @@
#include "data/formatter.h"
#include "data/Z120/export.h"
-class SCZ120_EXPORT Z120 : public Formatter, public ExportFormatter
+class SCZ120_EXPORT Z120 : public Formatter
+#ifdef HAVE_ANTLR
+ , public ImportFormatter
+#endif
+ , public ExportFormatter
{
public:
//! file extension used to distinguish this format
@@ -33,6 +37,10 @@
virtual std::string get_description() const
{ return "Z.120 Textual Format"; }
+#ifdef HAVE_ANTLR
+ //! import MSC document
+ virtual MscPtr load_msc(const std::string &filename);
+#endif
//! export MSC document
virtual int save_msc(std::ostream& stream, const std::string &name, const std::vector<MscPtr>& msc);
Copied: trunk/src/data/Z120/z120_load.cpp (from rev 202, trunk/src/data/Z120/Z120.cpp)
===================================================================
--- trunk/src/data/Z120/z120_load.cpp (rev 0)
+++ trunk/src/data/Z120/z120_load.cpp 2009-03-14 18:25:33 UTC (rev 203)
@@ -0,0 +1,63 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2008-2009 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#include "z120.h"
+
+// Process "Z120.g" with ANTLR 3.1.1 to produce the following files.
+#include "Z120Lexer.h"
+#include "Z120Parser.h"
+
+MscPtr Z120::load_msc(const std::string &filename)
+{
+ pANTLR3_INPUT_STREAM input =
+ antlr3AsciiFileStreamNew((pANTLR3_UINT8)filename.c_str());
+ if (input == NULL || (int)input < 0)
+ {
+ print_report(RS_ERROR,
+ stringize() << "Cannot open file '" << filename << "'.");
+ return NULL;
+ }
+
+ pZ120Lexer lxr = Z120LexerNew(input);
+ if (lxr == NULL)
+ return NULL;
+
+ pANTLR3_COMMON_TOKEN_STREAM tstream =
+ antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lxr));
+ if (tstream == NULL)
+ return NULL;
+
+ pZ120Parser psr = Z120ParserNew(tstream);
+ if (psr == NULL)
+ return NULL;
+
+ Msc* my_msc = static_cast<Msc*>(psr->message_sequence_chart(psr));
+ MscPtr result = my_msc;
+ // my_msc is an extern "C" pointer to an object pointed by smart pointers
+ // the counter was increased in get_msc_fun() to avoid premature delete
+ intrusive_ptr_release(my_msc);
+
+ psr->free(psr); psr = NULL;
+ tstream->free(tstream); tstream = NULL;
+ lxr->free(lxr); lxr = NULL;
+ input->close(input); input = NULL;
+
+ return result;
+}
+
+// end of file
Property changes on: trunk/src/data/Z120/z120_load.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: trunk/src/data/engmann/engmann.cpp
===================================================================
--- trunk/src/data/engmann/engmann.cpp 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/data/engmann/engmann.cpp 2009-03-14 18:25:33 UTC (rev 203)
@@ -18,6 +18,7 @@
#include <string>
#include <iostream>
+#include <fstream>
#include <string.h>
#include "data/engmann/engmann.h"
@@ -137,7 +138,7 @@
return pos->second;
}
-MscPtr Engmann::load_msc(std::istream& stream)
+MscPtr Engmann::load_msc(const std::string &filename)
{
BMscPtr result = new BMsc();
@@ -149,6 +150,15 @@
static const Coordinate y_step = 7.5; // distance between messages [mm]
Coordinate current_y = 7.5;
+ std::ifstream stream;
+ stream.open(filename.c_str(), std::ifstream::in);
+ if(!stream.good())
+ {
+ print_report(RS_ERROR,
+ stringize() << "Cannot open file '" << filename << "'.");
+ return NULL;
+ }
+
while(stream.good())
{
TToken token = get_token(stream);
@@ -219,6 +229,8 @@
}
}
+ stream.close();
+
// set length of the instance lines
for(InstanceAreaMap::const_iterator pos = instances.begin();
pos != instances.end(); pos++)
Modified: trunk/src/data/engmann/engmann.h
===================================================================
--- trunk/src/data/engmann/engmann.h 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/data/engmann/engmann.h 2009-03-14 18:25:33 UTC (rev 203)
@@ -34,7 +34,7 @@
{ return "Engmann Message Chart"; }
//! import MSC document
- virtual MscPtr load_msc(std::istream& stream);
+ virtual MscPtr load_msc(const std::string &filename);
protected:
};
Modified: trunk/src/data/formatter.h
===================================================================
--- trunk/src/data/formatter.h 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/data/formatter.h 2009-03-14 18:25:33 UTC (rev 203)
@@ -22,13 +22,14 @@
#include <boost/shared_ptr.hpp>
#include "data/msc.h"
+#include "data/reporter.h"
#if defined(_MSC_VER)
// FIXME: to be removed once the Formatter has some implementation in a .cpp file
#pragma warning(disable: 4275)
#endif
-class Formatter
+class Formatter : public Reporter
{
public:
virtual ~Formatter() {}
@@ -45,7 +46,7 @@
{
public:
//! import MSC document
- virtual MscPtr load_msc(std::istream& stream) = 0;
+ virtual MscPtr load_msc(const std::string &filename) = 0;
};
typedef boost::shared_ptr<ImportFormatter> ImportFormatterPtr;
Added: trunk/src/data/reporter.h
===================================================================
--- trunk/src/data/reporter.h (rev 0)
+++ trunk/src/data/reporter.h 2009-03-14 18:25:33 UTC (rev 203)
@@ -0,0 +1,100 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2009 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#ifndef _REPORTER_H
+#define _REPORTER_H
+
+#include <sstream>
+
+enum TReportSeverity
+{
+ RS_REPORT = 0, //! progress reports
+ RS_NOTICE, //! operation succeeded
+ RS_WARNING, //! problem detected, but operation continues
+ RS_ERROR, //! error detected, operation failed
+ __RS_LAST
+};
+
+class ReportPrinter
+{
+public:
+ virtual ~ReportPrinter() {}
+
+ virtual int print(TReportSeverity severity, const std::string& message) = 0;
+};
+
+class StreamReportPrinter : public ReportPrinter
+{
+public:
+ StreamReportPrinter(std::ostream& stream)
+ : m_stream(stream) {}
+
+ virtual int print(TReportSeverity severity, const std::string& message)
+ {
+ m_stream << message << std::endl;
+ return 0;
+ }
+
+private:
+ std::ostream& m_stream;
+};
+
+class Reporter
+{
+public:
+ virtual ~Reporter() {}
+
+ void set_printer(ReportPrinter* printer)
+ { m_printer = printer; }
+
+ int print_report(TReportSeverity severity, const std::string& message)
+ { return m_printer ? m_printer->print(severity, message) : 1; }
+
+private:
+ ReportPrinter* m_printer;
+};
+
+//! Helper class to construct a message for Reporter::print()
+/*!
+ * reporter->print(stringize() << "value: " << number);
+ */
+template<typename C>
+struct basic_stringize
+{
+ template<typename T>
+ basic_stringize<C> & operator << (T const& t)
+ {
+ m_s << t;
+ return *this;
+ }
+
+ // note: must not return reference
+ operator const std::basic_string<C>() const
+ {
+ return m_s.str();
+ }
+
+private:
+ std::basic_stringstream<C> m_s;
+};
+
+typedef basic_stringize<char> stringize;
+
+#endif /* _REPORTER_H */
+
+// $Id$
Property changes on: trunk/src/data/reporter.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/view/visio/addon/dllmodule.rc 2009-03-14 18:25:33 UTC (rev 203)
@@ -72,8 +72,8 @@
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,2,0,0
- PRODUCTVERSION 0,2,0,0
+ FILEVERSION 0,2,4,0
+ PRODUCTVERSION 0,2,4,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
@@ -90,13 +90,13 @@
BEGIN
VALUE "CompanyName", "Masaryk University Brno"
VALUE "FileDescription", "Microsoft Visio add-on for design and verification of Message Sequence Charts (MSC)."
- VALUE "FileVersion", "0.2.0"
+ VALUE "FileVersion", "0.2.4"
VALUE "InternalName", "scstudio.vsl"
VALUE "LegalCopyright", "(c) Petr Gotthard. All rights reserved."
VALUE "OriginalFilename", "scstudio.vsl"
VALUE "PrivateBuild", "$Revision$"
VALUE "ProductName", "Sequence Chart Studio"
- VALUE "ProductVersion", "0.2.0"
+ VALUE "ProductVersion", "0.2.4"
END
END
BLOCK "VarFileInfo"
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/view/visio/addon/document.cpp 2009-03-14 18:25:33 UTC (rev 203)
@@ -40,7 +40,7 @@
m_vsoDocument = vsoDocument;
m_reportVisible = false;
- m_reportView = NULL;
+ m_reportView = new CReportView(this);
LoadModulesFromRegistry(HKEY_LOCAL_MACHINE);
LoadModulesFromRegistry(HKEY_CURRENT_USER);
@@ -180,6 +180,7 @@
for(Formatter **fpos = formatters; *fpos != NULL; fpos++)
{
boost::shared_ptr<Formatter> formatter(*fpos);
+ formatter->set_printer(m_reportView);
m_formatters.push_back(formatter);
}
// delete the array
@@ -354,9 +355,6 @@
VAORC CDocumentMonitor::OnMenuRun(Visio::IVApplicationPtr vsoApp)
{
- if(!m_reportVisible)
- ShowReportView(vsoApp);
-
// clear the verification report
m_reportView->Reset();
@@ -464,6 +462,9 @@
VAORC CDocumentMonitor::OnMenuImport(Visio::IVApplicationPtr vsoApp)
{
+ // clear the verification report
+ m_reportView->Reset();
+
std::string extension;
std::stringstream filter;
@@ -522,18 +523,7 @@
if(formatter == NULL)
continue;
- std::ifstream stream;
- stream.open(fileName, std::ios::in);
- if(!stream.good())
- {
- MessageBox(GetActiveWindow(),
- _T("Cannot import given file."), _T("Error"), MB_OK | MB_ICONEXCLAMATION);
- return VAORC_FAILURE;
- }
-
- ImportDocument(formatter, stream);
-
- stream.close();
+ ImportDocument(formatter, fileName);
return VAORC_SUCCESS;
}
@@ -544,6 +534,9 @@
VAORC CDocumentMonitor::OnMenuExport(Visio::IVApplicationPtr vsoApp)
{
+ // clear the verification report
+ m_reportView->Reset();
+
std::string extension;
std::stringstream filter;
@@ -624,9 +617,6 @@
VAORC CDocumentMonitor::OnMenuRepaint(Visio::IVApplicationPtr vsoApp)
{
- if(!m_reportVisible)
- ShowReportView(vsoApp);
-
// clear the verification report
m_reportView->Reset();
@@ -665,17 +655,17 @@
// Close() --> CReportView::OnFinalMessage() --> CDocumentMonitor::OnHideReportView()
m_reportWindow->Close();
else
- ShowReportView(vsoApp);
+ ShowReportView();
return VAORC_SUCCESS;
}
-void CDocumentMonitor::ShowReportView(Visio::IVApplicationPtr vsoApp)
+void CDocumentMonitor::ShowReportView()
{
- if (m_reportView == NULL)
- m_reportView = new CReportView(this);
+ if(m_reportVisible)
+ return; // already shown
- Visio::IVWindowPtr vsoWindow = vsoApp->GetActiveWindow();
+ Visio::IVWindowPtr vsoWindow = m_vsoApp->GetActiveWindow();
const int defWidth = 500;
const int defHeight = 150;
@@ -701,9 +691,9 @@
m_reportVisible = false;
}
-void CDocumentMonitor::ImportDocument(const ImportFormatterPtr& formatter, std::istream& stream)
+void CDocumentMonitor::ImportDocument(const ImportFormatterPtr& formatter, const std::string& filename)
{
- MscPtr drawing = formatter->load_msc(stream);
+ MscPtr drawing = formatter->load_msc(filename);
long scope_id = m_vsoApp->BeginUndoScope("Import");
@@ -742,12 +732,6 @@
void CDocumentMonitor::ExportActiveDocument(const ExportFormatterPtr& formatter, std::ostream& stream)
{
- if(!m_reportVisible)
- ShowReportView(m_vsoApp);
-
- // clear the verification report
- m_reportView->Reset();
-
CDrawingExtractor extractor(m_reportView);
std::vector<MscPtr> msc;
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/view/visio/addon/document.h 2009-03-14 18:25:33 UTC (rev 203)
@@ -46,10 +46,10 @@
VAORC OnMenuExport(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuRepaint(Visio::IVApplicationPtr vsoApp);
- void ShowReportView(Visio::IVApplicationPtr vsoApp);
+ void ShowReportView();
void OnHideReportView();
- void ImportDocument(const ImportFormatterPtr& formatter, std::istream& stream);
+ void ImportDocument(const ImportFormatterPtr& formatter, const std::string& filename);
void ExportActiveDocument(const ExportFormatterPtr& formatter, std::ostream& stream);
int DisplayDocument(const MscPtr& msc);
Modified: trunk/src/view/visio/addon/reportview.cpp
===================================================================
--- trunk/src/view/visio/addon/reportview.cpp 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/view/visio/addon/reportview.cpp 2009-03-14 18:25:33 UTC (rev 203)
@@ -59,8 +59,13 @@
void CReportView::Reset()
{
- // reset the view
- m_edit.SetTextEx(NULL);
+ // window is active
+ if(::IsWindow(m_edit.m_hWnd))
+ {
+ // reset the view
+ m_edit.SetTextEx(NULL);
+ }
+
// reset the internal data
memset(m_statistics, 0, sizeof(m_statistics));
m_references.clear();
@@ -85,8 +90,11 @@
return 0;
}
-int CReportView::__Print(TSeverity severity, const std::string& message, int hasLink)
+int CReportView::__Print(TReportSeverity severity, const std::string& message, int hasLink)
{
+ // display the report view
+ m_documentMonitor->ShowReportView();
+
static const char *rtfPrefix =
"{\\rtf1\\ansi"
"{\\colortbl;\\red255\\green0\\blue0;}"
@@ -104,7 +112,7 @@
// depending on severity, change the text style
switch(severity)
{
- case RS_NORMAL:
+ case RS_REPORT:
default:
sstr += message;
break;
@@ -147,7 +155,7 @@
return 0;
}
-int CReportView::Print(TSeverity severity, const std::string& message, const std::vector<_bstr_t>& shapelist)
+int CReportView::Print(TReportSeverity severity, const std::string& message, const std::vector<_bstr_t>& shapelist)
{
__Print(severity, message, !shapelist.empty());
@@ -159,7 +167,7 @@
return 0;
}
-int CReportView::Print(TSeverity severity, const std::string& message, const MscPtr& msc)
+int CReportView::Print(TReportSeverity severity, const std::string& message, const MscPtr& msc)
{
__Print(severity, message, msc != NULL);
@@ -171,6 +179,12 @@
return 0;
}
+int CReportView::print(TReportSeverity severity, const std::string& message)
+{
+ __Print(severity, message, false);
+ return 0;
+}
+
LRESULT CReportView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
LRESULT lRet = DefWindowProc(uMsg, wParam, lParam);
Modified: trunk/src/view/visio/addon/reportview.h
===================================================================
--- trunk/src/view/visio/addon/reportview.h 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/view/visio/addon/reportview.h 2009-03-14 18:25:33 UTC (rev 203)
@@ -24,10 +24,10 @@
#include <atlctrls.h>
#include <atlwin.h>
-#include <sstream>
#include <vector>
#include "data/msc.h"
+#include "data/reporter.h"
class CReportView;
class CDocumentMonitor;
@@ -56,32 +56,6 @@
CReportView *m_reporter;
};
-//! Helper class to construct a message for CReportView::Print()
-/*!
- * reporter->Print(stringize() << "string" << number);
- */
-template<typename C>
-struct basic_stringize
-{
- template<typename T>
- basic_stringize<C> & operator << (T const& t)
- {
- m_s << t;
- return *this;
- }
-
- // note: must not return reference
- operator const std::basic_string<C>() const
- {
- return m_s.str();
- }
-
-private:
- std::basic_stringstream<C> m_s;
-};
-
-typedef basic_stringize<char> stringize;
-
struct shapelist
{
shapelist & operator << (Visio::IVShapePtr shape)
@@ -101,26 +75,19 @@
std::vector<_bstr_t> m_v;
};
-enum TSeverity
+class CReportView : public ReportPrinter,
+ public ATL::CWindowImpl<CReportView, ATL::CWindow, ATL::CNullTraits>
{
- RS_NORMAL = 0, //! black
- RS_NOTICE, //! black bold
- RS_WARNING, //! red
- RS_ERROR, //! red bold
- __RS_LAST
-};
-
-class CReportView
- : public ATL::CWindowImpl<CReportView, ATL::CWindow, ATL::CNullTraits>
-{
public:
CReportView(CDocumentMonitor *monitor);
void Reset();
- int Print(TSeverity severity, const std::string& message,
+ int Print(TReportSeverity severity, const std::string& message,
const std::vector<_bstr_t>& shapelist = std::vector<_bstr_t>());
- int Print(TSeverity severity, const std::string& message, const MscPtr& msc);
+ int Print(TReportSeverity severity, const std::string& message, const MscPtr& msc);
+ virtual int print(TReportSeverity severity, const std::string& message);
+
protected:
BEGIN_MSG_MAP(CReportView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
@@ -147,7 +114,7 @@
int m_statistics[__RS_LAST];
- int __Print(TSeverity severity, const std::string& message, int hasLink);
+ int __Print(TReportSeverity severity, const std::string& message, int hasLink);
struct Reference
{
Modified: trunk/src/view/visio/scstudio.nsi
===================================================================
--- trunk/src/view/visio/scstudio.nsi 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/src/view/visio/scstudio.nsi 2009-03-14 18:25:33 UTC (rev 203)
@@ -21,7 +21,7 @@
; -- General ---------------------------
-!define VERSION "0.2.2"
+!define VERSION "0.2.4"
Name "Sequence Chart Studio"
OutFile "scstudio-setup-${VERSION}.exe"
Modified: trunk/tests/CMakeLists.txt
===================================================================
--- trunk/tests/CMakeLists.txt 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/tests/CMakeLists.txt 2009-03-14 18:25:33 UTC (rev 203)
@@ -57,4 +57,14 @@
)
ADD_TEST(engmann engmann_test engmann_test01.cfi)
+IF(ANTLR_FOUND)
+ADD_DEFINITIONS(-DHAVE_ANTLR)
+ADD_EXECUTABLE(z120_test
+ z120_test.cpp
+)
+TARGET_LINK_LIBRARIES(z120_test
+ scZ120
+)
+ENDIF(ANTLR_FOUND)
+
# $Id$
Modified: trunk/tests/engmann_test.cpp
===================================================================
--- trunk/tests/engmann_test.cpp 2009-03-12 19:41:00 UTC (rev 202)
+++ trunk/tests/engmann_test.cpp 2009-03-14 18:25:33 UTC (rev 203)
@@ -17,7 +17,6 @@
*/
#include <iostream>
-#include <fstream>
#include "data/engmann/engmann.h"
#include "data/Z120/z120.h"
@@ -31,19 +30,12 @@
Engmann engmann;
- std::ifstream stream;
- stream.open(argv[1], std::ifstream::in);
- if(!stream.good())
- {
- std::cerr << "Cannot open file '" << argv[1] << "'" << std::endl;
- return 1;
- }
+ StreamReportPrinter printer(std::cerr);
+ engmann.set_printer(&printer);
std::vector<MscPtr> msc;
- msc.push_back(engmann.load_msc(stream));
+ msc.push_back(engmann.load_msc(argv[1]));
- stream.close();
-
Z120 z120;
z120.save_msc(std::cout, argv[1], msc);
Added: trunk/tests/z120_test.cpp
===================================================================
--- trunk/tests/z120_test.cpp (rev 0)
+++ trunk/tests/z120_test.cpp 2009-03-14 18:25:33 UTC (rev 203)
@@ -0,0 +1,43 @@
+/*
+ * scstudio - Sequence Chart Studio
+ * http://scstudio.sourceforge.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Copyright (c) 2009 Petr Gotthard <pet...@ce...>
+ *
+ * $Id$
+ */
+
+#include <iostream>
+#include "data/Z120/z120.h"
+
+int main(int argc, char** argv)
+{
+ if(argc < 2)
+ {
+ std::cerr << "Usage: " << argv[0] << " <filename>" << std::endl;
+ return 1;
+ }
+
+ Z120 z120;
+
+ StreamReportPrinter printer(std::cerr);
+ z120.set_printer(&printer);
+
+ std::vector<MscPtr> msc;
+ msc.push_back(z120.load_msc(argv[1]));
+
+ z120.save_msc(std::cout, argv[1], msc);
+
+ return 0;
+}
+
+// $Id$
Property changes on: trunk/tests/z120_test.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|