コード例 #1
0
bool PluginManagerImpl::check_plugin_input(const app_PluginInputDefinitionRef &def,
                                           const grt::ValueRef &value)
{
  if (def.is_instance(app_PluginFileInput::static_class_name()))
  {
    if (value.is_valid() && value.type() != StringType)
      return false;
  }
  else if (def.is_instance(app_PluginSelectionInput::static_class_name()))
  {
    if (!value.is_valid() || value.type() != ListType)
      return false;

    app_PluginSelectionInputRef sdef(app_PluginSelectionInputRef::cast_from(def));
    grt::ObjectListRef olist(grt::ObjectListRef::cast_from(value));

    for (size_t d= olist.count(), j= 0; j < d; j++)
    {
      grt::ObjectRef value(olist.get(j));
      bool ok= false;

      for (size_t c= sdef->objectStructNames().count(), i= 0; i < c; i++)
      {
        if (value.is_instance(sdef->objectStructNames()[i]))
        {
          ok= true;
          break;
        }
      }
      if (!ok)
        return false;
    }

    std::string card= *sdef->argumentCardinality();
    if (card == "1")
    {
      if (olist.count() != 1)
        return false;
    }
    else if (card == "?")
    {
      if (olist.count() > 1)
        return false;
    }
    else if (card == "+")
    {
      if (olist.count() == 0)
        return false;
    }
    else if (card == "*")
      ;
    else
    {
      if (olist.count() != 1)
        return false;
    }
  }
  else if (def.is_instance(app_PluginObjectInput::static_class_name()))
  {
    if (!value.is_valid() || value.type() != ObjectType)
      return false;

    app_PluginObjectInputRef odef(app_PluginObjectInputRef::cast_from(def));

    if (!grt::ObjectRef::cast_from(value).is_instance(odef->objectStructName()))
      return false;
  }
  else
    return false;

  return true;
}
コード例 #2
0
static grt::ValueRef normal_test_function() {
  return grt::IntegerRef(123);
}

TEST_FUNCTION(1) {
  // test callbacks
  grt::ValueRef result;
  bool finish_called = false;

  bec::GRTTask::Ref task = GRTTask::create_task("test", _dispatcher, std::bind(normal_test_function));
  task->signal_finished()->connect(std::bind(&finished, std::placeholders::_1, &finish_called));

  result = _dispatcher->add_task_and_wait(task);

  ensure("result", result.is_valid() && result.type() == grt::IntegerType);
  ensure_equals("result value", *grt::IntegerRef::cast_from(result), 123);

  ensure("finish callback called", finish_called);

  finish_called = false;
  task = GRTTask::create_task("test", _dispatcher, std::bind(normal_test_function));
  task->signal_finished()->connect(std::bind(&finished_with_wait, std::placeholders::_1, &finish_called));

  result = _dispatcher->add_task_and_wait(task);

  ensure("finish callback called with wait", finish_called);
}

TEST_FUNCTION(5) {
  // test msg queue