Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

testMgr.cxx File Reference

#include "../../FluxMgr.h"
#include "FluxSvc/EventSource.h"
#include "FluxSvc/ISpectrumFactory.h"
#include "../../SpectrumFactoryTable.h"
#include <iostream>
#include <algorithm>
#include "../../CHIMESpectrum.h"

Go to the source code of this file.

Defines

#define DLL_DECL_SPECTRUM(x)   extern const ISpectrumFactory& x##Factory; x##Factory.addRef();

Functions

void help ()
void listSources (const std::list< std::string > &source_list)
void listSpectra ()
void flux_load ()
int main (int argn, char *argc[])


Define Documentation

#define DLL_DECL_SPECTRUM      extern const ISpectrumFactory& x##Factory; x##Factory.addRef();
 

Definition at line 47 of file testMgr.cxx.


Function Documentation

void flux_load  
 

Definition at line 49 of file testMgr.cxx.

References DLL_DECL_SPECTRUM.

Referenced by main().

00049                  {
00050     
00051     // these are the spectra that we want to make available
00052     DLL_DECL_SPECTRUM( CHIMESpectrum);
00053     DLL_DECL_SPECTRUM( AlbedoPSpectrum);
00054     DLL_DECL_SPECTRUM( HeSpectrum);
00055     DLL_DECL_SPECTRUM( GalElSpectrum);
00056     //  DLL_DECL_SPECTRUM( CrElectron);
00057     //  DLL_DECL_SPECTRUM( CrProton);
00058     //  DLL_DECL_SPECTRUM( GRBSpectrum);
00059     //  DLL_DECL_SPECTRUM( CREMESpectrum);
00060 }

void help  
 

Definition at line 19 of file testMgr.cxx.

Referenced by main().

00019             {
00020     std::cout << 
00021         "   Simple test program to create a particle source, then run it.\n"
00022         "   Command line args are \n"
00023         "      <source name> <count>\n"
00024         "   with defaults \"" 
00025         <<  default_source << "\"," << default_count
00026         << "\n  Also, 'help' for this help, 'list' for a list of sources and Spectrum objects "
00027         << std::endl;
00028 }

void listSources const std::list< std::string > &    source_list
 

Definition at line 29 of file testMgr.cxx.

Referenced by main().

00029                                                          {
00030     std::cout << "List of available sources:" << std::endl;
00031     for( std::list<std::string>::const_iterator it = source_list.begin(); 
00032     it != source_list.end(); ++it) { 
00033         std::cout << '\t'<< *it << std::endl;
00034     }
00035     
00036 }

void listSpectra  
 

Definition at line 37 of file testMgr.cxx.

References SpectrumFactoryTable::instance().

Referenced by main().

00037                    {
00038     std::cout << "List of loaded Spectrum objects: " << std::endl;
00039     std::list<std::string> spectra(SpectrumFactoryTable::instance()->spectrumList());
00040     for( std::list<std::string>::const_iterator it = spectra.begin(); 
00041     it != spectra.end(); ++it) { 
00042         std::cout << '\t'<< *it << std::endl;
00043     }
00044 }

int main int    argn,
char *    argc[]
 

Definition at line 62 of file testMgr.cxx.

References flux_load(), help(), SpectrumFactoryTable::instance(), listSources(), listSpectra(), FluxMgr::sourceList(), and FluxMgr::test().

00062                                   {
00063     using std::cout;
00064     using std::endl;
00065     flux_load();
00066     //testing 
00067     std::string test("23class");
00068     int ss = test.find_first_not_of("0123456789");
00069     
00070     int count = default_count;
00071     std::string source_name(default_source);
00072     
00073     
00074     //TESTING MULTIPLE XML INPUT
00075     std::vector<std::string> fileList;
00076     fileList.push_back("$(FLUXSVCROOT)/xml/user_library.xml");
00077     fileList.push_back("$(FLUXSVCROOT)/xml/source_library.xml");        
00078     FluxMgr fm(fileList);
00079     
00080     //FluxMgr fm;
00081     
00082     //Testing the addfactory function
00083     //    static PencilBeam* sean=TestSpec::instance();
00084     //    fm.addFactory("seantest", sean );
00085     //End Test
00086     
00087     if ( argn >1 ) source_name = argc[1];
00088     if( source_name =="help") { help(); return 0; }
00089     if( source_name =="list") { 
00090         listSources(fm.sourceList());
00091         listSpectra(); return 0; }
00092     if ( argn >2 ) count = ::atoi(argc[2]);
00093     
00094     cout << "------------------------------------------------------" << endl;
00095     cout << " Flux test program: type 'help' for help" << endl;
00096     cout << ( ( argn ==1)?  " No command line args, using default flux \""
00097         :  " Selected source name \"");
00098     cout  << source_name <<"\"" << endl;
00099     
00100     
00101     std::list<std::string> source_list(fm.sourceList());
00102     
00103     if( std::find(source_list.begin(), source_list.end(), source_name)==source_list.end() ) {
00104         std::list<std::string> spectra(SpectrumFactoryTable::instance()->spectrumList());
00105         
00106         if( std::find(spectra.begin(), spectra.end(), source_name)==spectra.end() ) {
00107             std::cout << "Source \"" << source_name << "\" not found in the list or sources!" << std::endl;
00108             listSources(source_list);
00109             std::cout << "or in specra list, which is:\n";
00110             listSpectra();
00111             
00112             return -1;
00113         }
00114     }
00115     // now have FluxMgr create and run it.
00116     fm.test(std::cout, source_name, count);
00117     return 0;
00118     
00119 }


Generated on Wed Oct 16 14:01:31 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001