diff --git a/crlcore/CMakeLists.txt b/crlcore/CMakeLists.txt index 0229c112..8f4bf21d 100644 --- a/crlcore/CMakeLists.txt +++ b/crlcore/CMakeLists.txt @@ -11,15 +11,6 @@ ENDIF(COMMAND CMAKE_POLICY) # This macro has to be included in all the tools CMakeLists.txt as it's # the sole means of localizing other tools/projects. MACRO(SETUP_PROJECT_PATHS project) - IF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") ) - MESSAGE("-- ${project}_USER_TOP is set to $ENV{${project}_USER_TOP}") - SET(PROJECT_MODULE_PATH "$ENV{${project}_USER_TOP}/share/cmake_modules/") - LIST(FIND CMAKE_MODULE_PATH "${PROJECT_MODULE_PATH}" DIR_INDEX) - IF( DIR_INDEX LESS 0) - LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_MODULE_PATH}") - ENDIF( DIR_INDEX LESS 0) - ENDIF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") ) - IF( NOT("$ENV{${project}_TOP}" STREQUAL "") ) MESSAGE("-- ${project}_TOP is set to $ENV{${project}_TOP}") SET(PROJECT_MODULE_PATH "$ENV{${project}_TOP}/share/cmake_modules/") @@ -28,6 +19,15 @@ MACRO(SETUP_PROJECT_PATHS project) LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_MODULE_PATH}") ENDIF( DIR_INDEX LESS 0) ENDIF( NOT("$ENV{${project}_TOP}" STREQUAL "") ) + + IF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") ) + MESSAGE("-- ${project}_USER_TOP is set to $ENV{${project}_USER_TOP}") + SET(PROJECT_MODULE_PATH "$ENV{${project}_USER_TOP}/share/cmake_modules/") + LIST(FIND CMAKE_MODULE_PATH "${PROJECT_MODULE_PATH}" DIR_INDEX) + IF( DIR_INDEX LESS 0) + LIST(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_MODULE_PATH}") + ENDIF( DIR_INDEX LESS 0) + ENDIF( NOT("$ENV{${project}_USER_TOP}" STREQUAL "") ) ENDMACRO(SETUP_PROJECT_PATHS project) SETUP_PROJECT_PATHS(IO) diff --git a/crlcore/src/ccore/Utilities.cpp b/crlcore/src/ccore/Utilities.cpp index 4dbc886e..a69774bb 100644 --- a/crlcore/src/ccore/Utilities.cpp +++ b/crlcore/src/ccore/Utilities.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -27,10 +27,12 @@ #include #include #include +#include #include "crlcore/Utilities.h" +int tty::_width = 80; bool tty::_enabled = true; unsigned int mstream::_activeMask = mstream::Verbose0; @@ -40,6 +42,54 @@ mstream cmess2 ( mstream::Verbose2, std::cout ); mstream cinfo ( mstream::Info , std::cout ); +// ------------------------------------------------------------------- +// Class : "::Dots". + + +Dots::Dots ( const std::string& left, const std::string& right ) : _left(left), _right(right) { } + + +Dots Dots::asPercentage ( const std::string& left, float value ) +{ + std::ostringstream right; + right << std::setprecision(3) << value << "%"; + return Dots(left,right.str()); +} + + +Dots Dots::asUInt ( const std::string& left, unsigned int value ) +{ std::ostringstream right; right << value; return Dots(left,right.str()); } + + +Dots Dots::asULong ( const std::string& left, unsigned long value ) +{ std::ostringstream right; right << value; return Dots(left,right.str()); } + + +Dots Dots::asSizet ( const std::string& left, size_t value ) +{ std::ostringstream right; right << value; return Dots(left,right.str()); } + + +Dots Dots::asDouble ( const std::string& left, double value ) +{ std::ostringstream right; right << value; return Dots(left,right.str()); } + + +Dots Dots::asIdentifier ( const std::string& left, const std::string& value ) +{ std::ostringstream right; right << "<" << value << ">"; return Dots(left,right.str()); } + + +Dots Dots::asString ( const std::string& left, const std::string& value ) +{ return Dots(left,value); } + + +std::ostream& operator<< ( std::ostream& out, const Dots& dots ) +{ + int count = tty::getWidth() - 2 - dots._left.length() - dots._right.length(); + out << dots._left << " "; while ( count-- > 0 ) out << "."; out << " " << dots._right; + + return out; +} + + namespace CRL { diff --git a/crlcore/src/ccore/crlcore/Utilities.h b/crlcore/src/ccore/crlcore/Utilities.h index c49cd879..11c0d738 100644 --- a/crlcore/src/ccore/crlcore/Utilities.h +++ b/crlcore/src/ccore/crlcore/Utilities.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -178,6 +178,8 @@ class tty { , TypeMask = 0xF0 }; public: + inline static void setWidth ( int ); + inline static int getWidth (); inline static void enable (); inline static void disable (); inline static bool enabled (); @@ -202,9 +204,11 @@ class tty { private: static bool _enabled; static const char* _intensity[4]; + static int _width; }; - +inline void tty::setWidth ( int width ) { _width=width; } +inline int tty::getWidth () { return _width; } inline void tty::enable () { _enabled=true; } inline void tty::disable () { _enabled=false; } inline bool tty::enabled () { return _enabled; } @@ -327,13 +331,36 @@ inline std::string tty::bgcolor ( unsigned int mask ) MSTREAM_PR_SUPPORT(std::string); - // --------------------------------------------------------------- - // Shared objects. +// ------------------------------------------------------------------- +// Shared objects. - extern mstream cmess0; - extern mstream cmess1; - extern mstream cmess2; - extern mstream cinfo; + +extern mstream cmess0; +extern mstream cmess1; +extern mstream cmess2; +extern mstream cinfo; + + +// ------------------------------------------------------------------- +// Class : "::Dots". + + +class Dots { + public: + static Dots asPercentage ( const std::string& left, float ); + static Dots asUInt ( const std::string& left, unsigned int ); + static Dots asULong ( const std::string& left, unsigned long ); + static Dots asSizet ( const std::string& left, size_t ); + static Dots asDouble ( const std::string& left, double ); + static Dots asIdentifier ( const std::string& left, const std::string& ); + static Dots asString ( const std::string& left, const std::string& ); + private: + Dots ( const std::string& left, const std::string& right ); + friend std::ostream& operator<< ( std::ostream&, const Dots& ); + private: + const std::string _left; + const std::string _right; +}; # endif diff --git a/crlcore/src/cyclop/CyclopMain.cpp b/crlcore/src/cyclop/CyclopMain.cpp index 2e8f3890..1080b3b0 100644 --- a/crlcore/src/cyclop/CyclopMain.cpp +++ b/crlcore/src/cyclop/CyclopMain.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -202,10 +202,11 @@ int main ( int argc, char *argv[] ) // cerr << "Selecting: " << occurrence << endl; // } // } -// if ( cell && cell->getName() == "inv_x1" ) { -// Box box = cell->getAbutmentBox(); -// DemoGo::create ( cell, box.inflate(DbU::lambda(2)) ); -// } + if ( cell && cell->getName() == "inv_x1" ) { + // Box box = cell->getAbutmentBox(); + // DemoGo::create ( cell, box.inflate(DbU::lambda(2)) ); + Reference::create ( cell, "Label", DbU::lambda(0.0), DbU::lambda(0.0), Reference::Label ); + } dbo_ptr cyclop ( Cyclop::create() ); cmess1 << cyclop->getBanner() << endl;; @@ -218,6 +219,10 @@ int main ( int argc, char *argv[] ) returnCode = qa->exec(); } } + catch ( poptions::error& e ) { + cerr << "[ERROR] " << e.what() << endl; + exit ( 1 ); + } catch ( Error& e ) { cerr << e.what() << endl; exit ( 1 );