23 #ifndef ICE_APPLICATION_BASE_H
24 #define ICE_APPLICATION_BASE_H
34 #include <boost/thread.hpp>
35 #include <boost/thread/mutex.hpp>
43 static const unsigned int ICEAPPLICATION_ACTIVATION_TIMEOUT_MS(600);
60 int run(
int,
char*[]);
63 template<
typename TserverBase,
typename TserverClass>
71 static TserverBase*
i();
72 static const std::vector<std::string>
endpoints();
79 virtual TserverBase*
i_impl() = 0;
92 void starticeexample();
94 bool application_started();
96 int run(
int,
char*[]);
98 static void kickoff();
101 template<
typename TserverBase,
typename TserverClass>
107 template<
typename TserverBase,
typename TserverClass>
116 template<
typename TserverBase,
typename TserverClass>
124 if(conffile.size() > 0) {
125 std::stringstream iceconf;
129 d_application->main(0, argv, iceconf.str().c_str());
134 d_application->main(0, argv);
138 template<
typename TserverBase,
typename TserverClass>
141 static bool run_once =
false;
148 (
new boost::thread(boost::bind(&ice_application_base::starticeexample, d_this)));
150 ::timespec timer_ts, rem_ts;
151 timer_ts.tv_sec = 0; timer_ts.tv_nsec = ICEAPPLICATION_ACTIVATION_TIMEOUT_MS*1000;
154 while(!d_this->application_started()) {
155 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
156 ::Sleep(timer_ts.tv_nsec / 1000000);
158 ::nanosleep(&timer_ts, &rem_ts);
160 if(!d_this->application_started())
163 std::cout <<
"ice_application_base::kickoff(), timeout waiting to get communicator() d_application->main() might have failed?!" << std::endl;;
175 template<
typename TserverBase,
typename TserverClass>
178 return (d_this->d_reacquire != d_application->d_reacquire_attributes);
181 template<
typename TserverBase,
typename TserverClass>
184 d_this->d_reacquire = d_application->d_reacquire_attributes;
188 template<
typename TserverBase,
typename TserverClass>
191 std::vector<std::string> ep; ep.push_back(d_this->d_application->d_endpointStr);
return ep;
194 template<
typename TserverBase,
typename TserverClass>
200 if(!d_this->application_started()) {
211 return d_this->i_impl();
221 template<
typename TserverBase,
typename TImplClass>
Definition: ice_application_base.h:64
static bool d_have_ice_config
Definition: ice_application_base.h:56
Definition: ice_application_base.h:46
ice_application_base(TserverClass *_this)
Definition: ice_application_base.h:108
static bool d_main_called
Definition: ice_application_base.h:55
static TserverClass * d_this
Definition: ice_application_base.h:86
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
virtual TserverBase * i_impl()=0
static TserverBase * i()
Definition: ice_application_base.h:195
static boost::shared_ptr< ice_application_common > Instance()
boost::thread thread
Definition: thread.h:45
static boost::shared_ptr< boost::thread > d_thread
Definition: ice_application_base.h:58
~ice_application_common()
Definition: ice_application_base.h:51
ice_application_common()
Definition: ice_application_base.h:59
~ice_application_base()
Definition: ice_application_base.h:69
virtual const std::string get_string(const std::string §ion, const std::string &option, const std::string &default_val)
If option exists return associated value; else default_val.
virtual void sync_reacquire()
Definition: ice_application_base.h:182
int d_reacquire
Definition: ice_application_base.h:88
static prefs * singleton()
static int d_reacquire_attributes
Definition: ice_application_base.h:52
void set_endpoint(const std::string &endpoint)
Definition: ice_application_base.h:76
bool have_ice_config()
Definition: ice_application_base.h:75
static std::string d_endpointStr
Definition: ice_application_base.h:57
Definition: pycallback_object.h:35
virtual bool reacquire_sync()
Definition: ice_application_base.h:176
static const std::vector< std::string > endpoints()
Definition: ice_application_base.h:189
boost::shared_ptr< ice_application_common > d_application
Definition: ice_application_base.h:67