You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB
C++

/**
* @file
* @brief tools for file format processing
* @author Andreas Nuechter. Jacobs University Bremen gGmbH, Germany.
* @author Thomas Escher. Institute of Computer Science, University of Osnabrueck, Germany.
*/
#ifndef __IO_UTILS_H__
#define __IO_UTILS_H__
#include "slam6d/io_types.h"
#include "slam6d/globals.icc"
#include <string>
using std::string;
using std::cerr;
/**
* Make type, start and end a write once only class for parseFormatFile because
* we know the directory only after the type, start and end parameters may have
* been written already, so encapsulate this write once behaviour in this class.
*/
template<typename T>
class WriteOnce {
public:
WriteOnce(T& value) : value(value), written(false) {}
WriteOnce& operator=(const T& other) { if(!written) { value = other; written = true; } return *this; }
operator T() const { return value; }
private:
T& value;
bool written;
};
void parseFormatFile(string& dir, WriteOnce<IOType>& type, WriteOnce<int>& start, WriteOnce<int>& end);
#endif