DebFile.hh 1.44 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// (C) Copyright 2016 by Autodesk, Inc.

#ifndef BASE_DEBFILE_HH_INCLUDED
#define BASE_DEBFILE_HH_INCLUDED
#ifdef DEB_ON

#include <vector>
#include <string>
#include <Base/Utils/IOutputStream.hh>

namespace Debug {
typedef unsigned int uint;
/*!
Debug file.
*/
class File
{
public:
19
  static const File& query();
20 21 22 23 24 25 26 27
  static File& modify();

public:
  enum Flags
  {
    APPEND    = 0x01,
    HTML      = 0x02,
    RETAIN    = 0x04,
28 29 30 31
    KEEP_OPEN = 0x08,
    CONSOLE   = 0x10,
    LOGFILE   = 0x20,
    DEFAULT = APPEND | RETAIN | CONSOLE | LOGFILE
32 33 34
  };

public:
35
  File(const char* const _flnm, const uint _flags = DEFAULT);
36 37 38 39 40 41 42 43 44 45 46 47 48 49
  ~File();

  void enter(const int _id);

  void print(const char _c);
  void print(const char* _s);
  void print(const size_t _i);
  void print(const int _i);
  void print(double _d);
  void print(const Base::Command& _co);

  const char* double_format() const;
  void set_double_format(const char* const str);

50 51
  //! Turn on/off the console. This could be extended to redirect it.
  void set_console(const bool _on = true);
52

53 54 55 56 57 58 59 60
  //! Get if the console is turned on/off. 
  bool console() const;

  //! Turn on/off the logfile. This could be extended to provide a FILE*.
  void set_logfile(const bool _on);

  //! Get if the logfile is turned on/off. 
  bool logfile() const;
61

Max Lyon's avatar
Max Lyon committed
62 63 64 65
  void set_filename(const char* const _flnm);

  void close();

66 67 68 69 70 71 72 73 74
private:
  class Impl;
  Impl* impl_;
};

}//namespace Debug

#endif//DEB_ON
#endif//BASE_DEBFILE_HH_INCLUDED