agglistT.cc

Go to the documentation of this file.
00001 // agglistT.C
00002 
00003 #include <iostream>
00004 
00005 using std::cerr ;
00006 using std::cout ;
00007 using std::endl ;
00008 
00009 #include "agglistT.h"
00010 #include "BESAggFactory.h"
00011 #include "BESTextInfo.h"
00012 #include "BESException.h"
00013 #include "TestAggServer.h"
00014 
00015 int agglistT::
00016 run(void)
00017 {
00018     cout << endl << "*****************************************" << endl;
00019     cout << "Entered agglistT::run" << endl;
00020     int retVal = 0;
00021 
00022     cout << endl << "*****************************************" << endl;
00023     cout << "Adding three handlers to the list" << endl ;
00024     try
00025     {
00026         BESAggFactory::TheFactory()->add_handler( "h1", agglistT::h1 ) ;
00027         BESAggFactory::TheFactory()->add_handler( "h2", agglistT::h2 ) ;
00028         BESAggFactory::TheFactory()->add_handler( "h3", agglistT::h3 ) ;
00029         cout << "Successfully added three handlers" << endl ;
00030     }
00031     catch( BESException &e )
00032     {
00033         cerr << "Failed to add aggregation servers to list" << endl ;
00034         cerr << e.get_message() << endl ;
00035         return 1 ;
00036     }
00037 
00038     cout << endl << "*****************************************" << endl;
00039     cout << "Find the three handlers" << endl ;
00040     try
00041     {
00042         BESAggregationServer *s = 0 ;
00043         s = BESAggFactory::TheFactory()->find_handler( "h1" ) ;
00044         if( !s )
00045         {
00046             cerr << "Failed to find handler h1" << endl ;
00047             return 1 ;
00048         }
00049         else
00050         {
00051             cout << "Successfully found handler h1" << endl ;
00052         }
00053         s = BESAggFactory::TheFactory()->find_handler( "h2" ) ;
00054         if( !s )
00055         {
00056             cerr << "Failed to find handler h2" << endl ;
00057             return 1 ;
00058         }
00059         else
00060         {
00061             cout << "Successfully found handler h2" << endl ;
00062         }
00063         s = BESAggFactory::TheFactory()->find_handler( "h3" ) ;
00064         if( !s )
00065         {
00066             cerr << "Failed to find handler h3" << endl ;
00067             return 1 ;
00068         }
00069         else
00070         {
00071             cout << "Successfully found handler h3" << endl ;
00072         }
00073     }
00074     catch( BESException &e )
00075     {
00076         cerr << "Failed to find aggregation servers" << endl ;
00077         cerr << e.get_message() << endl ;
00078     }
00079 
00080     cout << endl << "*****************************************" << endl;
00081     cout << "Remove handler h2" << endl ;
00082     try
00083     {
00084         bool removed = BESAggFactory::TheFactory()->remove_handler( "h2" ) ;
00085         if( removed )
00086         {
00087             cout << "Successfully removed handler h2" << endl ;
00088         }
00089         else
00090         {
00091             cerr << "Failed to remove handler h2" << endl ;
00092             return 1 ;
00093         }
00094     }
00095     catch( BESException &e )
00096     {
00097         cerr << "Failed to remove aggregation server h2" << endl ;
00098         cerr << e.get_message() << endl ;
00099         return 1 ;
00100     }
00101 
00102     cout << endl << "*****************************************" << endl;
00103     cout << "Find the two handlers" << endl ;
00104     try
00105     {
00106         BESAggregationServer *s = 0 ;
00107         s = BESAggFactory::TheFactory()->find_handler( "h1" ) ;
00108         if( !s )
00109         {
00110             cerr << "Failed to find handler h1" << endl ;
00111             return 1 ;
00112         }
00113         else
00114         {
00115             cout << "Successfully found handler h1" << endl ;
00116         }
00117         s = BESAggFactory::TheFactory()->find_handler( "h2" ) ;
00118         if( !s )
00119         {
00120             cout << "Failed to find handler h2, good" << endl ;
00121         }
00122         else
00123         {
00124             cout << "Successfully found handler h2, should not have" << endl ;
00125             return 1 ;
00126         }
00127         s = BESAggFactory::TheFactory()->find_handler( "h3" ) ;
00128         if( !s )
00129         {
00130             cerr << "Failed to find handler h3" << endl ;
00131             return 1 ;
00132         }
00133         else
00134         {
00135             cout << "Successfully found handler h3" << endl ;
00136         }
00137     }
00138     catch( BESException &e )
00139     {
00140         cerr << "Failed to find aggregation servers" << endl ;
00141         cerr << e.get_message() << endl ;
00142     }
00143 
00144     cout << endl << "*****************************************" << endl;
00145     cout << "Show handler names registered" << endl;
00146     cout << BESAggFactory::TheFactory()->get_handler_names() << endl ;
00147 
00148     cout << endl << "*****************************************" << endl;
00149     cout << "Returning from agglistT::run" << endl;
00150 
00151     return retVal;
00152 }
00153 
00154 BESAggregationServer *
00155 agglistT::h1( string name )
00156 {
00157     return new TestAggServer( name ) ;
00158 }
00159 
00160 BESAggregationServer *
00161 agglistT::h2( string name )
00162 {
00163     return new TestAggServer( name ) ;
00164 }
00165 
00166 BESAggregationServer *
00167 agglistT::h3( string name )
00168 {
00169     return new TestAggServer( name ) ;
00170 }
00171 
00172 int
00173 main(int argC, char **argV) {
00174     Application *app = new agglistT();
00175     putenv( "BES_CONF=./persistence_file_test.ini" ) ;
00176     return app->main(argC, argV);
00177 }
00178 

Generated on Sat Jan 19 04:05:36 2008 for OPeNDAP Back End Server (BES) by  doxygen 1.5.4