Hi Geoff and Doug:

please can you generate a default behavior file for class Main:

Main { ... }

which contains the equivalent of what the Demeter/C++ generated 
main file contains (see below).
Call the file generic-visitor-use.beh.sample and put it into the
generated directory.

This has three purposes:

1. It tells users how to use the generated visitors.

2. By renaming generic-visitor-use.beh.sample to generic-visitor-use.beh
we get a good test program for the visitors.

3. It gives an example of how to write the Main class.

Please put this in the next release. Note that the first class in the
class dictionary (WorkFlowManagement)
plays a key role. Input should be taken from program.input.

-- Karl


//-----------------------------------------------------------------
// main.C.sample 
// This file is an example for a main.C Demeter main file.
// It provides sample code fragments showing how to use some of the 
// Demeter runtime libraries. To have a quick test of your environment 
// rename this file to main.C and compile the environment. 
//-----------------------------------------------------------------


/*
 * GEN_DIR is a global variable containing the path of the generation
 * environment. This path is used to find the cd-print and cd-parse
 * class dictionaries.
 * Do NOT delete the following statement.
 */

char* GEN_DIR = getenv( "GEN_DIR" );

int main( int argc, char* argv[], char* envp[] )
{
  //----------------------------------------
  // Parsing an object 
  //----------------------------------------
  // specify file to parse in 
  const int MAXPATH = 256;
  char Dem_input[MAXPATH];

  // Input file is first argument
  if( argc >= 2 )
     strcpy( Dem_input, argv[1] );
  else {
     strcpy( Dem_input, "demeter-input" );  // default input 
  }

  // parse it in 
  cout << "Parsing in object in: " << Dem_input << "." << endl;
  WorkFlowManagement* iWorkFlowManagement = new WorkFlowManagement();
  if ( ( WorkFlowManagement* ) iWorkFlowManagement -> g_parse( Dem_input ) == NULL )
  {
     cerr << "Parser error." << endl;
     exit(1);
  }
  cout << endl;

  //----------------------------------------
  // Drawing an object 
  //----------------------------------------
  cout << "Drawing the parsed object:" << endl;
  iWorkFlowManagement -> g_draw();
  cout << "\nEnd of drawing.\n" << endl;

  //----------------------------------------
  // Copying an object 
  //----------------------------------------
  cout << "Copying the object." << endl;
  WorkFlowManagement* nWorkFlowManagement = ( WorkFlowManagement* ) iWorkFlowManagement -> g_copy();
  cout << endl;

  //----------------------------------------
  // Displaying the copied object as a tree
  //----------------------------------------
  cout << "Displaying the copied object as a tree:" << endl;
  nWorkFlowManagement -> g_displayAsTree();
  cout << "\nEnd of display.\n" << endl;

  //----------------------------------------
  // Comparing two objects 
  //----------------------------------------
  cout << "Comparing the two objects:" << endl;
  if ( iWorkFlowManagement -> g_equal( nWorkFlowManagement ) == 1 )
     cout << "copied and original object are equal\n" << endl;
  else
     cout << "copied and original object are NOT equal\n" << endl;

  //----------------------------------------
  // Printing an object 
  //----------------------------------------
  cout << "Pretty printing the parsed object:" << endl;
  char* tmp_filename = "notmod/tmp/demeter-output";
  ofstream outFile( tmp_filename );
  if ( !outFile ) {
    cerr << "UNKNOWN error: unable to open " << tmp_filename
         << " for output" << endl;
    exit( 1 );
  }
  cout << iWorkFlowManagement << endl;
  iWorkFlowManagement -> g_print( outFile );
  outFile.close();
  cout << "\nEnd of printing.\n" << endl;

  //----------------------------------------
  // Selftest of generic parser/printer 
  //----------------------------------------
  cout << "Selftest of generic parser/printer:" << endl;
  WorkFlowManagement* iWorkFlowManagement_printed = new WorkFlowManagement();
  iWorkFlowManagement_printed = (WorkFlowManagement*)iWorkFlowManagement_printed->g_parse( tmp_filename );
  if( iWorkFlowManagement->g_equal( iWorkFlowManagement_printed ) == 1 ) {
    cout << "g_parse and g_parse( g_print( g_parse ) ) are equal.\n"
         << "Selftest passed.\n";
  } else {
    cout << "g_parse and g_parse( g_print( g_parse ) ) are NOT equal.\n"
         << "Selftest failed.\n";
  }
  cout << endl;

  //----------------------------------------
  // Your own code follows after this 
  //----------------------------------------

  cout << "\n*** FINISHED ***" << endl;

  return ( 0 );
}

