replistT.cc

Go to the documentation of this file.
00001 // replistT.C
00002 
00003 #include <iostream>
00004 
00005 using std::cerr ;
00006 using std::cout ;
00007 using std::endl ;
00008 
00009 #include "replistT.h"
00010 #include "BESReporterList.h"
00011 #include "TestReporter.h"
00012 
00013 int replistT::
00014 run(void)
00015 {
00016     cout << endl << "*****************************************" << endl;
00017     cout << "Entered replistT::run" << endl;
00018     int retVal = 0;
00019 
00020     cout << endl << "*****************************************" << endl;
00021     cout << "add the 5 reporters" << endl ;
00022     BESReporterList *rl = BESReporterList::TheList() ;
00023     char num[10] ;
00024     for( int i = 0; i < 5; i++ )
00025     {
00026         sprintf( num, "rep%d", i ) ;
00027         if( rl->add_reporter( num, new TestReporter( num ) ) == true )
00028         {
00029             cout << "successfully added " << num << endl ;
00030         }
00031         else
00032         {
00033             cerr << "failed to add " << num << endl ;
00034             return 1 ;
00035         }
00036     }
00037 
00038     cout << endl << "*****************************************" << endl;
00039     cout << "try to add rep3 again" << endl ;
00040     TestReporter *r = new TestReporter( "rep3" ) ;
00041     if( rl->add_reporter( "rep3", r ) == true )
00042     {
00043         cerr << "successfully added rep3 again" << endl ;
00044         return 1 ;
00045     }
00046     else
00047     {
00048         cout << "failed to add rep3 again, good" << endl ;
00049         delete r ;
00050     }
00051 
00052     cout << endl << "*****************************************" << endl;
00053     cout << "finding the reporters" << endl ;
00054     for( int i = 4; i >=0; i-- )
00055     {
00056         sprintf( num, "rep%d", i ) ;
00057         r = (TestReporter *)rl->find_reporter( num ) ;
00058         if( r )
00059         {
00060             if( r->get_name() == num )
00061             {
00062                 cout << "found " << num << endl ;
00063             }
00064             else
00065             {
00066                 cerr << "looking for " << num
00067                      << ", found " << r->get_name() << endl ;
00068                 return 1 ;
00069             }
00070         }
00071         else
00072         {
00073             cerr << "coundn't find " << num << endl ;
00074             return 1 ;
00075         }
00076     }
00077     r = (TestReporter *)rl->find_reporter( "thingy" ) ;
00078     if( r )
00079     {
00080         if( r->get_name() == "thingy" )
00081         {
00082             cerr << "found thingy" << endl ;
00083             return 1 ;
00084         }
00085         else
00086         {
00087             cerr << "looking for thingy, found " << r->get_name() << endl ;
00088             return 1 ;
00089         }
00090     }
00091     else
00092     {
00093         cout << "coundn't find thingy" << endl ;
00094     }
00095 
00096     cout << endl << "*****************************************" << endl;
00097     cout << "removing rep2" << endl ;
00098     r = (TestReporter *)rl->remove_reporter( "rep2" ) ;
00099     if( r )
00100     {
00101         string name = r->get_name() ;
00102         if( name == "rep2" )
00103         {
00104             cout << "successfully removed rep2" << endl ;
00105             delete r ;
00106         }
00107         else
00108         {
00109             cerr << "trying to remove rep2, but removed " << name << endl ;
00110             return 1 ;
00111         }
00112     }
00113     else
00114     {
00115         cerr << "failed to remove rep2" << endl ;
00116         return 1 ;
00117     }
00118 
00119     r = (TestReporter *)rl->find_reporter( "rep2" ) ;
00120     if( r )
00121     {
00122         if( r->get_name() == "rep2" )
00123         {
00124             cerr << "found rep2, should have been removed" << endl ;
00125             return 1 ;
00126         }
00127         else
00128         {
00129             cerr << "found " << r->get_name() << " when looking for rep2"
00130                  << endl ;
00131             return 1 ;
00132         }
00133     }
00134     else
00135     {
00136         cout << "couldn't find rep2, good" << endl ;
00137     }
00138 
00139     if( rl->add_reporter( "rep2", new TestReporter( "rep2" ) ) == true )
00140     {
00141         cout << "successfully added rep2 back" << endl ;
00142     }
00143     else
00144     {
00145         cerr << "failed to add rep2 back" << endl ;
00146         return 1 ;
00147     }
00148 
00149     r = (TestReporter *)rl->find_reporter( "rep2" ) ;
00150     if( r )
00151     {
00152         if( r->get_name() == "rep2" )
00153         {
00154             cout << "found rep2" << endl ;
00155         }
00156         else
00157         {
00158             cerr << "looking for rep2, found " << r->get_name() << endl ;
00159             return 1 ;
00160         }
00161     }
00162     else
00163     {
00164         cerr << "coundn't find rep2" << endl ;
00165         return 1 ;
00166     }
00167 
00168     cout << endl << "*****************************************" << endl;
00169     cout << "report" << endl;
00170     BESDataHandlerInterface dhi ;
00171     rl->report( dhi ) ;
00172 
00173     cout << endl << "*****************************************" << endl;
00174     cout << "Returning from replistT::run" << endl;
00175 
00176     return retVal;
00177 }
00178 
00179 int
00180 main(int argC, char **argV) {
00181     Application *app = new replistT();
00182     return app->main(argC, argV);
00183 }
00184 

Generated on Wed Jan 2 06:01:19 2008 for OPeNDAP Back End Server (BES) by  doxygen 1.5.4