/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/calibUtil/calibUtil-00-00-43/src/test/test_meta.cxx File Reference

#include <string>
#include <iostream>
#include "calibUtil/Metadata.h"

Go to the source code of this file.

Functions

void gotIt (unsigned int ser, const std::string &dataFmt, const std::string &fmtVersion, const std::string &dataIdent)
calibUtil::Metadata::eRet lookup (const std::string &ctype, const facilities::Timestamp &ts, unsigned int levelMask, const std::string &inst)
calibUtil::Metadata::eRet soonest (const std::string &ctype, const facilities::Timestamp &update_start, const facilities::Timestamp &update_end, unsigned int levelMask, const std::string &inst, const std::string &flavor=std::string("VANILLA"))
void compatibility ()
int main (int, char **)


Detailed Description

Sample program to add record(s) to the MySQL database. For now user only gets to specify instrument type location of file validity start and end times

Ultimately need something more flexible and easier to use.

Definition in file test_meta.cxx.


Function Documentation

void compatibility (  ) 

void gotIt ( unsigned int  ser,
const std::string dataFmt,
const std::string fmtVersion,
const std::string dataIdent 
)

calibUtil::Metadata::eRet lookup ( const std::string ctype,
const facilities::Timestamp ts,
unsigned int  levelMask,
const std::string inst 
)

Definition at line 113 of file test_meta.cxx.

References facilities::Timestamp::getString(), gotIt(), meta, and deljobs::string.

Referenced by main().

00116                                                         {
00117   using calibUtil::Metadata;
00118   unsigned int ser;
00119   
00120   std::cout << std::endl;
00121   std::cout << "lookup called with input " << std::endl;
00122   std::cout << "   calibType = " <<  ctype <<std::endl;
00123   std::cout << "   timestamp = " << ts.getString() << std::endl;
00124   std::cout << "   levelMask = " << levelMask << std::endl;
00125   std::cout << "   instrument = " << inst << std::endl;
00126 
00127   Metadata       meta("*", "*", "calib_test");
00128   Metadata::eRet ret = meta.findBest(&ser, ctype, ts, levelMask, inst);
00129 
00130   if (ret != Metadata::RETOk) {
00131     std::cout << "findBest failed with status" << (int) ret << std::endl;
00132   }
00133   else if (!ser) {
00134     std::cout << "Query succeeded; no rows found." << std::endl;
00135   }
00136   else {
00137     std::string  fmtVersion;
00138     std::string dataFmt;
00139     std::string dataIdent;
00140 
00141     ret = meta.getReadInfo(ser, dataFmt, fmtVersion, dataIdent);
00142     
00143     if (ret == Metadata::RETOk) { 
00144       gotIt(ser, dataFmt, fmtVersion, dataIdent);
00145     }
00146 
00147     else {
00148       std::cout << "Failed reading info for record #" << ser;
00149       std::cout << " with code " << (int) ret << std::endl;
00150     }
00151   }
00152 
00153   return ret;
00154 }

int main ( int  ,
char **   
)

Definition at line 28 of file test_meta.cxx.

References lookup(), and soonest().

