Esempio n. 1
0
  IPlugInInfo* PlugIn::info()
  {
    Symbol symbol;
    try
    {
      symbol = this->find_symbol(kGetInfoSymbol);
    }
    catch(yat::Exception& ex)
    {
      RETHROW_YAT_ERROR(ex,
                        "SHAREDLIBRARY_ERROR",
                        "Unable to find the 'GetInfo' symbol",
                        "PlugIn::info");
    }

    GetInfoFunc_t get_info_func = (GetInfoFunc_t)(symbol);

    IPlugInInfo* info = 0;
    try
    {
      info = (*get_info_func)();
    }
    catch(...)
    {
      THROW_YAT_ERROR("UNKNOWN_ERROR",
                      "Unknown error during IPlugInInfo instantiation",
                      "PlugIn::info");
    }
    return info;
  }
Esempio n. 2
0
  void PlugIn::release_library()
  {
    try
    {
      if ( m_libraryHandle != NULL )
      {
        Symbol sym = this->find_symbol(kOnUnLoadSymbol);

        OnUnLoadFunc_t unload_func = (OnUnLoadFunc_t)(sym);
        unload_func();

        this->do_release_library();
        m_libraryHandle = NULL;
      }
    }
    catch(yat::Exception& ex)
    {
      RETHROW_YAT_ERROR(ex,
                        "SHAREDLIBRARY_ERROR",
                        "Error while releasing library",
                        "PlugIn::release_library");
    }
    catch (...)
    {
      THROW_YAT_ERROR("SHAREDLIBRARY_ERROR",
                      "Unknown error while releasing library",
                      "PlugIn::release_library");
    }
  }
Esempio n. 3
0
  void PlugIn::load_library( const std::string &library_file_name )
  {
    try
    {
      this->release_library();
      m_libraryHandle = this->do_load_library( library_file_name );
      if ( m_libraryHandle == NULL )
      {
        THROW_YAT_ERROR("SHAREDLIBRARY_ERROR",
                        "Unable to load the specified shared library",
                        "PlugIn::load_library");
      }

      Symbol sym = this->find_symbol(kOnLoadSymbol);

      OnLoadFunc_t load_func = (OnLoadFunc_t)(sym);
      load_func();

    }
    catch(yat::Exception& ex)
    {
      RETHROW_YAT_ERROR(ex,
                        "SHAREDLIBRARY_ERROR",
                        "Error while loading library",
                        "PlugIn::load_library");
    }
    catch (...)
    {
      THROW_YAT_ERROR("SHAREDLIBRARY_ERROR",
                      "Unknown error while loading library",
                      "PlugIn::load_library");
    }

  }
Esempio n. 4
0
  IPlugInFactory* PlugIn::factory()
  {
    Symbol symbol;
    try
    {
      symbol = this->find_symbol(kGetFactorySymbol);
    }
    catch(yat::Exception& ex)
    {
      RETHROW_YAT_ERROR(ex,
                        "SHAREDLIBRARY_ERROR",
                        "Unable to find the 'GetFactory' symbol",
                        "PlugIn::factory");
    }

    GetFactoryFunc_t get_factory_func = (GetFactoryFunc_t)(symbol);

    IPlugInFactory* factory = 0;
    try
    {
      factory = (*get_factory_func)();
    }
    catch(...)
    {
      THROW_YAT_ERROR("UNKNOWN_ERROR",
                      "Unknown error during factory instantiation",
                      "PlugIn::factory");
    }
    return factory;
  }
