Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ ENDIF()
####################################
SET(UTILITIES
Utilities/RandomGenerator.cpp
Utilities/OhmmsInform.cpp
Utilities/OhmmsInfo.cpp
Utilities/InfoStream.cpp
Utilities/OutputManager.cpp
Utilities/NewTimer.cpp
io/hdf_archive.cpp
${GITREV_TMP}
Expand Down
17 changes: 1 addition & 16 deletions src/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <vector>
#include <map>
#include <complex>
#include <Utilities/OhmmsInfo.h>
#include <Utilities/OutputManager.h>
#include <Message/Communicate.h>

#define byRows 999
Expand Down Expand Up @@ -120,21 +120,6 @@ namespace qmcplusplus
typedef SMSparseMatrix<SPComplexType> SPComplexSMSpMat;
*/

inline std::ostream &app_log() { return OhmmsInfo::Log->getStream(); }

inline std::ostream &app_error()
{
OhmmsInfo::Log->getStream() << "ERROR ";
return OhmmsInfo::Error->getStream();
}

inline std::ostream &app_warning()
{
OhmmsInfo::Log->getStream() << "WARNING ";
return OhmmsInfo::Warn->getStream();
}

inline std::ostream &app_debug() { return OhmmsInfo::Debug->getStream(); }
}

namespace std{
Expand Down
56 changes: 56 additions & 0 deletions src/Utilities/InfoStream.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//////////////////////////////////////////////////////////////////////////////////////
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2017 Jeongnim Kim and QMCPACK developers.
//
// File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
//
// File created by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
//////////////////////////////////////////////////////////////////////////////////////


#include <Utilities/InfoStream.h>
#include <fstream>

InfoStream::~InfoStream()
{
if (currStream != nullStream) {
delete nullStream;
}
if (ownStream && currStream) {
delete(currStream);
}
}

void InfoStream::pause() {
if (currStream != nullStream)
{
prevStream = currStream;
currStream = nullStream;
}
}

void InfoStream::resume() {
if (prevStream) {
currStream = prevStream;
prevStream = NULL;
}
}

void InfoStream::shutOff() {
prevStream = NULL;
currStream = nullStream;
}

void InfoStream::redirectToFile(const std::string &fname) {
currStream = new std::ofstream(fname);
ownStream = true;
}

void InfoStream::redirectToSameStream(InfoStream &info)
{
currStream = &info.getStream();
ownStream = false;
}

95 changes: 95 additions & 0 deletions src/Utilities/InfoStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//////////////////////////////////////////////////////////////////////////////////////
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2017 Jeongnim Kim and QMCPACK developers.
//
// File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
//
// File created by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
//////////////////////////////////////////////////////////////////////////////////////


/** @file InfoStream.h
* @brief Declaration of InfoStream class.
*/

#ifndef INFOSTREAM_H
#define INFOSTREAM_H

#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>

/**
* Interface to output streams. Can redirect output to stdout/stderr, a file, or a null stream.
*/

class InfoStream
{
public:
InfoStream(std::ostream *output_stream): prevStream(NULL), nullStream(new std::ostream(NULL)),
ownStream(false) {
currStream = output_stream;
}

InfoStream(InfoStream &in): prevStream(NULL), nullStream(new std::ostream(NULL)),
ownStream(false) {
redirectToSameStream(in);
}

~InfoStream();

std::ostream &getStream(const std::string &tag = "") {
return *currStream;
}

void setStream(std::ostream *output_stream) {
currStream = output_stream;
}


void flush() {
currStream->flush();
}

/// Stop output (redirect to a null stream)
void pause();

/// Continue output on the stream used before pausing
void resume();

/// Open a file and output to that file
void redirectToFile(const std::string &fname);

/// Copy a stream
void redirectToSameStream(InfoStream &info);

/// Permanently turn off the stream
void shutOff();

private:

// Keep track of whether we should delete the stream or not
bool ownStream;

std::ostream *currStream;

// save stream during pause
std::ostream *prevStream;

// Created at construction. Used during pause
std::ostream *nullStream;
};

template<class T>
inline
InfoStream& operator<<(InfoStream& o, const T& val)
{
o.getStream() << val;
return o;
}


#endif
113 changes: 0 additions & 113 deletions src/Utilities/OhmmsInfo.cpp

This file was deleted.

Loading