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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
static const char *RcsId = "$Id: dbapi_history.cpp 27410 2015-01-27 05:46:17Z taurel $\n$Name$";
//
// dbapi_history.cpp - C++ source code file for TANGO dbapi class DbHistory
//
// programmer - JL Pons (pons@esrf.fr)
//
// original - Feb 2007
//
// Copyright (C) : 2007,2008,2009,2010,2011,2012,2013,2014,2015
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This file is part of Tango.
//
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango 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.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Tango. If not, see <http://www.gnu.org/licenses/>.
//
// $Log$
// Revision 3.6 2010/09/09 13:43:38 taurel
// - Add year 2010 in Copyright notice
//
// Revision 3.5 2009/01/21 12:45:15 taurel
// - Change CopyRights for 2009
//
// Revision 3.4 2008/10/06 15:02:17 taurel
// - Changed the licensing info from GPL to LGPL
//
// Revision 3.3 2008/10/02 16:09:25 taurel
// - Add some licensing information in each files...
//
// Revision 3.2 2008/03/11 14:36:44 taurel
// - Apply patches from Frederic Picca about compilation with gcc 4.2
//
// Revision 3.1 2007/04/30 14:05:47 jlpons
// Added new commands to the database client interface.
//
//
//
#if HAVE_CONFIG_H
#include <ac_config.h>
#endif
#include <tango.h>
using namespace CORBA;
namespace Tango
{
//-----------------------------------------------------------------------------
//
// DbHistory::DbHistory() - Constructs a property
//
//-----------------------------------------------------------------------------
DbHistory::DbHistory(string _propname,string _date,vector<string> &svalues) {
propname = _propname;
date = format_mysql_date(_date);
deleted = (svalues.size()==0);
make_db_datum(svalues);
}
//-----------------------------------------------------------------------------
//
// DbHistory::DbHistory() - Constructs an attribute property.
//
//-----------------------------------------------------------------------------
DbHistory::DbHistory(string _propname,string _attname,string _date,vector<string> &svalues) {
propname = _propname;
attname = _attname;
date = format_mysql_date(_date);
deleted = (svalues.size()==0);
make_db_datum(svalues);
}
//-----------------------------------------------------------------------------
//
// DbHistory::get_name() - Returns property name.
//
//-----------------------------------------------------------------------------
string DbHistory::get_name() {
return propname;
}
//-----------------------------------------------------------------------------
//
// DbHistory::get_attribute_name() - Returns attribute name.
// Used when retrieving attribute property.
//
//-----------------------------------------------------------------------------
string DbHistory::get_attribute_name() {
return attname;
}
//-----------------------------------------------------------------------------
//
// DbHistory::get_date() - Returns the update date.
//
//-----------------------------------------------------------------------------
string DbHistory::get_date() {
return date;
}
//-----------------------------------------------------------------------------
//
// DbHistory::get_value() - Returns the value.
//
//-----------------------------------------------------------------------------
DbDatum DbHistory::get_value() {
return value;
}
//-----------------------------------------------------------------------------
//
// DbHistory::is_deleted() - Return true if the property is deleted.
//
//-----------------------------------------------------------------------------
bool DbHistory::is_deleted() {
return deleted;
}
//-----------------------------------------------------------------------------
//
// DbHistory::format_mysql_date() - Format mysql date using format
// DD/MM/YYYY hh:mm:ss
//
//-----------------------------------------------------------------------------
string DbHistory::format_mysql_date(string _date) {
// Handle MySQL date formating
if( _date.find("-")!=string::npos )
return _date.substr(8,2) + "/" + _date.substr(5,2) + "/" + _date.substr(0,4) + " " +
_date.substr(11,2) + ":" + _date.substr(14,2) + ":" + _date.substr(17,2);
else
return _date.substr(6,2) + "/" + _date.substr(4,2) + "/" + _date.substr(0,4) + " " +
_date.substr(8,2) + ":" + _date.substr(10,2) + ":" + _date.substr(12,2);
}
//-----------------------------------------------------------------------------
//
// DbHistory::make_db_datum() - Build the value as DbDatum
//
//-----------------------------------------------------------------------------
void DbHistory::make_db_datum(vector<string> &values) {
value.name = propname;
value.value_string.resize(values.size());
for (unsigned int i=0; i<values.size(); i++)
value.value_string[i] = values[i];
}
}
|