File msg_stack.hxx#

Defines

GLOBAL

This is a way to define a global object, so that it is declared extern in all files except one where GLOBALORIGIN is defined.

CONCATENATE_DIRECT(s1, s2)#

To concatenate strings for a variable name.

CONCATENATE(s1, s2)#

Need to use two levels due to macro strangeness.

TRACE(...)#

The TRACE macro provides a convenient way to put messages onto the msg_stack It pushes a message onto the stack, and pops it when the scope ends

Example

{ TRACE(“Starting calculation”)

} // Scope ends, message popped

Variables

MsgStack msg_stack#

Global object. Will eventually replace with better system.

class MsgStack#
#include <msg_stack.hxx>

Message stack

Implements a stack of messages which can be pushed onto the top and popped off the top. This is used for debugging: messages are put into this stack at the start of a section of code, and removed at the end. If an error occurs in between push and pop, then the message can be printed.

This code is only enabled if CHECK > 1. If CHECK is disabled then this message stack code reverts to empty functions which should be removed by the optimiser

Public Functions

MsgStack() = default#
inline ~MsgStack()#
int push(std::string message)#

Add a message to the stack. Returns a message id.

Provides a message stack to print more useful error messages.

Copyright 2010 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu

Contact: Ben Dudson, bd512@york.ac.uk

This file is part of BOUT++.

BOUT++ is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

BOUT++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with BOUT++. If not, see http://www.gnu.org/licenses/.

inline int push()#
template<class S, class ...Args>
inline int push(const S &format, const Args&... args)#
void pop()#

Remove the last message.

void pop(int id)#

Remove all messages back to msg id.

void clear()#

Clear all message.

void dump()#

Write out all messages (using output)

std::string getDump()#

Write out all messages to a string.

inline std::size_t size() const#

Current stack size.

Private Members

std::vector<std::string> stack#

Message stack;.

std::vector<std::string>::size_type position = {0}#

Position in stack.

class MsgStackItem#
#include <msg_stack.hxx>

MsgStackItem

Simple class to manage pushing and popping messages from the message stack. Pushes a message in the constructor, and pops the message on destruction.

Public Functions

inline MsgStackItem(std::string message)#
inline MsgStackItem(const std::string &message, const char *file, int line)#
inline MsgStackItem(const std::string &file, int line, const char *msg)#
template<class S, class ...Args>
inline MsgStackItem(const std::string &file, int line, const S &msg, const Args&... args)#
inline ~MsgStackItem()#

Private Members

int exception_count = std::uncaught_exceptions()#
int point#