Esempio n. 5
0
// ============================================================================
// Task::go
// ============================================================================
void Task::go (size_t _tmo_ms) 
  throw (Exception)
{
  YAT_TRACE("Task::go");
 
  this->start_undetached();

  Message * msg = 0;
  try
  {
    msg = Message::allocate (TASK_INIT, INIT_MSG_PRIORITY, true);
  }
  catch (Exception& ex)
  {
    RETHROW_YAT_ERROR(ex, 
                      "OUT_OF_MEMORY", 
                      "Message allocation failed", 
                      "Task::go");
  }

  this->wait_msg_handled (msg, _tmo_ms);
}
Esempio n. 6
0
/*static*/
isl::Image* IBASourceBypass::convert_image_grabber_to_isl(const GrabAPI::Image* gimage) throw (yat::Exception)
{
  try {
    isl::Image* image = new isl::Image(gimage->width(), gimage->height(), isl::ISL_STORAGE_USHORT);
    image->unserialize(gimage->base());
    return image;
  } catch(isl::Exception & ex) {
    GrabAPI::ISL2YATException yat_exc(ex);
    isl::ErrorHandler::reset();
    RETHROW_YAT_ERROR(yat_exc,
                      "SOFTWARE_FAILURE",
                      "Unable to convert from GrabAPI::Image to isl::Image.",
                      "IBASourceBypass::convert_image_grabber_to_isl.");
  } catch(std::bad_alloc &) {
    THROW_YAT_ERROR("OUT_OF_MEMORY",
                    "Allocation of isl::Image failed [std::bad_alloc]",
                    "IBASourceBypass::convert_image_grabber_to_isl");
  } catch(...) {
     THROW_YAT_ERROR("UNKNOWN_ERROR",
                    "Unable to convert from GrabAPI::Image to isl::Image. [Unknown exception caught]",
                    "IBASourceBypass::convert_image_grabber_to_isl");
  }
}
Esempio n. 7
0
// ======================================================================
// Task::exit
// ======================================================================
void Task::exit () 
  throw (Exception)
{
  YAT_TRACE("Task::exit");

  //- we may have to implicitly delete the thread
  bool delete_self = false;

  //- enter critical section
  this->m_lock.lock();

  //- get underlying thread state
  Thread::State ts = this->state_i();

  //- if the thread is running, then ask it to exit
  if (ts == yat::Thread::STATE_RUNNING)
  {
    yat::Message * msg = 0;
    try
    {
      msg = Message::allocate (yat::TASK_EXIT, EXIT_MSG_PRIORITY, true);
    }
    catch (Exception &ex)
    {
      this->m_lock.unlock();
      RETHROW_YAT_ERROR(ex, 
                        "SOFTWARE_ERROR", 
                        "Could not stop task [yat::Message allocation failed]", 
                        "Task::exit");
    }
    catch (...)
    {
      this->m_lock.unlock();
      THROW_YAT_ERROR("UNKNOWN_ERROR", 
                      "Could not stop task [yat::Message allocation failed]", 
                      "Task::exit");
    }
    //- unlock the thread lock (avoid deadlock during message handling)
    this->m_lock.unlock();
    try
    {
      //- ... then wait for TASK_EXIT msg to be handled
      //- TODO: change kINFINITE_WAIT to a more flexible TIMEOUT
      YAT_LOG("Task::exit - waiting for the TASK_EXIT msg to be handled");
      this->wait_msg_handled (msg, kINFINITE_WAIT);
    }
    catch (...)
    {
      //- ignore any error
    }
    //- wait for the thread to actually quit
    try
    {
      Thread::IOArg dummy = 0;
      YAT_LOG("Task::exit - about to join with the underlying thread");
      this->join (&dummy);
    }
    catch (...)
    {
     //- ignore any error
    }
  }
  else if (ts == yat::Thread::STATE_NEW) 
  {
    //- delete the thread (instanciated but never been started)
    YAT_LOG("Task::exit - about to delete the thread [has never been started]");
    delete_self = true;
    //- leave critical section
    this->m_lock.unlock();
  }
  else
  {
    //- nothing to do...
    YAT_LOG("Task::exit - do nothing");
    //- leave critical section
    this->m_lock.unlock();
  }

  //- delete (if required)
  if (delete_self)
  {
    YAT_LOG("Task::exit - deleting <this> Task instance");
    delete this;
  }
}