primatologist-gpl 6.0.4
trace.h
Go to the documentation of this file.
1/* Copyright (C) 2000-2013 CEA
2 *
3 * This software and supporting documentation were developed by
4 * bioPICSEL
5 * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6 * 18, route du Panorama
7 * 92265 Fontenay-aux-Roses
8 * France
9 */
10
11#ifndef PRIMATOLOGIST_UTILITY_TRACE_H
12#define PRIMATOLOGIST_UTILITY_TRACE_H
13
14//--- cartobase --------------------------------------------------------------
15#include <cartobase/type/string_conversion.h>
16//--- std --------------------------------------------------------------------
17#include <iomanip>
18#include <iostream>
19#include <map>
20#include <string>
21#include <vector>
22//----------------------------------------------------------------------------
23
24//----------------------------------------------------------------------------
25// trace
26//----------------------------------------------------------------------------
27
28namespace aims {
29
30 // Print std::vector
31 template <typename T>
32 std::ostream & operator<< ( std::ostream & out, const std::vector<T> & v )
33 {
34 typename std::vector<T>::const_iterator i = v.begin();
35 out << "( " << std::flush;
36 for( ; i != v.end(); ++i )
37 out << *i << ", " << std::flush;
38 out <<"\b\b )" << std::flush;
39 return out;
40 }
41
42 void message( const std::string & message, bool header, bool doit = true )
43 {
44 if( doit )
45 {
46 if( header )
47 {
48 int lfill = ( 25 - message.size() ) / 2;
49 if( lfill < 0 ) lfill = 0;
50 std::cout << std::endl;
51 std::cout << std::string( 25, '-' ) << std::endl;
52 std::cout << std::setw(25)
53 << std::left
54 << std::string( lfill, ' ' ) + message
55 << std::endl;
56 std::cout << std::string( 25, '-' ) << std::endl;
57 }
58 else
59 std::cout << message << std::endl;
60 }
61 }
62
63 void setOutColor( const std::string & color = "black", bool light = false );
65
66} // namespace aims
67
68#endif // PRIMATOLOGIST_UTILITY_TRACE_H
std::ostream & operator<<(std::ostream &out, const std::vector< T > &v)
Definition trace.h:32
void message(const std::string &message, bool header, bool doit=true)
Definition trace.h:42
void setOutColor(const std::string &color="black", bool light=false)
void resetOutColor()