Standardized output for BIE

The idea is to overwrite standard output 'cout' when you want to redirect the output to a different place.

The design goals are:

  • independently redirect output of each function to device or file
  • be able to dynamically change redirection during runtime
There are several options:
  • output to the standard output (default, cli_console=cout)
  • redirect output to a file (one can give any file name as desired)
  • redirect output to a terminal (example, simulation_out=/dev/pts/1)
  • redirect output to a network socket, named pipe, pipe or file descriptor

A file .bierc is located in one's home directory. It contains the information needed for redirecting output. If the program can not find the file, it will create a default .bierc file in your home directory. Redirections are specified as pairs: function name - output redirection

How to use it:

I have converted all functions which have outputs with this method. You can modify the standard .bierc file for your particular needs.

One may also place a .bierc file in a working directory. These new values will replace the default values in ~/.bierc. This way, one can define different default parameters for different projects as well as overall default parameters.

If you want to use this method in a new function you write, please follow the steps below:

1. in the program:

* include "gfunction.h" in the source file that contains the function

* in the function (method), at the beginning of the function, use ostream cout(checkTable(<function name>)); to redefine cout. You can also redefine cerr if needed.

It is possible to use a unique <function name> for each function. Alternatively, you can assign the same name to multiple functions (that defines a group that will be treated the same). Or, you can use an existing name (from the default .bierc file, examples: cli_console, simulation_output).

There is a second way to redefine cout: ostream cout(getOutput(<function name>, <output redirection>));

This function allows redefining 'cout' with a specific string as argument (if you don't want to use .bierc). It also updates the table.

* after redefinition cout can be used as usual (but will now be redirected)

2. in the configuration file:

in the [output] section, put a pair: function name - output redirection for your function

examples: cli_console=cout debug_output=debug.txt

We will provide methods to modify table entries in runtime to be able to change the values from within cli. Then the next time a function is called after the modification it will use the new value for its output redirection.

The functions you can use to redefine standard output are: streambuf *checkTable(char *function_name) and streambuf *checkTable(char *function_name, char *output_redirection)

The first one uses information from the global redirection table that is initialized from the .bierc file. The second one allows you to use a string to define output redirection and modify the table.

A few more comments:

When you call checkTable and function_name is not found; or if you never call checkTable in a function (method), then the standard cout will be used.

The new method allows us to eliminate 'cout_o' from the program.


Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU.
Documentation generated at Fri Mar 26 00:35:11 2010 by doxygen