00028                       {
00029   using calibUtil::Metadata;
00030   using facilities::Timestamp;
00031 
00032   // just for exercise..
00033   //  compatibility();
00034 
00035   Timestamp t_ok("2001-11-10 08:00");
00036   Timestamp t_none("2000-09-08 10:00");
00037   Timestamp t_late("2010-12-19");
00038 
00039   Metadata::eRet ret = lookup("TKR_DeadChan", t_ok, 
00040                               Metadata::LEVELDev | Metadata::LEVELTest, 
00041                               "BTEM");
00042 
00043   ret = soonest("TKR_DeadChan", t_none, t_late, 
00044                               Metadata::LEVELDev | Metadata::LEVELTest, 
00045                               "BTEM");
00046 
00047   ret = soonest("TKR_DeadChan", t_none, t_late, 
00048                               Metadata::LEVELDev | Metadata::LEVELTest, 
00049                               "BTEM", "invisible");
00050 
00051   ret = lookup("TKR_DeadChan", t_ok, 
00052                Metadata::LEVELProd | Metadata::LEVELDev, "BTEM");
00053 
00054   ret = lookup("ACD_Eff", t_ok, 
00055                Metadata::LEVELProd | Metadata::LEVELDev, 
00056                "BTEM");
00057   ret = lookup("TKR_HotChan", t_none, Metadata::LEVELDev,
00058                "BTEM");
00059 
00060   // Try to insert a record
00061   /*
00062   ret = meta.openRecord(Metadata::INSTEm, Metadata::CTYPE_TKRHotChan,
00063                    Metadata::FMTXml, "1.0",
00064                    "$CALIBUTILROOT/xml/test/testHot-2002-05-02.xml",
00065                    Metadata::CMPLOk);
00066   if (ret) {
00067     std::cerr << "openRecord failed with return value " << (int) ret 
00068               << std::endl;
00069     return ret;
00070   }
00071   ret = 
00072     meta.addInputDesc("This is the standard invented hot strips file");
00073   if (ret) {
00074     std::cerr << "Bad return from addInputDesc: " << (int) ret << std::endl;
00075     return ret;
00076   }
00077   ret = meta.addNotes("Fake record, added from test_meta");
00078   if (ret) {
00079     std::cerr << "Bad return from addNotes: " << (int) ret << std::endl;
00080     return ret;
00081   }
00082   ret = meta.addValidInterval(Timestamp(2000, 8, 2), Timestamp());
00083   if (ret) {
00084     std::cerr << "Bad return from addValidInterval: " << (int) ret 
00085               << std::endl;
00086     return ret;
00087   }
00088   unsigned int newSerial;
00089   ret = meta.insertRecord(&newSerial);
00090   if (ret) {
00091     std::cerr << "Bad return from insertRecord: " << (int) ret << std::endl;
00092   }
00093   else {
00094     std::cout << "Successfully inserted new record, serial number " 
00095               << newSerial << std::endl;
00096   }
00097   */
00098   return(ret);
00099 
00100 }

calibUtil::Metadata::eRet soonest ( const std::string ctype,
const facilities::Timestamp update_start,
const facilities::Timestamp update_end,
unsigned int  levelMask,
const std::string inst,
const std::string flavor = std::string("VANILLA") 
)

Definition at line 156 of file test_meta.cxx.

References facilities::Timestamp::getString(), gotIt(), meta, and deljobs::string.

Referenced by main().

00161                                                            {
00162   using calibUtil::Metadata;
00163   unsigned int ser;
00164 
00165   
00166   std::cout << std::endl;
00167   std::cout << "soonest called with input " << std::endl;
00168   std::cout << "   calibType = " <<  ctype <<std::endl;
00169   std::cout << "   update_start = " << update_start.getString() << std::endl;
00170   std::cout << "   update_end = " << update_end.getString() << std::endl;
00171   std::cout << "   levelMask = " << levelMask << std::endl;
00172   std::cout << "   instrument = " << inst << std::endl;
00173   std::cout << "   flavor     = " << flavor << std::endl;
00174 
00175   Metadata       meta("*", "*", "calib_test");
00176   Metadata::eRet ret = meta.findSoonAfter(&ser, ctype, &update_start, 
00177                                           &update_end, levelMask, inst, flavor);
00178 
00179   if (ret != Metadata::RETOk) {
00180     std::cout << "findSoonAfter failed with status" << (int) ret << std::endl;
00181   }
00182   else if (!ser) {
00183     std::cout << "Query succeeded; no rows found." << std::endl;
00184   }
00185   else {
00186     std::string  fmtVersion;
00187     std::string dataFmt;
00188     std::string dataIdent;
00189 
00190     ret = meta.getReadInfo(ser, dataFmt, fmtVersion, dataIdent);
00191     
00192     if (ret == Metadata::RETOk) { 
00193       gotIt(ser, dataFmt, fmtVersion, dataIdent);
00194     }
00195 
00196     else {
00197       std::cout << "Failed reading info for record #" << ser;
00198       std::cout << " with code " << (int) ret << std::endl;
00199     }
00200   }
00201 
00202   return ret;
00203 }


Generated on Tue Nov 29 23:14:52 2016 for BOSS_7.0.2 by  doxygen 1.4.7