LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
tagConditionsTableInDB.cc File Reference
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <getopt.h>
#include <string>
#include "nutools/IFDatabase/Table.h"

Go to the source code of this file.

Functions

void PrintUsage ()
 
bool ParseCLArgs (int argc, char *argv[])
 
int main (int argc, char *argv[])
 

Variables

std::string dbHost = ""
 
std::string dbName = ""
 
std::string dbPort = ""
 
std::string tableName = ""
 
std::string detectorName = ""
 
std::string tagName = ""
 
bool override =false
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 118 of file tagConditionsTableInDB.cc.

References dbHost, dbName, dbPort, detectorName, e, nutools::dbi::kConditionsTable, ParseCLArgs(), tableName, nutools::dbi::Table::Tag(), and tagName.

119 {
120  ParseCLArgs(argc, argv);
121 
122  nutools::dbi::Table* dbt;
123  try {
127  }
128  catch (std::runtime_error& e) {
129  std::cerr << e.what() << std::endl;
130  exit(1);
131  }
132 
133  std::cerr << "Tagging validity dB table " << dbName << " in database with tag "
134  << tagName << std::endl;
135 
136  if (!dbt->Tag(tagName,override))
137  std::cerr << "Tag failed!" << std::endl;
138 
139  return 0;
140 }
bool ParseCLArgs(int argc, char *argv[])
std::string dbPort
std::string dbName
std::string detectorName
std::string tagName
std::string dbHost
bool Tag(std::string tn="", bool override=false)
Definition: Table.cpp:2046
Float_t e
Definition: plot.C:34
std::string tableName
bool ParseCLArgs ( int  argc,
char *  argv[] 
)

Definition at line 33 of file tagConditionsTableInDB.cc.

References dbHost, dbName, dbPort, detectorName, PrintUsage(), tableName, and tagName.

Referenced by main().

34 {
35  if (argc == 1) {
36  PrintUsage();
37  exit(0);
38  }
39 
40  struct option long_options[] = {
41  {"host", 1, 0, 'h'},
42  {"port", 1, 0, 'p'},
43  {"name", 1, 0, 'n'},
44  {"detector", 1, 0, 'd'},
45  {"tablename", 1, 0, 'T'},
46  {"tag", 1, 0, 't'},
47  {"override", 1, 0, 'o'},
48  {0,0,0,0}
49  };
50 
51  while (1) {
52  int optindx;
53  int c = getopt_long(argc,argv,"t:h:p:n:d:f:o",long_options,&optindx);
54 
55  if (c==-1) break;
56 
57  switch(c) {
58  case 'h':
59  dbHost = optarg;
60  break;
61  case 'p':
62  dbPort = optarg;
63  break;
64  case 'n':
65  dbName = optarg;
66  break;
67  case 'd':
68  detectorName = optarg;
69  break;
70  case 'T':
71  tableName = optarg;
72  break;
73  case 't':
74  tagName = optarg;
75  break;
76  case 'o':
77  override=true;
78  break;
79  default:
80  break;
81  }
82 
83  }
84 
85  if (optind<argc) {
86  std::cerr << "Unrecognized argument." << std::endl;
87  PrintUsage();
88  exit(0);
89  }
90 
91  if (tagName == "") {
92  std::cerr << "No tag name provided. Aborting." << std::endl;
93  exit(1);
94  }
95 
96  if (dbHost == "") {
97  std::cerr << "No value set for dB host. Aborting." << std::endl;
98  exit(0);
99  }
100  if (dbPort == "") {
101  std::cerr << "No value set for dB port. Aborting." << std::endl;
102  exit(0);
103  }
104  if (dbName == "") {
105  std::cerr << "No value set for dB name. Aborting." << std::endl;
106  exit(0);
107  }
108  if (tableName == "") {
109  std::cerr << "No value set for table name. Aborting." << std::endl;
110  exit(0);
111  }
112 
113  return true;
114 }
std::string dbPort
void PrintUsage()
std::string dbName
std::string detectorName
std::string tagName
std::string dbHost
std::string tableName
void PrintUsage ( )

Definition at line 19 of file tagConditionsTableInDB.cc.

Referenced by main(), and ParseCLArgs().

20 {
21  std::cout << "Usage: tagConditionsTableInDB [options]" << std::endl;
22  std::cout << "options:\n";
23  std::cout << "\t -h (--host) [dB host, REQUIRED]" << std::endl;
24  std::cout << "\t -n (--name) [dB name, REQUIRED]" << std::endl;
25  std::cout << "\t -p (--port) [dB port, REQUIRED]" << std::endl;
26  std::cout << "\t -d (--detector) [detector name, REQUIRED]" << std::endl;
27  std::cout << "\t -T (--tablename) [table name, REQUIRED]" << std::endl;
28  std::cout << "\t -t (--tag) [tag name, REQUIRED]" << std::endl;
29  std::cout << "\t -o (--override)" << std::endl;
30 }

Variable Documentation

std::string dbHost = ""

Definition at line 11 of file tagConditionsTableInDB.cc.

Referenced by main(), and ParseCLArgs().

std::string dbName = ""

Definition at line 12 of file tagConditionsTableInDB.cc.

Referenced by main(), and ParseCLArgs().

std::string dbPort = ""

Definition at line 13 of file tagConditionsTableInDB.cc.

Referenced by main(), and ParseCLArgs().

std::string detectorName = ""

Definition at line 15 of file tagConditionsTableInDB.cc.

Referenced by main(), and ParseCLArgs().

bool override =false

Definition at line 17 of file tagConditionsTableInDB.cc.

std::string tableName = ""

Definition at line 14 of file tagConditionsTableInDB.cc.

Referenced by main(), and ParseCLArgs().

std::string tagName = ""

Definition at line 16 of file tagConditionsTableInDB.cc.

Referenced by main(), and ParseCLArgs().