FACT++  1.0
vector< int > FitsLoader::CalculateBufferSize ( )
private

Calculate the buffer size required to read a row of the fits table, as well as the offsets to each column.

Calculates the required buffer size for reading one row of the current table. Also calculates the offsets to all the columns

Definition at line 274 of file fitsloader.cc.

References MessageImp::Error(), fColMap, MessageImp::Message(), size, and str.

Referenced by DoDumpPlease().

275 {
276  vector<int> result;
277  map<int,int> sizes;
278  int size = 0;
279 
280  for (map<string, CCfits::Column*>::iterator it=fColMap.begin(); it != fColMap.end(); it++)
281  {
282  int width = it->second->width();
283  switch (it->second->type())
284  {
285  case CCfits::Tbyte:
286  case CCfits::Tushort:
287  case CCfits::Tshort:
288  Message("short");
289  sizes[it->second->index()] = sizeof(char)*width;
290  break;
291  case CCfits::Tuint:
292  case CCfits::Tint:
293  Message("int");
294  sizes[it->second->index()] = sizeof(int)*width;
295  break;
296  case CCfits::Tulong:
297  case CCfits::Tlong:
298  Message("long");
299  sizes[it->second->index()] = sizeof(int)*width;
300  break;
301  case CCfits::Tlonglong:
302  Message("longlong");
303  sizes[it->second->index()] = sizeof(long long)*width;
304  break;
305  case CCfits::Tfloat:
306  Message("float");
307  sizes[it->second->index()] = sizeof(float)*width;
308  break;
309  case CCfits::Tdouble:
310  Message("double");
311  sizes[it->second->index()] = sizeof(double)*width;
312  break;
313  case CCfits::Tnull:
314  case CCfits::Tbit:
315  case CCfits::Tlogical:
316  case CCfits::Tstring:
317  case CCfits::Tcomplex:
318  case CCfits::Tdblcomplex:
319  case CCfits::VTbit:
320  case CCfits::VTbyte:
321  case CCfits::VTlogical:
322  case CCfits::VTushort:
323  case CCfits::VTshort:
324  case CCfits::VTuint:
325  case CCfits::VTint:
326  case CCfits::VTulong:
327  case CCfits::VTlong:
328  case CCfits::VTlonglong:
329  case CCfits::VTfloat:
330  case CCfits::VTdouble:
331  case CCfits::VTcomplex:
332  case CCfits::VTdblcomplex:
333  Error("Data type not implemented yet.");
334  return vector<int>();
335  break;
336  default:
337  Error("THIS SHOULD NEVER BE REACHED");
338  return vector<int>();
339  }
340  }
341  //calculate the offsets in the vector.
342  int checkIndex = 1;
343  for (map<int,int>::iterator it=sizes.begin(); it != sizes.end(); it++)
344  {
345  result.push_back(size);
346  size += it->second;
347  if (it->first != checkIndex)
348  {
349  ostringstream str;
350  str << "Expected index " << checkIndex << " found " << it->first;
351  Error(str);
352  }
353  checkIndex++;
354  }
355  result.push_back(size);
356  return result;
357 }
map< string, CCfits::Column * > fColMap
map between the column names and their CCfits objects
Definition: fitsloader.cc:82
char str[80]
Definition: test_client.c:7
int Error(const std::string &str)
Definition: MessageImp.h:49
int size
Definition: db_dim_server.c:17
int Message(const std::string &str)
Definition: MessageImp.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function: