FACT++  1.0
void Fits::InitDataColumns ( const vector< Description > &  desc,
const vector< string > &  dataFormat,
MessageImp out 
)

Adds columns specific to the service being logged.

This gives the file writter access to the DIM data

Parameters
desca vector containing the description of all the columns to log
dataFormata vector containing the FITS data format of all the columsn to log
dataPointerthe memory location where the DIM data starts
numDataBytesthe number of bytes taken by the DIM data.
outMessage object to use for propagating messages

Definition at line 62 of file Fits.cc.

References i, MessageImp::Info(), str, and MessageImp::Warn().

63 {
64  fDataFormats = dataFormat;
65 
66  if ((desc.size() == 0) && (dataFormat.size() == 0))
67  {
68  fDataColDesc.clear();
69  return;
70  }
71 
72  //we will copy this information here. It duplicates the data, which is not great,
73  // but it is the easiest way of doing it right now
74  if (
75  (desc.size() == dataFormat.size()+1) || // regular service
76  (desc.size() == dataFormat.size()+2) // service with ending string. skipped in fits
77  )
78  {
79  //services have one (or two) more description than columns. skip the first entry while copying as it describes the table itself.
80 
81  fDataColDesc.clear();
82 
83  fTableDesc = desc[0].comment;
84  if (fTableDesc.size() > 68)
85  {
86  out->Warn("Table description '" + fTableDesc + "' exceeds 68 chars... truncated.");
87  fTableDesc = fTableDesc.substr(0,68);
88  }
89 
90  for (unsigned int i=0; i<dataFormat.size(); i++)
91  {
92  string name = desc[i+1].name;
93  if (name.length() > 68)
94  {
95  out->Warn("Column name '" + name + "' exceeds 68 chars... truncated.");
96  name = name.substr(0, 68);
97  }
98 
99  string comment = desc[i+1].comment;
100  if (comment.length() + name.length() > 71)
101  {
102  out->Warn("Column '" + name + " / " + comment + "' exceeds 68 chars... truncated.");
103  comment = comment.substr(0,68);
104  }
105 
106  string unit = desc[i+1].unit;
107  if (unit.length() > 68)
108  {
109  out->Warn("Unit '" + name + "' exceeds 68 chars... truncated.");
110  unit = comment.substr(0,68);
111  }
112 
113  const size_t p = fDataFormats[i].find_last_of('B');
114  if ((boost::iequals(unit, "text") || boost::iequals(unit, "string")) && p!=string::npos)
115  {
116  out->Info("Column '" + name + "' detected to be an ascii string (FITS format 'A').");
117  fDataFormats[i].replace(p, 1, "A");
118  }
119 
120  fDataColDesc.push_back(Description(name, comment, unit));
121  }
122  return;
123  }
124 
125  {//if we arrived here, this means that the columns descriptions could not be parsed
126  ostringstream str;
127  str << "Expected " << dataFormat.size() << " descriptions of columns, got " << (int)(desc.size())-1 << " for service: ";
128  if (desc.size() > 0)
129  str << desc[0].name;
130  else
131  str << "<unknown>";
132 
133  out->Warn(str.str());
134  }
135 
136  fDataColDesc.clear();
137  // fDataColDesc.push_back(Description("service", "comment", "unit"));
138  for (unsigned int i=0;i<dataFormat.size();i++)
139  {
140  ostringstream stt;
141  stt << "Data" << i;
142  fDataColDesc.push_back(Description(stt.str(), "", ""));
143  }
144 }
vector< string > fDataFormats
the data format of the data columns
Definition: Fits.h:33
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
A struct which stores a name, a unit and a comment.
Definition: Description.h:7
string fTableDesc
Definition: Fits.h:31
int Warn(const std::string &str)
Definition: MessageImp.h:48
int Info(const std::string &str)
Definition: MessageImp.h:47
vector< Description > fDataColDesc
the vector of data column names
Definition: Fits.h:29

+ Here is the call graph for this function: