// Copyright (C) 2019 by Joseph Mirabel, LAAS-CNRS.
//
// This file is part of the hpp-corbaserver.
//
// This software is provided "as is" without warranty of any kind,
// either expressed or implied, including but not limited to the
// implied warranties of fitness for a particular purpose.
//
// See the COPYING file for more information.

#ifndef HPP_CORE_PATH_VALIDATIONS_IDL
#define HPP_CORE_PATH_VALIDATIONS_IDL
#include <hpp/common.idl>

#include <hpp/core_idl/paths.idl>

#define HPP_CORE_OBSTACLE_USER_INTERFACE                                       \
   void setSecurityMargins(in floatSeqSeq margins) raises(Error); \
   void setSecurityMarginBetweenBodies(in string body_a, in string body_b, in value_type margin) raises(Error); \
   void filterCollisionPairs (in RelativeMotionMatrix relMotion) raises(Error);


module hpp
{
  module core_idl {
  typedef string ValidationReport;
  typedef string PathValidationReport;
  typedef intSeqSeq RelativeMotionMatrix;

  interface ConfigValidation
  {
    HPP_EXPOSE_MEMORY_DEALLOCATION(Error)

    boolean validate (in floatSeq config, out ValidationReport report) raises (Error);
    //* using namespace hpp::core;
    //* ValidationReportPtr_t vr;
    //*
    //* bool res = get()->validate (hpp::corbaServer::floatSeqToVector(config), vr);
    //*
    //* if (vr) {
    //*   std::ostringstream oss; oss << *vr;
    //*   std::string res = oss.str();
    //*   report = CORBA::string_dup(res.c_str());
    //* } else {
    //*   report = CORBA::string_dup("");
    //* }
    //*
    //* return res;
  }; // interface ConfigValidation

  interface ConfigValidations : ConfigValidation
  {
      void add (in ConfigValidation validation) raises (Error);
      size_type numberConfigValidations() raises (Error);
      void clear() raises (Error);

      HPP_CORE_OBSTACLE_USER_INTERFACE
  }; // interface ConfigValidations

  interface CollisionValidation : ConfigValidation
  {
      HPP_CORE_OBSTACLE_USER_INTERFACE
  }; // interface PathValidations

  interface PathValidation
  {
    HPP_EXPOSE_MEMORY_DEALLOCATION(Error)

    boolean validate (in Path p, in boolean reverse, out Path validPart, out PathValidationReport report) raises (Error);
    //* using namespace hpp::core;
    //* PathPtr_t _p (::hpp::corbaServer::reference_to_servant_base<core::Path>(server_, p)->get());
    //* PathPtr_t vp;
    //* PathValidationReportPtr_t pvr;
    //*
    //* bool res = get()->validate (_p, reverse, vp, pvr);
    //*
    //* if (pvr) {
    //*   std::ostringstream oss; oss << *pvr;
    //*   std::string res = oss.str();
    //*   report = CORBA::string_dup(res.c_str());
    //* } else {
    //*   report = CORBA::string_dup("");
    //* }
    //*
    //* validPart = ::hpp::corbaServer::makeServant<hpp::core_idl::Path_ptr> (server_, new Path (server_, vp));
    //* return res;

    boolean validateConfiguration (in floatSeq config,
                                   out ValidationReport report) raises (Error);
    //* using namespace hpp::core;
    //* Configuration_t q(corbaServer::floatSeqToVector(config));
    //* ValidationReportPtr_t vr;
    //* bool res = get()->validate(q, vr);
    //* if (vr) {
    //*   std::ostringstream oss; oss << *vr;
    //*   std::string res = oss.str();
    //*   report = CORBA::string_dup(res.c_str());
    //* } else {
    //*   report = CORBA::string_dup("");
    //* }
    //* return res;
  }; // interface SteeringMethod

  interface PathValidations : PathValidation
  {
      HPP_CORE_OBSTACLE_USER_INTERFACE
  }; // interface PathValidations

  interface ContinuousValidation : PathValidation
  {
      HPP_CORE_OBSTACLE_USER_INTERFACE

      void setBreakDistance(in value_type breakDistance) raises (Error);
      //-> breakDistance

      value_type getBreakDistance() raises (Error);
      //-> breakDistance
  }; // interface PathValidations

  module pathValidation_idl {
    // \todo at the moment, multiple parent classes is not supported.
    interface Discretized : PathValidation
    {
        HPP_CORE_OBSTACLE_USER_INTERFACE
    }; // interface PathValidations
  }; // module pathValidation

  }; // module core
}; // module hpp
//* #include <hpp/core/config-validation.hh>
//* #include <hpp/core/config-validations.hh>
//* #include <hpp/core/collision-validation.hh>
//* #include <hpp/core/path-validation.hh>
//* #include <hpp/core/path-validations.hh>
//* #include <hpp/core/path-validation-report.hh>
//* #include <hpp/core/path-validation/discretized.hh>
//* #include <hpp/core/continuous-validation.hh>
//* #include <hpp/core_idl/paths.hh>
//* #include <hpp/corbaserver/conversions.hh>

#endif // HPP_CORE_PATH_VALIDATIONS_IDL
