[go: up one dir, main page]

Menu

[r999]: / mia2 / mia / core / history.cc  Maximize  Restore  History

Download this file

103 lines (83 with data), 2.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
/* -*- mona-c++ -*-
*
* Copyright (c) Leipzig, Madrid 2004 - 2009
* Max-Planck-Institute for Human Cognitive and Brain Science
* Max-Planck-Institute for Evolutionary Anthropology
* BIT, ETSI Telecomunicacion, UPM
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 PUcRPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
// $Id: miaHistory.cc 937 2006-07-11 11:56:52Z write1 $
#include <miaconfig.h>
#include <ctime>
#include <sstream>
#include <config.h>
#include <mia/core/history.hh>
#include <mia/core/cmdlineparser.hh>
using namespace std;
NS_MIA_BEGIN
char const *get_revision();
void CHistory::append(const string& me, const string& version, const CCmdOptionList& options)
{
CHistoryRecord record = options.get_values();
record["+PROGRAM"] = me;
record["+VERSION"] = version;
record["+USER"] = string(getenv("USER"));
record["+LIBMIA_VERSION"] = PACKAGE_VERSION;
record["+LIBMIA_REVISION"] = get_revision();
time_t t = time(NULL);
char *time_str = ctime(&t);
char *help = time_str;
while (*help) {
if (*help == ':')
*help = '.';
if (*help == ' ')
*help = '_';
if (*help == '\n')
*help = '_';
++help;
}
if (!options.get_remaining().empty()) {
stringstream extra_str;
for (vector<const char *>::const_iterator i = options.get_remaining().begin();
i != options.get_remaining().end(); ++i)
extra_str << *i << " ";
record["EXTRA"] = extra_str.str();
}
push_back(CHistoryEntry(time_str, record));
}
string CHistory::as_string()const
{
CHistory::const_iterator e = end();
stringstream result;
for (CHistory::const_iterator i = begin(); i != e; ++i){
result << i->first << ":";
CHistoryRecord::const_iterator ke = i->second.end();
for (CHistoryRecord::const_iterator k = i->second.begin(); k != ke; ++k) {
result <<" "<< k->first << " : " << k->second << endl;
}
}
return result.str();
}
CHistory::CHistory()
{
}
CHistory& CHistory::instance()
{
static CHistory object;
return object;
}
NS_MIA_END