00001 #ifndef ANALYZER_IGUANA_NET_PRODUCER_H 00002 # define ANALYZER_IGUANA_NET_PRODUCER_H 00003 00004 //<<<<<< INCLUDES >>>>>> 00005 00006 # include "Iguana/Framework/interface/IgNet.h" 00007 # include "classlib/utils/DebugAids.h" 00008 # include "classlib/utils/TimeInfo.h" 00009 # include "classlib/utils/Signal.h" 00010 # include "classlib/utils/Time.h" 00011 # include <cstdlib> 00012 # include <cstring> 00013 # include <iostream> 00014 # include <signal.h> 00015 # include <unistd.h> 00016 00017 static sig_atomic_t s_stop = 0; 00018 00019 class IguanaNetProducer : public IgNet 00020 { 00021 public: 00022 IguanaNetProducer (bool verbose, int port) 00023 : IgNet("iguana-source") 00024 { 00025 logme() << "INFO: serving data at port " << port << '\n'; 00026 debug(verbose); 00027 startLocalServer(port); 00028 } 00029 00030 virtual bool 00031 shouldStop(void) 00032 { 00033 return s_stop > 0; 00034 } 00035 }; 00036 00037 static void 00038 onInterrupt(int /* sig */) 00039 { 00040 s_stop++; 00041 } 00042 00043 static char 00044 onAssertFail(const char *message) 00045 { 00046 std::cout.flush(); 00047 fflush(stdout); 00048 std::cerr.flush(); 00049 fflush(stderr); 00050 std::cerr << message << "ABORTING\n"; 00051 return 'a'; 00052 } 00053 00054 #endif // ANALYZER_IGUANA_NET_PRODUCER_H