Changeset 372 for cpp/frams/_demos


Ignore:
Timestamp:
04/22/15 04:14:59 (5 years ago)
Author:
sz
Message:

Renamed some classes and functions to make their purpose more obvious:

All MessageHandlers? must now be given the explicit "Enable" argument if you want them to automatically become active. This makes side effects clearly visible.

Location:
cpp/frams/_demos
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/_demos/f0_variants_test.cpp

    r348 r372  
    1010#include <frams/genetics/defgenoconv.h>
    1111#include <frams/model/model.h>
    12 #include <frams/errmgr/stdouterr.h>
     12#include <frams/mhandlers/stdouthandler.h>
    1313
    1414void save_as_f0(SString &gen,Model &m,bool omit_default_values)
     
    7474int main(int argc,char*argv[])
    7575{
    76 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output)
     76MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
    7777
    7878//without converters the application would only handle "format 0" genotypes
  • cpp/frams/_demos/full_props.cpp

    r348 r372  
    99
    1010#include <frams/model/model.h>
    11 #include <frams/errmgr/stdouterr.h>
     11#include <frams/mhandlers/stdouthandler.h>
    1212#include <frams/genetics/preconfigured.h>
    1313
     
    5050{
    5151StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err
    52 StdoutErrorHandler err(ErrorHandlerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
     52MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable | MessageHandlerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
    5353
    5454PreconfiguredGenetics genetics;
     
    7979if (!m.isValid())
    8080        {
    81         FMprintf("","full_props",FMLV_ERROR,"Cannot build Model from the supplied genotype\n");
     81        Hprintf("","full_props",HMLV_ERROR,"Cannot build Model from the supplied genotype\n");
    8282        return 2;       
    8383        }
  • cpp/frams/_demos/geno_test.cpp

    r365 r372  
    66#include <frams/util/sstringutils.h>
    77#include <frams/genetics/preconfigured.h>
    8 #include <frams/errmgr/stdouterr.h>
     8#include <frams/mhandlers/stdouthandler.h>
    99
    1010/**
     
    1818{
    1919        PreconfiguredGenetics genetics;
    20         StdoutErrorHandler stdouterr; //comment this object out to mute error/warning messages
     20        MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable); //comment this object out to mute error/warning messages
    2121
    2222        if (argc <= 1)
  • cpp/frams/_demos/genoconv_test.cpp

    r348 r372  
    99
    1010#include "printconvmap.h"
    11 #include <frams/errmgr/stdouterr.h>
     11#include <frams/mhandlers/stdouthandler.h>
    1212
    1313/**
     
    117117int main(int argc,char *argv[])
    118118{
    119 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output)
     119MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
    120120
    121121DefaultGenoConvManager gcm;
  • cpp/frams/_demos/genomanipulation.cpp

    r348 r372  
    1010#include <frams/model/model.h>
    1111#include <frams/genetics/preconfigured.h>
    12 #include <frams/errmgr/stdouterr.h>
     12#include <frams/mhandlers/stdouthandler.h>
    1313
    1414/**
     
    266266int main(int argc,char*argv[])
    267267{
    268 StdoutErrorHandler err; //redirect model-related errors to stdout
     268MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable); //redirect model-related errors to stdout
    269269
    270270srand(time(0));
  • cpp/frams/_demos/genooper_test.cpp

    r348 r372  
    33// See LICENSE.txt for details.
    44
    5 #include <frams/errmgr/stdouterr.h>
     5#include <frams/mhandlers/stdouthandler.h>
    66#include <frams/genetics/preconfigured.h>
    77
     
    2121int main(int argc, char *argv[])
    2222{
    23         StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output)
     23        MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
    2424        PreconfiguredGenetics genetics;
    2525
  • cpp/frams/_demos/loader_test_param.cpp

    r348 r372  
    55#include <frams/param/multiparamload.h>
    66#include <frams/virtfile/stdiofile.h>
    7 #include <frams/errmgr/stdouterr.h>
     7#include <frams/mhandlers/stdouthandler.h>
    88
    99/**
     
    6666        StdioFILEDontClose virt_stderr(stderr);
    6767        StdioFILEDontClose virt_stdout(stdout);
    68         StdoutErrorHandler error_handler(0, &virt_stderr);
     68        MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable, &virt_stderr);
    6969        StdioFileSystem_autoselect stdiofilesys;
    7070        MultiParamLoader loader(argv[1]);
  • cpp/frams/_demos/multiline_f0_test.cpp

    r348 r372  
    1010#include <frams/genetics/preconfigured.h>
    1111#include <frams/model/model.h>
    12 #include <frams/errmgr/stdouterr.h>
     12#include <frams/mhandlers/stdouthandler.h>
    1313#include <frams/virtfile/stringfile.h>
    1414
    1515int main(int argc,char*argv[])
    1616{
    17 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output)
     17MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
    1818PreconfiguredGenetics genetics;
    1919
  • cpp/frams/_demos/neuro_layout_test.cpp

    r348 r372  
    77#include <frams/genetics/preconfigured.h>
    88#include <frams/model/model.h>
    9 #include <frams/errmgr/stdouterr.h>
     9#include <frams/mhandlers/stdouthandler.h>
    1010#include <frams/canvas/nn_layout_model.h>
    1111
     
    8383int main(int argc,char*argv[])
    8484{
    85 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output)
     85MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
    8686PreconfiguredGenetics genetics;
    8787
  • cpp/frams/_demos/neuro_test.cpp

    r348 r372  
    99#include <frams/neuro/neuroimpl.h>
    1010#include <frams/neuro/neurofactory.h>
    11 #include <frams/errmgr/stdouterr.h>
     11#include <frams/mhandlers/stdouthandler.h>
    1212
    1313/**
     
    6060int main(int argc,char*argv[])
    6161{
    62 StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output)
     62MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
    6363PreconfiguredGenetics genetics;
    6464
  • cpp/frams/_demos/shapeconvert.cpp

    r348 r372  
    99
    1010#include <frams/model/model.h>
    11 #include <frams/errmgr/stdouterr.h>
     11#include <frams/mhandlers/stdouthandler.h>
    1212#include <frams/genetics/preconfigured.h>
    1313
     
    3434{
    3535        StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err
    36         StdoutErrorHandler err(ErrorHandlerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
     36        MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable | MessageHandlerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
    3737
    3838        PreconfiguredGenetics genetics;
     
    5050                                if ((shape != Part::SHAPE_ELLIPSOID) && (shape != Part::SHAPE_CUBOID) && (shape != Part::SHAPE_CYLINDER))
    5151                                {
    52                                         FMprintf("", "shapeconvert", FMLV_ERROR, "Invalid shape");
     52                                        Hprintf("", "shapeconvert", HMLV_ERROR, "Invalid shape");
    5353                                        return 4;
    5454                                }
     
    7171        if (!m.isValid())
    7272        {
    73                 FMprintf("", "shapeconvert", FMLV_ERROR, "Cannot build Model from the supplied genotype");
     73                Hprintf("", "shapeconvert", HMLV_ERROR, "Cannot build Model from the supplied genotype");
    7474                return 2;
    7575        }
     
    7777        if (m.getShape() != Model::SHAPE_OLD)
    7878        {
    79                 FMprintf("", "shapeconvert", FMLV_ERROR, "Only old style shapes can be converted");
     79                Hprintf("", "shapeconvert", HMLV_ERROR, "Only old style shapes can be converted");
    8080                return 3;
    8181        }
  • cpp/frams/_demos/simil_test.cpp

    r361 r372  
    55
    66#include <vector>
    7 #include "frams/errmgr/stdouterr.h"
     7#include "frams/mhandlers/stdouthandler.h"
    88#include "frams/_demos/genotypeloader.h"
    99#include "frams/genetics/preconfigured.h"
     
    3939int main(int argc, char *argv[])
    4040{
    41     StdoutErrorHandler stdouterr; //comment this object out to mute error/warning messages
     41    MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
    4242    typedef double *pDouble;
    4343    int iCurrParam = 0; // index of the currently processed parameter
Note: See TracChangeset for help on using the changeset viewer.