Exemplo n.º 1
0
    V8Result MarshalFromNative(const RGBDistribution& d)
    {
        TRACE_FUNCTION;
        NanEscapableScope();

        Local<Object> structure = NanNew<Object>();
        NodeObject resultWrapper(structure);

        resultWrapper["b"] = d.b;
        resultWrapper["g"] = d.g;
        resultWrapper["r"] = d.r;

        return NanEscapeScope(structure);
    }
Exemplo n.º 2
0
    V8Result MarshalFromNative(const DominantColor& d)
    {
        TRACE_FUNCTION;
        NanEscapableScope();

        Local<Object> structure = NanNew<Object>();
        NodeObject resultWrapper(structure);

        resultWrapper["average"] = d.color;
        resultWrapper["entropy"] = d.error;
        resultWrapper["max"] = d.interclassVariance;
        resultWrapper["min"] = d.totalPixels;
        resultWrapper["html"] = d.html();

        return NanEscapeScope(structure);
    }
Exemplo n.º 3
0
    V8Result MarshalFromNative(const Distribution& d)
    {
        TRACE_FUNCTION;
        NanEscapableScope();

        Local<Object> structure = NanNew<Object>();
        NodeObject resultWrapper(structure);

        resultWrapper["average"] = d.average;
        resultWrapper["entropy"] = d.entropy;
        resultWrapper["max"] = d.max;
        resultWrapper["min"] = d.min;
        resultWrapper["standardDeviation"] = d.standardDeviation;

        return NanEscapeScope(structure);
    }
Exemplo n.º 4
0
    V8Result MarshalFromNative(const AnalyzeResult& res)
    {
        TRACE_FUNCTION;
        NanEscapableScope();

        Local<Object> structure = NanNew<Object>();
        NodeObject resultWrapper(structure);

        resultWrapper["aspectRatio"] = res.aspectRatio;
        resultWrapper["colorDeviation"] = res.colorDeviation;
        resultWrapper["dominantColors"] = res.dominantColors;
        resultWrapper["frameSize"] = res.frameSize;
        resultWrapper["histogram"] = res.histogram;
        resultWrapper["intensity"] = res.intensity;
        resultWrapper["reducedColors"] = res.reducedColors;
        resultWrapper["rmsContrast"] = res.rmsContrast;
        resultWrapper["uniqueColors"] = res.uniqieColors;

        return NanEscapeScope(structure);
    }
Exemplo n.º 5
0
SqlTaskReturnType EntityTemplate::loadTemplate(sql::Connection *c, std::size_t id)
{
  std::shared_ptr<ISqlResult> resultWrapper(new ISqlResult());
  if (!c)
    return resultWrapper;

  EntityTemplate *eTpl = new EntityTemplate();

  try
    {
      std::shared_ptr<sql::PreparedStatement> pstmt(c->prepareStatement("SELECT id, name, script_name, shape_id, affect_nav_mesh FROM entity_template WHERE id = (?)"));
      std::shared_ptr<sql::ResultSet> res;
      pstmt->setInt(1, id);

      res = std::shared_ptr<sql::ResultSet > (pstmt->executeQuery());
      while (res->next())
        {
          eTpl->id_ = res->getInt("id");
          eTpl->name_ = res->getString("name");
          eTpl->scriptName_ = res->getString("script_name");
          eTpl->shape_id = res->getInt("shape_id");
          eTpl->affectNavMesh_ = res->getBoolean("affect_nav_mesh");
          INFO("SQL REPLIES: " << res->getString("name") << " with id " << res->getInt("id") << " with scriptName " << res->getString("script_name"));
        }

      resultWrapper->error_ = false;
      resultWrapper->result_ = eTpl;

      return resultWrapper;
    }
  catch (sql::SQLException &e)
    {
      ERROR("SQL Exception:" << e.what() << " (MySQL error code: " << e.getErrorCode() << ", SQLState: " << e.getSQLState() << " )");
      resultWrapper->error_ = true;
      resultWrapper->result_ = nullptr;
      delete eTpl;
      return resultWrapper;
    }
}