From 02a79e28695d8c902ca7cdb844bd2c156fe58b9f Mon Sep 17 00:00:00 2001 From: Francois Bleibel <fbleibel@gmail.com> Date: Fri, 24 Sep 2010 11:19:41 +0900 Subject: [PATCH] Added more exception catch codes in interpreter. Should now link correctly with boost libraries. Small debug output changes. --- CMakeLists.txt | 2 +- include/dynamic-graph/signal.h | 2 +- src/CMakeLists.txt | 5 ++++- src/dgraph/interpreter.cpp | 17 +++++++++-------- src/traces/tracer-real-time.cpp | 2 ++ tools/test_shell.cpp | 8 ++++---- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bffb99c..fbe7a20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ OPTION(GENERATE_DOC "Generate html documentation" ON) # --- BOOST --------------------------------------------------- SET(Boost_THREAD_FOUND 0) -FIND_PACKAGE(Boost COMPONENTS thread) +FIND_PACKAGE(Boost COMPONENTS thread REQUIRED) IF(Boost_THREAD_FOUND) #MESSAGE(STATUS "Boost_THREAD_LIBRARY:" ${Boost_THREAD_LIBRARY}) #MESSAGE(STATUS "Boost_THREAD_LIBRARY_RELEASE:" ${Boost_THREAD_LIBRARY_RELEASE}) diff --git a/include/dynamic-graph/signal.h b/include/dynamic-graph/signal.h index 9c0e3e9..2928aea 100644 --- a/include/dynamic-graph/signal.h +++ b/include/dynamic-graph/signal.h @@ -124,7 +124,7 @@ protected: public: - virtual void checkCompatibility( void ) { throw Tcopy; } + virtual void checkCompatibility( void ) { throw Tcopy; } private: const T& setTcopy( const T& t ); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 35eae48..77f7d96 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,6 +49,8 @@ IF (UNIX) TARGET_LINK_LIBRARIES(${LIBRARY_NAME} dl pthread) ENDIF (UNIX) +TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES}) + INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib) @@ -72,7 +74,8 @@ ADD_LIBRARY(${plugin} "${plugin_file}.cpp") TARGET_LINK_LIBRARIES(${plugin} - ${PROJECT_NAME} ${${plugin}_dependancy}) + ${PROJECT_NAME} ${${plugin}_dependancy} + ${Boost_LIBRARIES}) SET_TARGET_PROPERTIES(${plugin} PROPERTIES diff --git a/src/dgraph/interpreter.cpp b/src/dgraph/interpreter.cpp index 9236029..6c0dc91 100644 --- a/src/dgraph/interpreter.cpp +++ b/src/dgraph/interpreter.cpp @@ -64,13 +64,14 @@ registerFunction( const string& funname, if( funkey != functionMap.end() ) // key does exist { if( initDone ) - { - dgDEBUG(15) << "!! Another function already defined with the same name. " - << "Funname is" <<funname.c_str() << endl; - } - throw ExceptionFactory( ExceptionFactory::FUNCTION_CONFLICT, - "Another function already defined with the same name. ", - "Funname is <%s>.",funname.c_str() ); + { + dgDEBUG(15) << "!! Another function already defined with the same name. Overloading " + << "Funname is" <<funname.c_str() << endl; + throw ExceptionFactory( ExceptionFactory::FUNCTION_CONFLICT, + "Another function already defined with the same name. ", + "Funname is <%s>.",funname.c_str() ); + + } } else { @@ -475,7 +476,7 @@ shell( std::istream& sin, std::ostream& sout, const std::string& promptUser ) istringstream args (cmdArgs); try{ cmd(cmdLine,args,sout); } - catch( ExceptionAbstract& e ) { dgDEBUG(1) << e; throw e; } + catch( exception& e ) { dgDEBUG(1) << e.what(); throw e; } catch(...) { dgDEBUG(1) << "!! unknow!." <<endl; throw; } } } diff --git a/src/traces/tracer-real-time.cpp b/src/traces/tracer-real-time.cpp index 8c876b0..718d118 100644 --- a/src/traces/tracer-real-time.cpp +++ b/src/traces/tracer-real-time.cpp @@ -131,7 +131,9 @@ openFile( const SignalBase<int> & sig, dgDEBUG(5) << "Sig <"<<sig.getName() << ">: new file "<< filename << endl; std::ofstream * newfile = new std::ofstream( filename.c_str() ); + dgDEBUG(5) << "Newfile:" << (void*) newfile << endl; hardFiles.push_back( newfile ); + dgDEBUG(5) << "Creating Outstringstream" << endl; //std::stringstream * newbuffer = new std::stringstream(); OutStringStream * newbuffer = new OutStringStream(); // std::stringstream(); diff --git a/tools/test_shell.cpp b/tools/test_shell.cpp index 9e6a8ea..0caf832 100644 --- a/tools/test_shell.cpp +++ b/tools/test_shell.cpp @@ -51,9 +51,9 @@ int main( int argc,char** argv ) g_shell.cmd( "run",script,cout ); } } - catch( ExceptionAbstract& e ) + catch( exception& e ) { - cout << "!! In file <" << argv[fileIdx] << "> : " << e <<endl; + cout << "!! In file <" << argv[fileIdx] << "> : " << e.what() <<endl; } catch ( const char* str ) { cout << "!! In file <" << argv[fileIdx] << "> : " @@ -70,9 +70,9 @@ int main( int argc,char** argv ) dgDEBUG(5) << "Shell over." << endl; if( cin.eof() ) break; } - catch( ExceptionAbstract& e ) + catch( exception& e ) { - cout << "!! " << e <<endl; + cout << "!! " << e.what() <<endl; } catch( ... ){ dgDEBUG(5) << "!! Unknown! " <<endl ; } } -- GitLab