text:
// This file is auto-generated, don't edit it. Thanks.

#ifndef ALIBABACLOUD_DPLUS20201216_H_
#define ALIBABACLOUD_DPLUS20201216_H_

#include <alibabacloud/open_api.hpp>
#include <boost/any.hpp>
#include <boost/throw_exception.hpp>
#include <darabonba/core.hpp>
#include <darabonba/util.hpp>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

namespace Alibabacloud_Dplus20201216 {
class AePredictCategoryRequest : public Darabonba::Model {
public:
  shared_ptr<string> picUrl{};

  AePredictCategoryRequest() {}

  explicit AePredictCategoryRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrl) {
      res["PicUrl"] = boost::any(*picUrl);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrl") != m.end() && !m["PicUrl"].empty()) {
      picUrl = make_shared<string>(boost::any_cast<string>(m["PicUrl"]));
    }
  }

  virtual ~AePredictCategoryRequest() = default;
};
class AePredictCategoryAdvanceRequest : public Darabonba::Model {
public:
  shared_ptr<Darabonba::Stream> picUrlObject{};

  AePredictCategoryAdvanceRequest() {}

  explicit AePredictCategoryAdvanceRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!picUrlObject) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("picUrlObject is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrlObject) {
      res["PicUrlObject"] = boost::any(*picUrlObject);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrlObject") != m.end() && !m["PicUrlObject"].empty()) {
      picUrlObject = make_shared<Darabonba::Stream>(boost::any_cast<Darabonba::Stream>(m["PicUrlObject"]));
    }
  }

  virtual ~AePredictCategoryAdvanceRequest() = default;
};
class AePredictCategoryResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<map<string, boost::any>> body{};

  AePredictCategoryResponse() {}

  explicit AePredictCategoryResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = boost::any(*body);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      map<string, boost::any> map1 = boost::any_cast<map<string, boost::any>>(m["body"]);
      map<string, boost::any> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      body = make_shared<map<string, boost::any>>(toMap1);
    }
  }

  virtual ~AePredictCategoryResponse() = default;
};
class AePropRecRequest : public Darabonba::Model {
public:
  shared_ptr<string> picUrl{};

  AePropRecRequest() {}

  explicit AePropRecRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrl) {
      res["PicUrl"] = boost::any(*picUrl);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrl") != m.end() && !m["PicUrl"].empty()) {
      picUrl = make_shared<string>(boost::any_cast<string>(m["PicUrl"]));
    }
  }

  virtual ~AePropRecRequest() = default;
};
class AePropRecAdvanceRequest : public Darabonba::Model {
public:
  shared_ptr<Darabonba::Stream> picUrlObject{};

  AePropRecAdvanceRequest() {}

  explicit AePropRecAdvanceRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!picUrlObject) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("picUrlObject is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrlObject) {
      res["PicUrlObject"] = boost::any(*picUrlObject);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrlObject") != m.end() && !m["PicUrlObject"].empty()) {
      picUrlObject = make_shared<Darabonba::Stream>(boost::any_cast<Darabonba::Stream>(m["PicUrlObject"]));
    }
  }

  virtual ~AePropRecAdvanceRequest() = default;
};
class AePropRecResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<map<string, boost::any>> body{};

  AePropRecResponse() {}

  explicit AePropRecResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = boost::any(*body);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      map<string, boost::any> map1 = boost::any_cast<map<string, boost::any>>(m["body"]);
      map<string, boost::any> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      body = make_shared<map<string, boost::any>>(toMap1);
    }
  }

  virtual ~AePropRecResponse() = default;
};
class AlivisionImgdupRequest : public Darabonba::Model {
public:
  shared_ptr<long> imageHeight{};
  shared_ptr<long> imageWidth{};
  shared_ptr<long> outputImageNum{};
  shared_ptr<long> picNum{};
  shared_ptr<string> picUrl{};

  AlivisionImgdupRequest() {}

  explicit AlivisionImgdupRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (imageHeight) {
      res["ImageHeight"] = boost::any(*imageHeight);
    }
    if (imageWidth) {
      res["ImageWidth"] = boost::any(*imageWidth);
    }
    if (outputImageNum) {
      res["OutputImageNum"] = boost::any(*outputImageNum);
    }
    if (picNum) {
      res["PicNum"] = boost::any(*picNum);
    }
    if (picUrl) {
      res["PicUrl"] = boost::any(*picUrl);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("ImageHeight") != m.end() && !m["ImageHeight"].empty()) {
      imageHeight = make_shared<long>(boost::any_cast<long>(m["ImageHeight"]));
    }
    if (m.find("ImageWidth") != m.end() && !m["ImageWidth"].empty()) {
      imageWidth = make_shared<long>(boost::any_cast<long>(m["ImageWidth"]));
    }
    if (m.find("OutputImageNum") != m.end() && !m["OutputImageNum"].empty()) {
      outputImageNum = make_shared<long>(boost::any_cast<long>(m["OutputImageNum"]));
    }
    if (m.find("PicNum") != m.end() && !m["PicNum"].empty()) {
      picNum = make_shared<long>(boost::any_cast<long>(m["PicNum"]));
    }
    if (m.find("PicUrl") != m.end() && !m["PicUrl"].empty()) {
      picUrl = make_shared<string>(boost::any_cast<string>(m["PicUrl"]));
    }
  }

  virtual ~AlivisionImgdupRequest() = default;
};
class AlivisionImgdupAdvanceRequest : public Darabonba::Model {
public:
  shared_ptr<Darabonba::Stream> picUrlObject{};
  shared_ptr<long> imageHeight{};
  shared_ptr<long> imageWidth{};
  shared_ptr<long> outputImageNum{};
  shared_ptr<long> picNum{};

  AlivisionImgdupAdvanceRequest() {}

  explicit AlivisionImgdupAdvanceRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!picUrlObject) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("picUrlObject is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrlObject) {
      res["PicUrlObject"] = boost::any(*picUrlObject);
    }
    if (imageHeight) {
      res["ImageHeight"] = boost::any(*imageHeight);
    }
    if (imageWidth) {
      res["ImageWidth"] = boost::any(*imageWidth);
    }
    if (outputImageNum) {
      res["OutputImageNum"] = boost::any(*outputImageNum);
    }
    if (picNum) {
      res["PicNum"] = boost::any(*picNum);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrlObject") != m.end() && !m["PicUrlObject"].empty()) {
      picUrlObject = make_shared<Darabonba::Stream>(boost::any_cast<Darabonba::Stream>(m["PicUrlObject"]));
    }
    if (m.find("ImageHeight") != m.end() && !m["ImageHeight"].empty()) {
      imageHeight = make_shared<long>(boost::any_cast<long>(m["ImageHeight"]));
    }
    if (m.find("ImageWidth") != m.end() && !m["ImageWidth"].empty()) {
      imageWidth = make_shared<long>(boost::any_cast<long>(m["ImageWidth"]));
    }
    if (m.find("OutputImageNum") != m.end() && !m["OutputImageNum"].empty()) {
      outputImageNum = make_shared<long>(boost::any_cast<long>(m["OutputImageNum"]));
    }
    if (m.find("PicNum") != m.end() && !m["PicNum"].empty()) {
      picNum = make_shared<long>(boost::any_cast<long>(m["PicNum"]));
    }
  }

  virtual ~AlivisionImgdupAdvanceRequest() = default;
};
class AlivisionImgdupResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<map<string, boost::any>> body{};

  AlivisionImgdupResponse() {}

  explicit AlivisionImgdupResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = boost::any(*body);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      map<string, boost::any> map1 = boost::any_cast<map<string, boost::any>>(m["body"]);
      map<string, boost::any> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      body = make_shared<map<string, boost::any>>(toMap1);
    }
  }

  virtual ~AlivisionImgdupResponse() = default;
};
class CreateImageAmazonTaskRequest : public Darabonba::Model {
public:
  shared_ptr<bool> gif{};
  shared_ptr<vector<string>> imgUrlList{};
  shared_ptr<string> templateMode{};
  shared_ptr<vector<string>> textList{};

  CreateImageAmazonTaskRequest() {}

  explicit CreateImageAmazonTaskRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (gif) {
      res["Gif"] = boost::any(*gif);
    }
    if (imgUrlList) {
      res["ImgUrlList"] = boost::any(*imgUrlList);
    }
    if (templateMode) {
      res["TemplateMode"] = boost::any(*templateMode);
    }
    if (textList) {
      res["TextList"] = boost::any(*textList);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("Gif") != m.end() && !m["Gif"].empty()) {
      gif = make_shared<bool>(boost::any_cast<bool>(m["Gif"]));
    }
    if (m.find("ImgUrlList") != m.end() && !m["ImgUrlList"].empty()) {
      vector<string> toVec1;
      if (typeid(vector<boost::any>) == m["ImgUrlList"].type()) {
        vector<boost::any> vec1 = boost::any_cast<vector<boost::any>>(m["ImgUrlList"]);
        for (auto item:vec1) {
           toVec1.push_back(boost::any_cast<string>(item));
        }
      }
      imgUrlList = make_shared<vector<string>>(toVec1);
    }
    if (m.find("TemplateMode") != m.end() && !m["TemplateMode"].empty()) {
      templateMode = make_shared<string>(boost::any_cast<string>(m["TemplateMode"]));
    }
    if (m.find("TextList") != m.end() && !m["TextList"].empty()) {
      vector<string> toVec1;
      if (typeid(vector<boost::any>) == m["TextList"].type()) {
        vector<boost::any> vec1 = boost::any_cast<vector<boost::any>>(m["TextList"]);
        for (auto item:vec1) {
           toVec1.push_back(boost::any_cast<string>(item));
        }
      }
      textList = make_shared<vector<string>>(toVec1);
    }
  }

  virtual ~CreateImageAmazonTaskRequest() = default;
};
class CreateImageAmazonTaskShrinkRequest : public Darabonba::Model {
public:
  shared_ptr<bool> gif{};
  shared_ptr<string> imgUrlListShrink{};
  shared_ptr<string> templateMode{};
  shared_ptr<string> textListShrink{};

  CreateImageAmazonTaskShrinkRequest() {}

  explicit CreateImageAmazonTaskShrinkRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (gif) {
      res["Gif"] = boost::any(*gif);
    }
    if (imgUrlListShrink) {
      res["ImgUrlList"] = boost::any(*imgUrlListShrink);
    }
    if (templateMode) {
      res["TemplateMode"] = boost::any(*templateMode);
    }
    if (textListShrink) {
      res["TextList"] = boost::any(*textListShrink);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("Gif") != m.end() && !m["Gif"].empty()) {
      gif = make_shared<bool>(boost::any_cast<bool>(m["Gif"]));
    }
    if (m.find("ImgUrlList") != m.end() && !m["ImgUrlList"].empty()) {
      imgUrlListShrink = make_shared<string>(boost::any_cast<string>(m["ImgUrlList"]));
    }
    if (m.find("TemplateMode") != m.end() && !m["TemplateMode"].empty()) {
      templateMode = make_shared<string>(boost::any_cast<string>(m["TemplateMode"]));
    }
    if (m.find("TextList") != m.end() && !m["TextList"].empty()) {
      textListShrink = make_shared<string>(boost::any_cast<string>(m["TextList"]));
    }
  }

  virtual ~CreateImageAmazonTaskShrinkRequest() = default;
};
class CreateImageAmazonTaskResponseBody : public Darabonba::Model {
public:
  shared_ptr<long> code{};
  shared_ptr<long> data{};
  shared_ptr<string> message{};
  shared_ptr<string> requestId{};
  shared_ptr<bool> successResponse{};

  CreateImageAmazonTaskResponseBody() {}

  explicit CreateImageAmazonTaskResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (code) {
      res["Code"] = boost::any(*code);
    }
    if (data) {
      res["Data"] = boost::any(*data);
    }
    if (message) {
      res["Message"] = boost::any(*message);
    }
    if (requestId) {
      res["RequestId"] = boost::any(*requestId);
    }
    if (successResponse) {
      res["SuccessResponse"] = boost::any(*successResponse);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("Code") != m.end() && !m["Code"].empty()) {
      code = make_shared<long>(boost::any_cast<long>(m["Code"]));
    }
    if (m.find("Data") != m.end() && !m["Data"].empty()) {
      data = make_shared<long>(boost::any_cast<long>(m["Data"]));
    }
    if (m.find("Message") != m.end() && !m["Message"].empty()) {
      message = make_shared<string>(boost::any_cast<string>(m["Message"]));
    }
    if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
      requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
    }
    if (m.find("SuccessResponse") != m.end() && !m["SuccessResponse"].empty()) {
      successResponse = make_shared<bool>(boost::any_cast<bool>(m["SuccessResponse"]));
    }
  }

  virtual ~CreateImageAmazonTaskResponseBody() = default;
};
class CreateImageAmazonTaskResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<CreateImageAmazonTaskResponseBody> body{};

  CreateImageAmazonTaskResponse() {}

  explicit CreateImageAmazonTaskResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      if (typeid(map<string, boost::any>) == m["body"].type()) {
        CreateImageAmazonTaskResponseBody model1;
        model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
        body = make_shared<CreateImageAmazonTaskResponseBody>(model1);
      }
    }
  }

  virtual ~CreateImageAmazonTaskResponse() = default;
};
class FaceshifterTRequest : public Darabonba::Model {
public:
  shared_ptr<long> age{};
  shared_ptr<long> gender{};
  shared_ptr<string> picUrl{};
  shared_ptr<long> race{};

  FaceshifterTRequest() {}

  explicit FaceshifterTRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (age) {
      res["Age"] = boost::any(*age);
    }
    if (gender) {
      res["Gender"] = boost::any(*gender);
    }
    if (picUrl) {
      res["PicUrl"] = boost::any(*picUrl);
    }
    if (race) {
      res["Race"] = boost::any(*race);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("Age") != m.end() && !m["Age"].empty()) {
      age = make_shared<long>(boost::any_cast<long>(m["Age"]));
    }
    if (m.find("Gender") != m.end() && !m["Gender"].empty()) {
      gender = make_shared<long>(boost::any_cast<long>(m["Gender"]));
    }
    if (m.find("PicUrl") != m.end() && !m["PicUrl"].empty()) {
      picUrl = make_shared<string>(boost::any_cast<string>(m["PicUrl"]));
    }
    if (m.find("Race") != m.end() && !m["Race"].empty()) {
      race = make_shared<long>(boost::any_cast<long>(m["Race"]));
    }
  }

  virtual ~FaceshifterTRequest() = default;
};
class FaceshifterTAdvanceRequest : public Darabonba::Model {
public:
  shared_ptr<Darabonba::Stream> picUrlObject{};
  shared_ptr<long> age{};
  shared_ptr<long> gender{};
  shared_ptr<long> race{};

  FaceshifterTAdvanceRequest() {}

  explicit FaceshifterTAdvanceRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!picUrlObject) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("picUrlObject is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrlObject) {
      res["PicUrlObject"] = boost::any(*picUrlObject);
    }
    if (age) {
      res["Age"] = boost::any(*age);
    }
    if (gender) {
      res["Gender"] = boost::any(*gender);
    }
    if (race) {
      res["Race"] = boost::any(*race);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrlObject") != m.end() && !m["PicUrlObject"].empty()) {
      picUrlObject = make_shared<Darabonba::Stream>(boost::any_cast<Darabonba::Stream>(m["PicUrlObject"]));
    }
    if (m.find("Age") != m.end() && !m["Age"].empty()) {
      age = make_shared<long>(boost::any_cast<long>(m["Age"]));
    }
    if (m.find("Gender") != m.end() && !m["Gender"].empty()) {
      gender = make_shared<long>(boost::any_cast<long>(m["Gender"]));
    }
    if (m.find("Race") != m.end() && !m["Race"].empty()) {
      race = make_shared<long>(boost::any_cast<long>(m["Race"]));
    }
  }

  virtual ~FaceshifterTAdvanceRequest() = default;
};
class FaceshifterTResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<map<string, boost::any>> body{};

  FaceshifterTResponse() {}

  explicit FaceshifterTResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = boost::any(*body);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      map<string, boost::any> map1 = boost::any_cast<map<string, boost::any>>(m["body"]);
      map<string, boost::any> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      body = make_shared<map<string, boost::any>>(toMap1);
    }
  }

  virtual ~FaceshifterTResponse() = default;
};
class GetTaskResultRequest : public Darabonba::Model {
public:
  shared_ptr<long> taskId{};

  GetTaskResultRequest() {}

  explicit GetTaskResultRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (taskId) {
      res["TaskId"] = boost::any(*taskId);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("TaskId") != m.end() && !m["TaskId"].empty()) {
      taskId = make_shared<long>(boost::any_cast<long>(m["TaskId"]));
    }
  }

  virtual ~GetTaskResultRequest() = default;
};
class GetTaskResultResponseBodyData : public Darabonba::Model {
public:
  shared_ptr<string> resuslt{};
  shared_ptr<long> status{};
  shared_ptr<string> statusName{};
  shared_ptr<long> taskId{};

  GetTaskResultResponseBodyData() {}

  explicit GetTaskResultResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (resuslt) {
      res["Resuslt"] = boost::any(*resuslt);
    }
    if (status) {
      res["Status"] = boost::any(*status);
    }
    if (statusName) {
      res["StatusName"] = boost::any(*statusName);
    }
    if (taskId) {
      res["TaskId"] = boost::any(*taskId);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("Resuslt") != m.end() && !m["Resuslt"].empty()) {
      resuslt = make_shared<string>(boost::any_cast<string>(m["Resuslt"]));
    }
    if (m.find("Status") != m.end() && !m["Status"].empty()) {
      status = make_shared<long>(boost::any_cast<long>(m["Status"]));
    }
    if (m.find("StatusName") != m.end() && !m["StatusName"].empty()) {
      statusName = make_shared<string>(boost::any_cast<string>(m["StatusName"]));
    }
    if (m.find("TaskId") != m.end() && !m["TaskId"].empty()) {
      taskId = make_shared<long>(boost::any_cast<long>(m["TaskId"]));
    }
  }

  virtual ~GetTaskResultResponseBodyData() = default;
};
class GetTaskResultResponseBody : public Darabonba::Model {
public:
  shared_ptr<long> code{};
  shared_ptr<GetTaskResultResponseBodyData> data{};
  shared_ptr<string> message{};
  shared_ptr<string> requestId{};
  shared_ptr<bool> successResponse{};

  GetTaskResultResponseBody() {}

  explicit GetTaskResultResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (code) {
      res["Code"] = boost::any(*code);
    }
    if (data) {
      res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
    }
    if (message) {
      res["Message"] = boost::any(*message);
    }
    if (requestId) {
      res["RequestId"] = boost::any(*requestId);
    }
    if (successResponse) {
      res["SuccessResponse"] = boost::any(*successResponse);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("Code") != m.end() && !m["Code"].empty()) {
      code = make_shared<long>(boost::any_cast<long>(m["Code"]));
    }
    if (m.find("Data") != m.end() && !m["Data"].empty()) {
      if (typeid(map<string, boost::any>) == m["Data"].type()) {
        GetTaskResultResponseBodyData model1;
        model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
        data = make_shared<GetTaskResultResponseBodyData>(model1);
      }
    }
    if (m.find("Message") != m.end() && !m["Message"].empty()) {
      message = make_shared<string>(boost::any_cast<string>(m["Message"]));
    }
    if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
      requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
    }
    if (m.find("SuccessResponse") != m.end() && !m["SuccessResponse"].empty()) {
      successResponse = make_shared<bool>(boost::any_cast<bool>(m["SuccessResponse"]));
    }
  }

  virtual ~GetTaskResultResponseBody() = default;
};
class GetTaskResultResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<GetTaskResultResponseBody> body{};

  GetTaskResultResponse() {}

  explicit GetTaskResultResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      if (typeid(map<string, boost::any>) == m["body"].type()) {
        GetTaskResultResponseBody model1;
        model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
        body = make_shared<GetTaskResultResponseBody>(model1);
      }
    }
  }

  virtual ~GetTaskResultResponse() = default;
};
class GetTaskStatusRequest : public Darabonba::Model {
public:
  shared_ptr<long> taskId{};

  GetTaskStatusRequest() {}

  explicit GetTaskStatusRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (taskId) {
      res["TaskId"] = boost::any(*taskId);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("TaskId") != m.end() && !m["TaskId"].empty()) {
      taskId = make_shared<long>(boost::any_cast<long>(m["TaskId"]));
    }
  }

  virtual ~GetTaskStatusRequest() = default;
};
class GetTaskStatusResponseBodyData : public Darabonba::Model {
public:
  shared_ptr<long> status{};
  shared_ptr<string> statusName{};
  shared_ptr<long> taskId{};

  GetTaskStatusResponseBodyData() {}

  explicit GetTaskStatusResponseBodyData(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (status) {
      res["Status"] = boost::any(*status);
    }
    if (statusName) {
      res["StatusName"] = boost::any(*statusName);
    }
    if (taskId) {
      res["TaskId"] = boost::any(*taskId);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("Status") != m.end() && !m["Status"].empty()) {
      status = make_shared<long>(boost::any_cast<long>(m["Status"]));
    }
    if (m.find("StatusName") != m.end() && !m["StatusName"].empty()) {
      statusName = make_shared<string>(boost::any_cast<string>(m["StatusName"]));
    }
    if (m.find("TaskId") != m.end() && !m["TaskId"].empty()) {
      taskId = make_shared<long>(boost::any_cast<long>(m["TaskId"]));
    }
  }

  virtual ~GetTaskStatusResponseBodyData() = default;
};
class GetTaskStatusResponseBody : public Darabonba::Model {
public:
  shared_ptr<long> code{};
  shared_ptr<GetTaskStatusResponseBodyData> data{};
  shared_ptr<string> message{};
  shared_ptr<string> requestId{};
  shared_ptr<bool> successResponse{};

  GetTaskStatusResponseBody() {}

  explicit GetTaskStatusResponseBody(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (code) {
      res["Code"] = boost::any(*code);
    }
    if (data) {
      res["Data"] = data ? boost::any(data->toMap()) : boost::any(map<string,boost::any>({}));
    }
    if (message) {
      res["Message"] = boost::any(*message);
    }
    if (requestId) {
      res["RequestId"] = boost::any(*requestId);
    }
    if (successResponse) {
      res["SuccessResponse"] = boost::any(*successResponse);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("Code") != m.end() && !m["Code"].empty()) {
      code = make_shared<long>(boost::any_cast<long>(m["Code"]));
    }
    if (m.find("Data") != m.end() && !m["Data"].empty()) {
      if (typeid(map<string, boost::any>) == m["Data"].type()) {
        GetTaskStatusResponseBodyData model1;
        model1.fromMap(boost::any_cast<map<string, boost::any>>(m["Data"]));
        data = make_shared<GetTaskStatusResponseBodyData>(model1);
      }
    }
    if (m.find("Message") != m.end() && !m["Message"].empty()) {
      message = make_shared<string>(boost::any_cast<string>(m["Message"]));
    }
    if (m.find("RequestId") != m.end() && !m["RequestId"].empty()) {
      requestId = make_shared<string>(boost::any_cast<string>(m["RequestId"]));
    }
    if (m.find("SuccessResponse") != m.end() && !m["SuccessResponse"].empty()) {
      successResponse = make_shared<bool>(boost::any_cast<bool>(m["SuccessResponse"]));
    }
  }

  virtual ~GetTaskStatusResponseBody() = default;
};
class GetTaskStatusResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<GetTaskStatusResponseBody> body{};

  GetTaskStatusResponse() {}

  explicit GetTaskStatusResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = body ? boost::any(body->toMap()) : boost::any(map<string,boost::any>({}));
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      if (typeid(map<string, boost::any>) == m["body"].type()) {
        GetTaskStatusResponseBody model1;
        model1.fromMap(boost::any_cast<map<string, boost::any>>(m["body"]));
        body = make_shared<GetTaskStatusResponseBody>(model1);
      }
    }
  }

  virtual ~GetTaskStatusResponse() = default;
};
class KuajingSegRequest : public Darabonba::Model {
public:
  shared_ptr<string> picUrl{};
  shared_ptr<string> returnPicFormat{};
  shared_ptr<string> returnPicType{};

  KuajingSegRequest() {}

  explicit KuajingSegRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrl) {
      res["PicUrl"] = boost::any(*picUrl);
    }
    if (returnPicFormat) {
      res["ReturnPicFormat"] = boost::any(*returnPicFormat);
    }
    if (returnPicType) {
      res["ReturnPicType"] = boost::any(*returnPicType);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrl") != m.end() && !m["PicUrl"].empty()) {
      picUrl = make_shared<string>(boost::any_cast<string>(m["PicUrl"]));
    }
    if (m.find("ReturnPicFormat") != m.end() && !m["ReturnPicFormat"].empty()) {
      returnPicFormat = make_shared<string>(boost::any_cast<string>(m["ReturnPicFormat"]));
    }
    if (m.find("ReturnPicType") != m.end() && !m["ReturnPicType"].empty()) {
      returnPicType = make_shared<string>(boost::any_cast<string>(m["ReturnPicType"]));
    }
  }

  virtual ~KuajingSegRequest() = default;
};
class KuajingSegAdvanceRequest : public Darabonba::Model {
public:
  shared_ptr<Darabonba::Stream> picUrlObject{};
  shared_ptr<string> returnPicFormat{};
  shared_ptr<string> returnPicType{};

  KuajingSegAdvanceRequest() {}

  explicit KuajingSegAdvanceRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!picUrlObject) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("picUrlObject is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrlObject) {
      res["PicUrlObject"] = boost::any(*picUrlObject);
    }
    if (returnPicFormat) {
      res["ReturnPicFormat"] = boost::any(*returnPicFormat);
    }
    if (returnPicType) {
      res["ReturnPicType"] = boost::any(*returnPicType);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrlObject") != m.end() && !m["PicUrlObject"].empty()) {
      picUrlObject = make_shared<Darabonba::Stream>(boost::any_cast<Darabonba::Stream>(m["PicUrlObject"]));
    }
    if (m.find("ReturnPicFormat") != m.end() && !m["ReturnPicFormat"].empty()) {
      returnPicFormat = make_shared<string>(boost::any_cast<string>(m["ReturnPicFormat"]));
    }
    if (m.find("ReturnPicType") != m.end() && !m["ReturnPicType"].empty()) {
      returnPicType = make_shared<string>(boost::any_cast<string>(m["ReturnPicType"]));
    }
  }

  virtual ~KuajingSegAdvanceRequest() = default;
};
class KuajingSegResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<map<string, boost::any>> body{};

  KuajingSegResponse() {}

  explicit KuajingSegResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = boost::any(*body);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      map<string, boost::any> map1 = boost::any_cast<map<string, boost::any>>(m["body"]);
      map<string, boost::any> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      body = make_shared<map<string, boost::any>>(toMap1);
    }
  }

  virtual ~KuajingSegResponse() = default;
};
class RemoveWordsRequest : public Darabonba::Model {
public:
  shared_ptr<string> picUrl{};

  RemoveWordsRequest() {}

  explicit RemoveWordsRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrl) {
      res["PicUrl"] = boost::any(*picUrl);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrl") != m.end() && !m["PicUrl"].empty()) {
      picUrl = make_shared<string>(boost::any_cast<string>(m["PicUrl"]));
    }
  }

  virtual ~RemoveWordsRequest() = default;
};
class RemoveWordsAdvanceRequest : public Darabonba::Model {
public:
  shared_ptr<Darabonba::Stream> picUrlObject{};

  RemoveWordsAdvanceRequest() {}

  explicit RemoveWordsAdvanceRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!picUrlObject) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("picUrlObject is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrlObject) {
      res["PicUrlObject"] = boost::any(*picUrlObject);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrlObject") != m.end() && !m["PicUrlObject"].empty()) {
      picUrlObject = make_shared<Darabonba::Stream>(boost::any_cast<Darabonba::Stream>(m["PicUrlObject"]));
    }
  }

  virtual ~RemoveWordsAdvanceRequest() = default;
};
class RemoveWordsResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<map<string, boost::any>> body{};

  RemoveWordsResponse() {}

  explicit RemoveWordsResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = boost::any(*body);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      map<string, boost::any> map1 = boost::any_cast<map<string, boost::any>>(m["body"]);
      map<string, boost::any> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      body = make_shared<map<string, boost::any>>(toMap1);
    }
  }

  virtual ~RemoveWordsResponse() = default;
};
class ReplaceBackgroundRequest : public Darabonba::Model {
public:
  shared_ptr<string> backgroundId{};
  shared_ptr<long> num{};
  shared_ptr<string> picBackgroundUrl{};
  shared_ptr<string> picUrl{};

  ReplaceBackgroundRequest() {}

  explicit ReplaceBackgroundRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {}

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (backgroundId) {
      res["BackgroundId"] = boost::any(*backgroundId);
    }
    if (num) {
      res["Num"] = boost::any(*num);
    }
    if (picBackgroundUrl) {
      res["PicBackgroundUrl"] = boost::any(*picBackgroundUrl);
    }
    if (picUrl) {
      res["PicUrl"] = boost::any(*picUrl);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("BackgroundId") != m.end() && !m["BackgroundId"].empty()) {
      backgroundId = make_shared<string>(boost::any_cast<string>(m["BackgroundId"]));
    }
    if (m.find("Num") != m.end() && !m["Num"].empty()) {
      num = make_shared<long>(boost::any_cast<long>(m["Num"]));
    }
    if (m.find("PicBackgroundUrl") != m.end() && !m["PicBackgroundUrl"].empty()) {
      picBackgroundUrl = make_shared<string>(boost::any_cast<string>(m["PicBackgroundUrl"]));
    }
    if (m.find("PicUrl") != m.end() && !m["PicUrl"].empty()) {
      picUrl = make_shared<string>(boost::any_cast<string>(m["PicUrl"]));
    }
  }

  virtual ~ReplaceBackgroundRequest() = default;
};
class ReplaceBackgroundAdvanceRequest : public Darabonba::Model {
public:
  shared_ptr<Darabonba::Stream> picUrlObject{};
  shared_ptr<string> backgroundId{};
  shared_ptr<long> num{};
  shared_ptr<string> picBackgroundUrl{};

  ReplaceBackgroundAdvanceRequest() {}

  explicit ReplaceBackgroundAdvanceRequest(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!picUrlObject) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("picUrlObject is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (picUrlObject) {
      res["PicUrlObject"] = boost::any(*picUrlObject);
    }
    if (backgroundId) {
      res["BackgroundId"] = boost::any(*backgroundId);
    }
    if (num) {
      res["Num"] = boost::any(*num);
    }
    if (picBackgroundUrl) {
      res["PicBackgroundUrl"] = boost::any(*picBackgroundUrl);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("PicUrlObject") != m.end() && !m["PicUrlObject"].empty()) {
      picUrlObject = make_shared<Darabonba::Stream>(boost::any_cast<Darabonba::Stream>(m["PicUrlObject"]));
    }
    if (m.find("BackgroundId") != m.end() && !m["BackgroundId"].empty()) {
      backgroundId = make_shared<string>(boost::any_cast<string>(m["BackgroundId"]));
    }
    if (m.find("Num") != m.end() && !m["Num"].empty()) {
      num = make_shared<long>(boost::any_cast<long>(m["Num"]));
    }
    if (m.find("PicBackgroundUrl") != m.end() && !m["PicBackgroundUrl"].empty()) {
      picBackgroundUrl = make_shared<string>(boost::any_cast<string>(m["PicBackgroundUrl"]));
    }
  }

  virtual ~ReplaceBackgroundAdvanceRequest() = default;
};
class ReplaceBackgroundResponse : public Darabonba::Model {
public:
  shared_ptr<map<string, string>> headers{};
  shared_ptr<map<string, boost::any>> body{};

  ReplaceBackgroundResponse() {}

  explicit ReplaceBackgroundResponse(const std::map<string, boost::any> &config) : Darabonba::Model(config) {
    fromMap(config);
  };

  void validate() override {
    if (!headers) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("headers is required.")));
    }
    if (!body) {
      BOOST_THROW_EXCEPTION(boost::enable_error_info(std::runtime_error("body is required.")));
    }
  }

  map<string, boost::any> toMap() override {
    map<string, boost::any> res;
    if (headers) {
      res["headers"] = boost::any(*headers);
    }
    if (body) {
      res["body"] = boost::any(*body);
    }
    return res;
  }

  void fromMap(map<string, boost::any> m) override {
    if (m.find("headers") != m.end() && !m["headers"].empty()) {
      map<string, string> map1 = boost::any_cast<map<string, string>>(m["headers"]);
      map<string, string> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      headers = make_shared<map<string, string>>(toMap1);
    }
    if (m.find("body") != m.end() && !m["body"].empty()) {
      map<string, boost::any> map1 = boost::any_cast<map<string, boost::any>>(m["body"]);
      map<string, boost::any> toMap1;
      for (auto item:map1) {
         toMap1[item.first] = item.second;
      }
      body = make_shared<map<string, boost::any>>(toMap1);
    }
  }

  virtual ~ReplaceBackgroundResponse() = default;
};
class Client : Alibabacloud_OpenApi::Client {
public:
  explicit Client(const shared_ptr<Alibabacloud_OpenApi::Config>& config);
  string getEndpoint(shared_ptr<string> productId,
                     shared_ptr<string> regionId,
                     shared_ptr<string> endpointRule,
                     shared_ptr<string> network,
                     shared_ptr<string> suffix,
                     shared_ptr<map<string, string>> endpointMap,
                     shared_ptr<string> endpoint);
  AePredictCategoryResponse aePredictCategoryWithOptions(shared_ptr<AePredictCategoryRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  AePredictCategoryResponse aePredictCategory(shared_ptr<AePredictCategoryRequest> request);
  AePredictCategoryResponse aePredictCategoryAdvance(shared_ptr<AePredictCategoryAdvanceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  AePropRecResponse aePropRecWithOptions(shared_ptr<AePropRecRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  AePropRecResponse aePropRec(shared_ptr<AePropRecRequest> request);
  AePropRecResponse aePropRecAdvance(shared_ptr<AePropRecAdvanceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  AlivisionImgdupResponse alivisionImgdupWithOptions(shared_ptr<AlivisionImgdupRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  AlivisionImgdupResponse alivisionImgdup(shared_ptr<AlivisionImgdupRequest> request);
  AlivisionImgdupResponse alivisionImgdupAdvance(shared_ptr<AlivisionImgdupAdvanceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  CreateImageAmazonTaskResponse createImageAmazonTaskWithOptions(shared_ptr<CreateImageAmazonTaskRequest> tmpReq, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  CreateImageAmazonTaskResponse createImageAmazonTask(shared_ptr<CreateImageAmazonTaskRequest> request);
  FaceshifterTResponse faceshifterTWithOptions(shared_ptr<FaceshifterTRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  FaceshifterTResponse faceshifterT(shared_ptr<FaceshifterTRequest> request);
  FaceshifterTResponse faceshifterTAdvance(shared_ptr<FaceshifterTAdvanceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  GetTaskResultResponse getTaskResultWithOptions(shared_ptr<GetTaskResultRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  GetTaskResultResponse getTaskResult(shared_ptr<GetTaskResultRequest> request);
  GetTaskStatusResponse getTaskStatusWithOptions(shared_ptr<GetTaskStatusRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  GetTaskStatusResponse getTaskStatus(shared_ptr<GetTaskStatusRequest> request);
  KuajingSegResponse kuajingSegWithOptions(shared_ptr<KuajingSegRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  KuajingSegResponse kuajingSeg(shared_ptr<KuajingSegRequest> request);
  KuajingSegResponse kuajingSegAdvance(shared_ptr<KuajingSegAdvanceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  RemoveWordsResponse removeWordsWithOptions(shared_ptr<RemoveWordsRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  RemoveWordsResponse removeWords(shared_ptr<RemoveWordsRequest> request);
  RemoveWordsResponse removeWordsAdvance(shared_ptr<RemoveWordsAdvanceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  ReplaceBackgroundResponse replaceBackgroundWithOptions(shared_ptr<ReplaceBackgroundRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);
  ReplaceBackgroundResponse replaceBackground(shared_ptr<ReplaceBackgroundRequest> request);
  ReplaceBackgroundResponse replaceBackgroundAdvance(shared_ptr<ReplaceBackgroundAdvanceRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime);

  virtual ~Client() = default;
};
} // namespace Alibabacloud_Dplus20201216

#endif

max_stars_repo_name: aliyun/alibabacloud-cpp-sdk

max_issues_repo_name: aliyun/alibabacloud-cpp-sdk

max_forks_repo_name: aliyun/alibabacloud-cpp-sdk


text:
/*
 * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
 */

#include <mc_rbdyn/Robots.h>
#include <mc_rbdyn/configuration_io.h>

#include <RBDyn/parsers/urdf.h>

#include <sch-core/STP_BV.h>
#include <sch-core/STP_BV_P.h>
#include <sch-core/S_Box.h>
#include <sch-core/S_Capsule.h>
#include <sch-core/S_Cone.h>
#include <sch-core/S_Cylinder.h>
#include <sch-core/S_Point.h>
#include <sch-core/S_Polyhedron.h>
#include <sch-core/S_Sphere.h>
#include <sch-core/S_Superellipsoid.h>

#include <boost/filesystem.hpp>
namespace bfs = boost::filesystem;

namespace
{
// Return relative path to go to "to" from "from"
bfs::path relative(bfs::path to, bfs::path from)
{
  bfs::path::const_iterator fromIter = from.begin();
  bfs::path::const_iterator toIter = to.begin();
  while(fromIter != from.end() && toIter != to.end() && (*toIter) == (*fromIter))
  {
    ++toIter;
    ++fromIter;
  }
  bfs::path relPath;
  while(fromIter != from.end() && *fromIter != bfs::path("."))
  {
    relPath /= "..";
    ++fromIter;
  }
  while(toIter != to.end())
  {
    relPath /= *toIter;
    ++toIter;
  }
  return relPath;
}
} // namespace

namespace mc_rtc
{

rbd::Joint::Type ConfigurationLoader<rbd::Joint::Type>::load(const mc_rtc::Configuration & config)
{
  std::string type = "";
  config("type", type);
  if(type == "rev")
  {
    return rbd::Joint::Type::Rev;
  }
  if(type == "prism")
  {
    return rbd::Joint::Type::Prism;
  }
  if(type == "spherical")
  {
    return rbd::Joint::Type::Spherical;
  }
  if(type == "planar")
  {
    return rbd::Joint::Type::Planar;
  }
  if(type == "cylindrical")
  {
    return rbd::Joint::Type::Cylindrical;
  }
  if(type == "free")
  {
    return rbd::Joint::Type::Free;
  }
  if(type == "fixed")
  {
    return rbd::Joint::Type::Fixed;
  }
  mc_rtc::log::error_and_throw<std::runtime_error>("{} was stored as joint type, cannot comprehend that", type);
}

mc_rtc::Configuration ConfigurationLoader<rbd::Joint::Type>::save(const rbd::Joint::Type & type)
{
  mc_rtc::Configuration config;
  std::string typeStr = "";
  switch(type)
  {
    case rbd::Joint::Type::Rev:
      typeStr = "rev";
      break;
    case rbd::Joint::Type::Prism:
      typeStr = "prism";
      break;
    case rbd::Joint::Type::Spherical:
      typeStr = "spherical";
      break;
    case rbd::Joint::Type::Planar:
      typeStr = "planar";
      break;
    case rbd::Joint::Type::Cylindrical:
      typeStr = "cylindrical";
      break;
    case rbd::Joint::Type::Free:
      typeStr = "free";
      break;
    case rbd::Joint::Type::Fixed:
      typeStr = "fixed";
      break;
    default:
      mc_rtc::log::error_and_throw<std::runtime_error>("Cannot serialize joint type {}", type);
  }
  config.add("type", typeStr);
  return config;
}

mc_rbdyn::Base ConfigurationLoader<mc_rbdyn::Base>::load(const mc_rtc::Configuration & config)
{
  return {config("name"), config("X_0_s"), config("X_b0_s"), config("type")};
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::Base>::save(const mc_rbdyn::Base & b)
{
  mc_rtc::Configuration config;
  config.add("name", b.baseName);
  config.add("X_0_s", b.X_0_s);
  config.add("X_b0_s", b.X_b0_s);
  config.add("type", b.baseType);
  return config;
}

mc_rbdyn::BodySensor ConfigurationLoader<mc_rbdyn::BodySensor>::load(const mc_rtc::Configuration & config)
{
  return mc_rbdyn::BodySensor(config("name"), config("parentBody"), config("X_b_s"));
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::BodySensor>::save(const mc_rbdyn::BodySensor & bs)
{
  mc_rtc::Configuration config;
  config.add("name", bs.name());
  config.add("parentBody", bs.parentBody());
  config.add("X_b_s", bs.X_b_s());
  return config;
}

mc_rbdyn::Collision ConfigurationLoader<mc_rbdyn::Collision>::load(const mc_rtc::Configuration & config)
{
  return mc_rbdyn::Collision(config("body1"), config("body2"), config("iDist", 0.05), config("sDist", 0.01),
                             config("damping", 0.0));
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::Collision>::save(const mc_rbdyn::Collision & c)
{
  mc_rtc::Configuration config;
  config.add("body1", c.body1);
  config.add("body2", c.body2);
  config.add("iDist", c.iDist);
  config.add("sDist", c.sDist);
  config.add("damping", c.damping);
  return config;
}

std::shared_ptr<mc_rbdyn::Surface> ConfigurationLoader<std::shared_ptr<mc_rbdyn::Surface>>::load(
    const mc_rtc::Configuration & config)
{
  std::string type = config("type");
  if(type == "planar")
  {
    return std::make_shared<mc_rbdyn::PlanarSurface>(config("name"), config("bodyName"), config("X_b_s"),
                                                     config("materialName"), config("planarPoints"));
  }
  else if(type == "cylindrical")
  {
    return std::make_shared<mc_rbdyn::CylindricalSurface>(config("name"), config("bodyName"), config("X_b_s"),
                                                          config("materialName"), config("radius"), config("width"));
  }
  else if(type == "gripper")
  {
    return std::make_shared<mc_rbdyn::GripperSurface>(config("name"), config("bodyName"), config("X_b_s"),
                                                      config("materialName"), config("pointsFromOrigin"),
                                                      config("X_b_motor"), config("motorMaxTorque"));
  }
  mc_rtc::log::error_and_throw<std::runtime_error>("Unknown surface type stored {}", type);
}

mc_rtc::Configuration ConfigurationLoader<std::shared_ptr<mc_rbdyn::Surface>>::save(
    const std::shared_ptr<mc_rbdyn::Surface> & s)
{
  mc_rtc::Configuration config;
  config.add("type", s->type());
  config.add("name", s->name());
  config.add("bodyName", s->bodyName());
  config.add("X_b_s", s->X_b_s());
  config.add("materialName", s->materialName());
  if(s->type() == "planar")
  {
    auto ps = static_cast<mc_rbdyn::PlanarSurface *>(s.get());
    config.add("planarPoints", ps->planarPoints());
  }
  else if(s->type() == "cylindrical")
  {
    auto cs = static_cast<mc_rbdyn::CylindricalSurface *>(s.get());
    config.add("radius", cs->radius());
    config.add("width", cs->width());
  }
  else if(s->type() == "gripper")
  {
    auto gs = static_cast<mc_rbdyn::GripperSurface *>(s.get());
    config.add("pointsFromOrigin", gs->pointsFromOrigin());
    config.add("X_b_motor", gs->X_b_motor());
    config.add("motorMaxTorque", gs->motorMaxTorque());
  }
  else
  {
    mc_rtc::log::error_and_throw<std::runtime_error>("Cannot serialize a surface of type {}", s->type());
  }
  return config;
}

std::shared_ptr<mc_rbdyn::PlanarSurface> ConfigurationLoader<std::shared_ptr<mc_rbdyn::PlanarSurface>>::load(
    const mc_rtc::Configuration & config)
{
  std::string type = config("type");
  if(type != "planar")
  {
    mc_rtc::log::error_and_throw<std::runtime_error>("Tried to deserialize a non-planar surface into a planar surface");
  }
  return std::static_pointer_cast<mc_rbdyn::PlanarSurface>(
      ConfigurationLoader<std::shared_ptr<mc_rbdyn::Surface>>::load(config));
}

mc_rtc::Configuration ConfigurationLoader<std::shared_ptr<mc_rbdyn::PlanarSurface>>::save(
    const std::shared_ptr<mc_rbdyn::PlanarSurface> & s)
{
  return ConfigurationLoader<std::shared_ptr<mc_rbdyn::Surface>>::save(s);
}

std::shared_ptr<mc_rbdyn::CylindricalSurface> ConfigurationLoader<std::shared_ptr<mc_rbdyn::CylindricalSurface>>::load(
    const mc_rtc::Configuration & config)
{
  std::string type = config("type");
  if(type != "cylindrical")
  {
    mc_rtc::log::error_and_throw<std::runtime_error>(
        "Tried to deserialize a non-cylindrical surface into a cylindrical surface");
  }
  return std::static_pointer_cast<mc_rbdyn::CylindricalSurface>(
      ConfigurationLoader<std::shared_ptr<mc_rbdyn::Surface>>::load(config));
}

mc_rtc::Configuration ConfigurationLoader<std::shared_ptr<mc_rbdyn::CylindricalSurface>>::save(
    const std::shared_ptr<mc_rbdyn::CylindricalSurface> & s)
{
  return ConfigurationLoader<std::shared_ptr<mc_rbdyn::Surface>>::save(s);
}

std::shared_ptr<mc_rbdyn::GripperSurface> ConfigurationLoader<std::shared_ptr<mc_rbdyn::GripperSurface>>::load(
    const mc_rtc::Configuration & config)
{
  std::string type = config("type");
  if(type != "gripper")
  {
    mc_rtc::log::error_and_throw<std::runtime_error>(
        "Tried to deserialize a non-gripper surface into a gripper surface");
  }
  return std::static_pointer_cast<mc_rbdyn::GripperSurface>(
      ConfigurationLoader<std::shared_ptr<mc_rbdyn::Surface>>::load(config));
}

mc_rtc::Configuration ConfigurationLoader<std::shared_ptr<mc_rbdyn::GripperSurface>>::save(
    const std::shared_ptr<mc_rbdyn::GripperSurface> & s)
{
  return ConfigurationLoader<std::shared_ptr<mc_rbdyn::Surface>>::save(s);
}

mc_rbdyn::Flexibility ConfigurationLoader<mc_rbdyn::Flexibility>::load(const mc_rtc::Configuration & config)
{
  return {config("jointName"), config("K"), config("C"), config("O")};
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::Flexibility>::save(const mc_rbdyn::Flexibility & flex)
{
  mc_rtc::Configuration config;
  config.add("jointName", flex.jointName);
  config.add("K", flex.K);
  config.add("C", flex.C);
  config.add("O", flex.O);
  return config;
}

mc_rbdyn::ForceSensor ConfigurationLoader<mc_rbdyn::ForceSensor>::load(const mc_rtc::Configuration & config)
{
  return {config("name"), config("parentBody"), config("X_p_f")};
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::ForceSensor>::save(const mc_rbdyn::ForceSensor & fs)
{
  mc_rtc::Configuration config;
  config.add("name", fs.name());
  config.add("parentBody", fs.parentBody());
  config.add("X_p_f", fs.X_p_f());
  return config;
}

mc_rbdyn::Plane ConfigurationLoader<mc_rbdyn::Plane>::load(const mc_rtc::Configuration & config)
{
  return mc_rbdyn::Plane{config("normal"), config("offset")};
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::Plane>::save(const mc_rbdyn::Plane & pl)
{
  mc_rtc::Configuration config;
  config.add("normal", pl.normal);
  config.add("offset", pl.offset);
  return config;
}

mc_rbdyn::PolygonInterpolator ConfigurationLoader<mc_rbdyn::PolygonInterpolator>::load(
    const mc_rtc::Configuration & config)
{
  std::vector<mc_rbdyn::PolygonInterpolator::tuple_pair_t> vec = config("tuple_pairs");
  return mc_rbdyn::PolygonInterpolator(vec);
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::PolygonInterpolator>::save(const mc_rbdyn::PolygonInterpolator & pi)
{
  mc_rtc::Configuration config;
  config.add("tuple_pairs", pi.tuple_pairs());
  return config;
}

mc_rbdyn::Springs ConfigurationLoader<mc_rbdyn::Springs>::load(const mc_rtc::Configuration & config)
{
  mc_rbdyn::Springs spr;
  spr.springsBodies = config("springsBodies");
  spr.afterSpringsBodies = config("afterSpringsBodies");
  spr.springsJoints = config("springsJoints");
  return spr;
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::Springs>::save(const mc_rbdyn::Springs & spr)
{
  mc_rtc::Configuration config;
  config.add("springsBodies", spr.springsBodies);
  config.add("afterSpringsBodies", spr.afterSpringsBodies);
  config.add("springsJoints", spr.springsJoints);
  return config;
}

sva::RBInertiad ConfigurationLoader<sva::RBInertiad>::load(const mc_rtc::Configuration & config)
{
  Eigen::Matrix3d inertia = config("inertia");
  return {config("mass"), config("momentum"), inertia};
}

mc_rtc::Configuration ConfigurationLoader<sva::RBInertiad>::save(const sva::RBInertiad & rbi)
{
  mc_rtc::Configuration config;
  config.add("mass", rbi.mass());
  config.add("momentum", rbi.momentum());
  config.add("inertia", rbi.inertia());
  return config;
}

rbd::Body ConfigurationLoader<rbd::Body>::load(const mc_rtc::Configuration & config)
{
  return {config("inertia"), config("name")};
}

mc_rtc::Configuration ConfigurationLoader<rbd::Body>::save(const rbd::Body & bod)
{
  mc_rtc::Configuration config;
  config.add("name", bod.name());
  config.add("inertia", bod.inertia());
  return config;
}

rbd::Joint ConfigurationLoader<rbd::Joint>::load(const mc_rtc::Configuration & config)
{
  rbd::Joint j{config("type"), config("axis"), config("forward"), config("name")};
  bool isMimic = config("isMimic");
  if(isMimic)
  {
    j.makeMimic(config("mimicName"), config("mimicMultiplier"), config("mimicOffset"));
  }
  return j;
}

mc_rtc::Configuration ConfigurationLoader<rbd::Joint>::save(const rbd::Joint & j)
{
  mc_rtc::Configuration config;
  config.add("type", j.type());
  Eigen::Vector3d axis = Eigen::Vector3d::UnitZ();
  switch(j.type())
  {
    case rbd::Joint::Rev:
    case rbd::Joint::Cylindrical:
      axis = j.direction() * j.motionSubspace().col(0).head<3>();
      break;
    case rbd::Joint::Prism:
      axis = j.direction() * j.motionSubspace().col(0).tail<3>();
      break;
    default:
      break;
  }
  config.add("axis", axis);
  config.add("forward", j.forward());
  config.add("isMimic", j.isMimic());
  if(j.isMimic())
  {
    config.add("mimicName", j.mimicName());
    config.add("mimicMultiplier", j.mimicMultiplier());
    config.add("mimicOffset", j.mimicOffset());
  }
  config.add("name", j.name());
  return config;
}

rbd::MultiBody ConfigurationLoader<rbd::MultiBody>::load(const mc_rtc::Configuration & config)
{
  return {config("bodies"), config("joints"),  config("preds"),
          config("succs"),  config("parents"), config("transforms")};
}

mc_rtc::Configuration ConfigurationLoader<rbd::MultiBody>::save(const rbd::MultiBody & mb)
{
  mc_rtc::Configuration config;
  config.add("bodies", mb.bodies());
  config.add("joints", mb.joints());
  config.add("preds", mb.predecessors());
  config.add("succs", mb.successors());
  config.add("parents", mb.parents());
  config.add("transforms", mb.transforms());
  return config;
}

Eigen::Matrix<double, 6, Eigen::Dynamic> ConfigurationLoader<Eigen::Matrix<double, 6, Eigen::Dynamic>>::load(
    const mc_rtc::Configuration & config)
{
  Eigen::Matrix<double, 6, Eigen::Dynamic> m(6, static_cast<int>(config("cols")));
  auto data = config("data");
  if(static_cast<Eigen::DenseIndex>(data.size()) != 6 * m.cols())
  {
    auto msg = fmt::format("Stored data size ({}) is different from the expected size ({})", data.size(), 6 * m.cols());
    mc_rtc::log::critical(msg);
    throw mc_rtc::Configuration::Exception(msg, data);
  }
  for(Eigen::DenseIndex i = 0; i < 6; ++i)
  {
    for(Eigen::DenseIndex j = 0; j < m.cols(); ++j)
    {
      m(i, j) = data[static_cast<size_t>(m.cols() * i + j)];
    }
  }
  return m;
}

mc_rtc::Configuration ConfigurationLoader<Eigen::Matrix<double, 6, Eigen::Dynamic>>::save(
    const Eigen::Matrix<double, 6, Eigen::Dynamic> & m)
{
  mc_rtc::Configuration config;
  config.add("cols", static_cast<int>(m.cols()));
  auto data = config.array("data", static_cast<size_t>(6 * m.cols()));
  for(Eigen::DenseIndex i = 0; i < 6; ++i)
  {
    for(Eigen::DenseIndex j = 0; j < m.cols(); ++j)
    {
      data.push(m(i, j));
    }
  }
  return config;
}

rbd::MultiBodyConfig ConfigurationLoader<rbd::MultiBodyConfig>::load(const mc_rtc::Configuration & config)
{
  rbd::MultiBodyConfig mbc;
  mbc.q = config("q");
  mbc.alpha = config("alpha");
  mbc.alphaD = config("alphaD");
  mbc.force = config("force");
  mbc.jointConfig = config("jointConfig");
  mbc.jointVelocity = config("jointVelocity");
  mbc.jointTorque = config("jointTorque");
  mbc.motionSubspace = config("motionSubspace");
  mbc.bodyPosW = config("bodyPosW");
  mbc.parentToSon = config("parentToSon");
  mbc.bodyVelW = config("bodyVelW");
  mbc.bodyVelB = config("bodyVelB");
  mbc.bodyAccB = config("bodyAccB");
  mbc.gravity = config("gravity");
  return mbc;
}

mc_rtc::Configuration ConfigurationLoader<rbd::MultiBodyConfig>::save(const rbd::MultiBodyConfig & mbc)
{
  mc_rtc::Configuration config;
  config.add("q", mbc.q);
  config.add("alpha", mbc.alpha);
  config.add("alphaD", mbc.alphaD);
  config.add("force", mbc.force);
  config.add("jointConfig", mbc.jointConfig);
  config.add("jointVelocity", mbc.jointVelocity);
  config.add("jointTorque", mbc.jointTorque);
  config.add("motionSubspace", mbc.motionSubspace);
  config.add("bodyPosW", mbc.bodyPosW);
  config.add("parentToSon", mbc.parentToSon);
  config.add("bodyVelW", mbc.bodyVelW);
  config.add("bodyVelB", mbc.bodyVelB);
  config.add("bodyAccB", mbc.bodyAccB);
  config.add("gravity", mbc.gravity);
  return config;
}

mc_rbdyn::Mimic ConfigurationLoader<mc_rbdyn::Mimic>::load(const mc_rtc::Configuration & config)
{
  return {config("name"), config("joint"), config("multiplier", 1.0), config("offset", 0.0)};
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::Mimic>::save(const mc_rbdyn::Mimic & mimic)
{
  mc_rtc::Configuration config;
  config.add("name", mimic.name);
  config.add("joint", mimic.joint);
  config.add("multiplier", mimic.multiplier);
  config.add("offset", mimic.offset);
  return config;
}

namespace
{

mc_rbdyn::RobotModule::Gripper loadGripper(const mc_rtc::Configuration & config,
                                           const mc_rbdyn::RobotModule::Gripper::Safety & safety)
{
  const std::string & name = config("name");
  const std::vector<std::string> & joints = config("joints");
  bool reverse_limits = config("reverse_limits");
  if(config.has("safety"))
  {
    const mc_rbdyn::RobotModule::Gripper::Safety & safety = config("safety");
    if(config.has("mimics"))
    {
      return {name, joints, reverse_limits, safety, config("mimics")};
    }
    return {name, joints, reverse_limits, safety};
  }
  if(config.has("mimics"))
  {
    return {name, joints, reverse_limits, safety, config("mimics")};
  }
  return {name, joints, reverse_limits};
}

} // namespace

mc_rbdyn::RobotModule::Gripper ConfigurationLoader<mc_rbdyn::RobotModule::Gripper>::load(
    const mc_rtc::Configuration & config)
{
  return loadGripper(config, {});
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::RobotModule::Gripper>::save(
    const mc_rbdyn::RobotModule::Gripper & rmg)
{
  mc_rtc::Configuration config;
  config.add("name", rmg.name);
  config.add("joints", rmg.joints);
  config.add("reverse_limits", rmg.reverse_limits);
  auto safety = rmg.safety();
  if(safety)
  {
    config.add("safety", *safety);
  }
  auto mimics = rmg.mimics();
  if(mimics)
  {
    config.add("mimics", *mimics);
  }
  return config;
}

mc_rbdyn::RobotModule::Gripper::Safety ConfigurationLoader<mc_rbdyn::RobotModule::Gripper::Safety>::load(
    const mc_rtc::Configuration & config)
{
  mc_rbdyn::RobotModule::Gripper::Safety safety;
  safety.load(config);
  return safety;
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::RobotModule::Gripper::Safety>::save(
    const mc_rbdyn::RobotModule::Gripper::Safety & safety)
{
  return safety.save();
}

rbd::parsers::Geometry::Box ConfigurationLoader<rbd::parsers::Geometry::Box>::load(const mc_rtc::Configuration & config)
{
  rbd::parsers::Geometry::Box b;
  b.size = config("size");
  return b;
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Geometry::Box>::save(const rbd::parsers::Geometry::Box & b)
{
  mc_rtc::Configuration config;
  config.add("size", b.size);
  return config;
}

rbd::parsers::Geometry::Cylinder ConfigurationLoader<rbd::parsers::Geometry::Cylinder>::load(
    const mc_rtc::Configuration & config)
{
  rbd::parsers::Geometry::Cylinder c;
  c.radius = config("radius");
  c.length = config("length");
  return c;
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Geometry::Cylinder>::save(
    const rbd::parsers::Geometry::Cylinder & c)
{
  mc_rtc::Configuration config;
  config.add("radius", c.radius);
  config.add("length", c.length);
  return config;
}

rbd::parsers::Geometry::Sphere ConfigurationLoader<rbd::parsers::Geometry::Sphere>::load(
    const mc_rtc::Configuration & config)
{
  rbd::parsers::Geometry::Sphere s;
  s.radius = config("radius");
  return s;
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Geometry::Sphere>::save(const rbd::parsers::Geometry::Sphere & s)
{
  mc_rtc::Configuration config;
  config.add("radius", s.radius);
  return config;
}

rbd::parsers::Geometry::Mesh ConfigurationLoader<rbd::parsers::Geometry::Mesh>::load(
    const mc_rtc::Configuration & config)
{
  rbd::parsers::Geometry::Mesh m;
  m.filename = static_cast<std::string>(config("filename"));
  m.scale = config("scale");
  return m;
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Geometry::Mesh>::save(const rbd::parsers::Geometry::Mesh & m)
{
  mc_rtc::Configuration config;
  config.add("filename", m.filename);
  config.add("scale", m.scale);
  return config;
}

rbd::parsers::Geometry::Superellipsoid ConfigurationLoader<rbd::parsers::Geometry::Superellipsoid>::load(
    const mc_rtc::Configuration & config)
{
  rbd::parsers::Geometry::Superellipsoid s;
  s.size = config("size");
  s.epsilon1 = config("epsilon1");
  s.epsilon2 = config("epsilon2");
  return s;
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Geometry::Superellipsoid>::save(
    const rbd::parsers::Geometry::Superellipsoid & s)
{
  mc_rtc::Configuration config;
  config.add("size", s.size);
  config.add("epsilon1", s.epsilon1);
  config.add("epsilon2", s.epsilon2);
  return config;
}

rbd::parsers::Geometry ConfigurationLoader<rbd::parsers::Geometry>::load(const mc_rtc::Configuration & config)
{
  rbd::parsers::Geometry geom;
  if(config.has("box"))
  {
    geom.type = rbd::parsers::Geometry::Type::BOX;
    rbd::parsers::Geometry::Box b = config("box");
    geom.data = b;
  }
  else if(config.has("cylinder"))
  {
    geom.type = rbd::parsers::Geometry::Type::CYLINDER;
    rbd::parsers::Geometry::Cylinder b = config("cylinder");
    geom.data = b;
  }
  else if(config.has("sphere"))
  {
    geom.type = rbd::parsers::Geometry::Type::SPHERE;
    rbd::parsers::Geometry::Sphere b = config("sphere");
    geom.data = b;
  }
  else if(config.has("mesh"))
  {
    geom.type = rbd::parsers::Geometry::Type::MESH;
    rbd::parsers::Geometry::Mesh b = config("mesh");
    geom.data = b;
  }
  else if(config.has("superellipsoid"))
  {
    geom.type = rbd::parsers::Geometry::Type::SUPERELLIPSOID;
    rbd::parsers::Geometry::Superellipsoid s = config("superellipsoid");
    geom.data = s;
  }
  return geom;
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Geometry>::save(const rbd::parsers::Geometry & geom)
{
  mc_rtc::Configuration config;
  switch(geom.type)
  {
    case rbd::parsers::Geometry::Type::BOX:
      config.add("box", boost::get<rbd::parsers::Geometry::Box>(geom.data));
      break;
    case rbd::parsers::Geometry::Type::CYLINDER:
      config.add("cylinder", boost::get<rbd::parsers::Geometry::Cylinder>(geom.data));
      break;
    case rbd::parsers::Geometry::Type::SPHERE:
      config.add("sphere", boost::get<rbd::parsers::Geometry::Sphere>(geom.data));
      break;
    case rbd::parsers::Geometry::Type::MESH:
      config.add("mesh", boost::get<rbd::parsers::Geometry::Mesh>(geom.data));
      break;
    case rbd::parsers::Geometry::Type::SUPERELLIPSOID:
      config.add("superellipsoid", boost::get<rbd::parsers::Geometry::Superellipsoid>(geom.data));
      break;
    default:
      break;
  }
  return config;
}

rbd::parsers::Material::Color ConfigurationLoader<rbd::parsers::Material::Color>::load(
    const mc_rtc::Configuration & config)
{
  return rbd::parsers::Material::Color{config("r"), config("g"), config("b"), config("a")};
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Material::Color>::save(const rbd::parsers::Material::Color & col)
{
  mc_rtc::Configuration config;
  config.add("r", col.r);
  config.add("g", col.g);
  config.add("b", col.b);
  config.add("a", col.a);
  return config;
}

rbd::parsers::Material::Texture ConfigurationLoader<rbd::parsers::Material::Texture>::load(
    const mc_rtc::Configuration & config)
{
  return rbd::parsers::Material::Texture{config("filename")};
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Material::Texture>::save(
    const rbd::parsers::Material::Texture & text)
{
  mc_rtc::Configuration config;
  config.add("filename", text.filename);
  return config;
}

rbd::parsers::Material ConfigurationLoader<rbd::parsers::Material>::load(const mc_rtc::Configuration & config)
{
  rbd::parsers::Material mat;
  if(config.has("color"))
  {
    mat.type = rbd::parsers::Material::Type::COLOR;
    rbd::parsers::Material::Color c = config("color");
    mat.data = c;
  }
  else if(config.has("texture"))
  {
    mat.type = rbd::parsers::Material::Type::TEXTURE;
    rbd::parsers::Material::Texture t = config("texture");
    mat.data = t;
  }
  return mat;
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Material>::save(const rbd::parsers::Material & mat)
{
  mc_rtc::Configuration config;
  switch(mat.type)
  {
    case rbd::parsers::Material::Type::COLOR:
      config.add("color", boost::get<rbd::parsers::Material::Color>(mat.data));
      break;
    case rbd::parsers::Material::Type::TEXTURE:
      config.add("texture", boost::get<rbd::parsers::Material::Texture>(mat.data));
      break;
    default:
      break;
  }
  return config;
}

rbd::parsers::Visual ConfigurationLoader<rbd::parsers::Visual>::load(const mc_rtc::Configuration & config)
{
  return {config("name"), config("origin"), config("geometry"), config("material")};
}

mc_rtc::Configuration ConfigurationLoader<rbd::parsers::Visual>::save(const rbd::parsers::Visual & vis)
{
  mc_rtc::Configuration config;
  config.add("name", vis.name);
  config.add("origin", vis.origin);
  config.add("geometry", vis.geometry);
  config.add("material", vis.material);
  return config;
}

mc_rbdyn::S_ObjectPtr ConfigurationLoader<mc_rbdyn::S_ObjectPtr>::load(const mc_rtc::Configuration & config)
{
  auto schPointFromConfig = [](const mc_rtc::Configuration & c) {
    sch::Point3 p;
    p[0] = c[0];
    p[1] = c[1];
    p[2] = c[2];
    return p;
  };
  std::string type = config("type");
  if(type == "box")
  {
    return std::make_shared<sch::S_Box>(config("width"), config("height"), config("depth"));
  }
  else if(type == "capsule")
  {
    auto p1 = schPointFromConfig(config("p1"));
    auto p2 = schPointFromConfig(config("p2"));
    return std::make_shared<sch::S_Capsule>(p1, p2, config("radius"));
  }
  else if(type == "cone")
  {
    return std::make_shared<sch::S_Cone>(config("angle"), config("height"));
  }
  else if(type == "cylinder")
  {
    auto p1 = schPointFromConfig(config("p1"));
    auto p2 = schPointFromConfig(config("p2"));
    mc_rtc::log::critical("Loaded p1: {} {} {}", p1.m_x, p1.m_y, p1.m_z);
    mc_rtc::log::critical("Loaded p2: {} {} {}", p2.m_x, p2.m_y, p2.m_z);
    return std::make_shared<sch::S_Cylinder>(p1, p2, config("radius"));
  }
  else if(type == "point")
  {
    return std::make_shared<sch::S_Point>();
  }
  else if(type == "polyhedron")
  {
    auto out = std::make_shared<sch::S_Polyhedron>();
    out->constructFromFile(config("filename"));
    return out;
  }
  else if(type == "sphere")
  {
    return std::make_shared<sch::S_Sphere>(config("radius"));
  }
  else if(type == "stp-bv")
  {
    auto out = std::make_shared<sch::STP_BV>();
    out->constructFromFile(config("filename"));
    return out;
  }
  else if(type == "stp-bv-p")
  {
    auto out = std::make_shared<sch::STP_BV_P>();
    out->constructFromFile(config("filename"));
    return out;
  }
  else if(type == "superellipsoid")
  {
    return std::make_shared<sch::S_Superellipsoid>(config("a"), config("b"), config("c"), config("epsilon1"),
                                                   config("epsilon2"));
  }
  mc_rtc::log::error_and_throw<std::runtime_error>("Unknown type {} in store S_Object", type);
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::S_ObjectPtr>::save(const mc_rbdyn::S_ObjectPtr & object)
{
  mc_rtc::Configuration out;
  auto schPointToConfig = [&out](const sch::Point3 & p, const std::string & name) {
    auto pOut = out.array(name, 3);
    pOut.push(p[0]);
    pOut.push(p[1]);
    pOut.push(p[2]);
  };
  auto type = object->getType();
  if(type == sch::S_Object::TBox)
  {
    auto box = dynamic_cast<sch::S_Box *>(object.get());
    if(!box)
    {
      goto failed_cast;
    }
    double width, height, depth;
    box->getBoxParameters(width, height, depth);
    out.add("type", "box");
    out.add("width", width);
    out.add("height", height);
    out.add("depth", depth);
  }
  else if(type == sch::S_Object::TCapsule)
  {
    auto capsule = dynamic_cast<sch::S_Capsule *>(object.get());
    if(!capsule)
    {
      goto failed_cast;
    }
    out.add("type", "capsule");
    schPointToConfig(capsule->getP1(), "p1");
    schPointToConfig(capsule->getP2(), "p2");
    out.add("radius", capsule->getRadius());
  }
  else if(type == sch::S_Object::TCone)
  {
    auto cone = dynamic_cast<sch::S_Cone *>(object.get());
    if(!cone)
    {
      goto failed_cast;
    }
    out.add("type", "cone");
    out.add("angle", cone->getAngle());
    out.add("height", cone->getHeight());
  }
  else if(type == sch::S_Object::TCylinder)
  {
    auto cylinder = dynamic_cast<sch::S_Cylinder *>(object.get());
    if(!cylinder)
    {
      goto failed_cast;
    }
    out.add("type", "cylinder");
    schPointToConfig(cylinder->getP1(), "p1");
    schPointToConfig(cylinder->getP2(), "p2");
    out.add("radius", cylinder->getRadius());
  }
  else if(type == sch::S_Object::TPoint)
  {
    out.add("type", "point");
  }
  else if(type == sch::S_Object::TSphere)
  {
    auto sphere = dynamic_cast<sch::S_Sphere *>(object.get());
    if(!sphere)
    {
      goto failed_cast;
    }
    out.add("type", "sphere");
    out.add("radius", sphere->getRadius());
  }
  else if(type == sch::S_Object::TPolyhedron || type == sch::S_Object::TSTP_BV
          || type == sch::S_Object::TSTP_BV_WithPolyhedron)
  {
    mc_rtc::log::error_and_throw<std::runtime_error>("Polyhedron and STP-BV objects cannot be saved this way");
  }
  else if(type == sch::S_Object::TSuperellipsoid)
  {
    auto se = dynamic_cast<sch::S_Superellipsoid *>(object.get());
    if(!se)
    {
      goto failed_cast;
    }
    double a, b, c, epsilon1, epsilon2;
    se->getEllipsoidParameter(a, b, c, epsilon1, epsilon2);
    out.add("type", "superellipsoid");
    out.add("a", a);
    out.add("b", b);
    out.add("c", c);
    out.add("epsilon1", epsilon1);
    out.add("epsilon2", epsilon2);
  }
  else
  {
    mc_rtc::log::error_and_throw<std::runtime_error>("New sch-core object type is not handled by this save function");
  }
  return out;
failed_cast:
  mc_rtc::log::error_and_throw<std::runtime_error>("Failed to cast the object to its deduced type");
}

mc_rbdyn::RobotModule ConfigurationLoader<mc_rbdyn::RobotModule>::load(const mc_rtc::Configuration & config)
{
  bfs::path path((std::string)config("path"));
  bfs::path urdf_path((std::string)config("urdf_path"));
  if(!urdf_path.is_absolute())
  {
    urdf_path = path / urdf_path;
  }
  mc_rbdyn::RobotModule rm(path.string(), config("name"), urdf_path.string());
  if(config.has("mb"))
  {
    rm.mb = config("mb");
    rm.mbc = config("mbc");
    rm._bounds = config("bounds");
    rm._visual = static_cast<std::map<std::string, std::vector<rbd::parsers::Visual>>>(config("visuals"));
    rm._collisionTransforms = config("collisionTransforms");
  }
  else
  {
    auto filteredLinks = config("filteredLinks", std::vector<std::string>{});
    auto fixed = config("fixed", false);
    if(!bfs::exists(rm.urdf_path))
    {
      mc_rtc::log::error_and_throw<std::runtime_error>("Could not open model for {} at {}", rm.name, rm.urdf_path);
    }
    rm.init(rbd::parsers::from_urdf_file(rm.urdf_path, fixed));
    auto ctfs = config("collisionTransforms", std::map<std::string, sva::PTransformd>{});
    for(const auto & ctf : ctfs)
    {
      if(rm._collisionTransforms.count(ctf.first))
      {
        mc_rtc::log::warning("The collision transform for {} was already loaded from the URDF, the one specified in "
                             "the module will be ignored",
                             ctf.first);
        continue;
      }
      rm._collisionTransforms[ctf.first] = ctf.second;
    }
  }
  if(config.has("accelerationBounds"))
  {
    mc_rbdyn::RobotModule::bounds_t aBounds = config("accelerationBounds");
    if(aBounds.size() != 2)
    {
      mc_rtc::log::error_and_throw<std::runtime_error>("accelerationBounds entry should be an array of size 2");
    }
    rm._accelerationBounds.resize(2);
    rm._accelerationBounds[0] = aBounds[0];
    rm._accelerationBounds[1] = aBounds[1];
  }
  if(config.has("jerkBounds"))
  {
    mc_rbdyn::RobotModule::bounds_t jBounds = config("jerkBounds");
    if(jBounds.size() != 2)
    {
      mc_rtc::log::error_and_throw<std::runtime_error>("jerkBounds entry should be an array of size 2");
    }
    rm._jerkBounds.resize(2);
    rm._jerkBounds[0] = jBounds[0];
    rm._jerkBounds[1] = jBounds[1];
  }
  if(config.has("torqueDerivativeBounds"))
  {
    mc_rbdyn::RobotModule::bounds_t tdBounds = config("torqueDerivativeBounds");
    if(tdBounds.size() != 2)
    {
      mc_rtc::log::error_and_throw<std::runtime_error>("torqueDerivativeBounds entry should be an array of size 2");
    }
    rm._torqueDerivativeBounds.resize(2);
    rm._torqueDerivativeBounds[0] = tdBounds[0];
    rm._torqueDerivativeBounds[1] = tdBounds[1];
  }
  /* Default values work fine for those */
  if(config.has("rsdf_dir"))
  {
    bfs::path rsdf_dir((std::string)config("rsdf_dir"));
    if(!rsdf_dir.is_absolute())
    {
      rsdf_dir = path / rsdf_dir;
    }
    rm.rsdf_dir = rsdf_dir.string();
  }
  config("convexHulls", rm._convexHull);
  for(auto & cH : rm._convexHull)
  {
    bfs::path chPath(cH.second.second);
    if(!chPath.is_absolute())
    {
      cH.second.second = (path / chPath).string();
    }
  }
  config("collisionObjects", rm._collisionObjects);
  config("stpbvHulls", rm._stpbvHull);
  for(auto & sH : rm._stpbvHull)
  {
    bfs::path stPath(sH.second.second);
    if(!stPath.is_absolute())
    {
      sH.second.second = (path / stPath).string();
    }
  }
  config("flexibilities", rm._flexibility);
  config("forceSensors", rm._forceSensors);
  config("bodySensors", rm._bodySensors);
  config("springs", rm._springs);
  config("minimalSelfCollisions", rm._minimalSelfCollisions);
  config("commonSelfCollisions", rm._commonSelfCollisions);
  config("default_attitude", rm._default_attitude);

  /* Those cannot be empty */
  config("stance", rm._stance);
  rm.expand_stance();
  if(config.has("ref_joint_order"))
  {
    rm._ref_joint_order = config("ref_joint_order");
  }
  else
  {
    rm.make_default_ref_joint_order();
  }

  if(config.has("gripperSafety"))
  {
    rm._gripperSafety = config("gripperSafety");
  }
  if(config.has("grippers"))
  {
    std::vector<mc_rtc::Configuration> grippers = config("grippers");
    for(auto & g : grippers)
    {
      rm._grippers.push_back(loadGripper(g, rm.gripperSafety()));
    }
  }
  if(config.has("lipmStabilizer"))
  {
    rm._lipmStabilizerConfig.load(config("lipmStabilizer"));
  }

  return rm;
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::RobotModule>::save(const mc_rbdyn::RobotModule & rm,
                                                                       bool save_mbc,
                                                                       const std::vector<std::string> & filteredLinks,
                                                                       bool fixed)
{
  mc_rtc::Configuration config;
  config.add("path", rm.path);
  config.add("name", rm.name);
  config.add("urdf_path", relative(rm.urdf_path, rm.path).string());
  config.add("rsdf_dir", relative(rm.rsdf_dir, rm.path).string());
  if(save_mbc)
  {
    config.add("mb", rm.mb);
    config.add("mbc", rm.mbc);
    config.add("collisionTransforms", rm._collisionTransforms);
    config.add("bounds", rm._bounds);
    config.add("visuals", rm._visual);
  }
  else
  {
    config.add("filteredLinks", filteredLinks);
    config.add("fixed", fixed);
  }
  if(rm._bounds.size() != 6)
  {
    mc_rtc::log::error_and_throw<std::runtime_error>("Wrong number ({}) of _bounds entries in RobotModule",
                                                     rm._bounds.size());
  }
  if(rm._accelerationBounds.size() != 0 && rm._accelerationBounds.size() != 2)
  {
    mc_rtc::log::error_and_throw<std::runtime_error>("Wrong number ({}) of _accelerationBounds entries in RobotModule",
                                                     rm._accelerationBounds.size());
  }
  if(rm._jerkBounds.size() != 0 && rm._jerkBounds.size() != 2)
  {
    mc_rtc::log::error_and_throw<std::runtime_error>("Wrong number ({}) of _jerkBounds entries in RobotModule",
                                                     rm._jerkBounds.size());
  }
  if(rm._torqueDerivativeBounds.size() != 0 && rm._torqueDerivativeBounds.size() != 2)
  {
    mc_rtc::log::error_and_throw<std::runtime_error>(
        "Wrong number ({}) of _torqueDerivativeBounds entries in RobotModule", rm._torqueDerivativeBounds.size());
  }
  if(rm._accelerationBounds.size() == 2)
  {
    config.add("accelerationBounds", rm._accelerationBounds);
  }
  if(rm._jerkBounds.size() == 2)
  {
    config.add("jerkBounds", rm._jerkBounds);
  }
  if(rm._torqueDerivativeBounds.size() == 2)
  {
    config.add("torqueDerivativeBounds", rm._torqueDerivativeBounds);
  }
  config.add("stance", rm._stance);
  auto cHs = rm._convexHull;
  for(auto & cH : cHs)
  {
    cH.second.second = relative(cH.second.second, rm.path).string();
  }
  config.add("convexHulls", cHs);
  auto sHs = rm._convexHull;
  for(auto & sH : sHs)
  {
    sH.second.second = relative(sH.second.second, rm.path).string();
  }
  config.add("collisionObjects", rm._collisionObjects);
  config.add("stpbvHulls", rm._stpbvHull);
  config.add("flexibilities", rm._flexibility);
  config.add("forceSensors", rm._forceSensors);
  config.add("bodySensors", rm._bodySensors);
  config.add("springs", rm._springs);
  config.add("minimalSelfCollisions", rm._minimalSelfCollisions);
  config.add("commonSelfCollisions", rm._commonSelfCollisions);
  config.add("grippers", rm._grippers);
  config.add("ref_joint_order", rm._ref_joint_order);
  config.add("default_attitude", rm._default_attitude);
  config.add("gripperSafety", rm._gripperSafety);
  config.add("lipmStabilizer", rm._lipmStabilizerConfig);
  return config;
}

mc_rbdyn::RobotModulePtr ConfigurationLoader<mc_rbdyn::RobotModulePtr>::load(const mc_rtc::Configuration & config)
{
  mc_rbdyn::RobotModule rm = config;
  return std::make_shared<mc_rbdyn::RobotModule>(std::move(rm));
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::RobotModulePtr>::save(const mc_rbdyn::RobotModulePtr & rm,
                                                                          bool save_mbc,
                                                                          const std::vector<std::string> & filteredLinks,
                                                                          bool fixed)
{
  return ConfigurationLoader<mc_rbdyn::RobotModule>::save(*rm, save_mbc, filteredLinks, fixed);
}

mc_rbdyn::Contact ConfigurationLoader<mc_rbdyn::Contact>::load(const mc_rtc::Configuration & config,
                                                               const mc_rbdyn::Robots & robots)
{
  const auto r1Index = robotIndexFromConfig(config, robots, "contact", false, "r1Index", "r1");
  const auto r2Index = robotIndexFromConfig(config, robots, "contact", false, "r2Index", "r2", robots.robot(1).name());
  sva::PTransformd X_r2s_r1s = sva::PTransformd::Identity();
  bool isFixed = config("isFixed");
  if(isFixed)
  {
    X_r2s_r1s = config("X_r2s_r1s");
  }
  std::string r1Surface = config("r1Surface");
  sva::PTransformd X_b_s = robots.robot(r1Index).surface(r1Surface).X_b_s();
  config("X_b_s", X_b_s);
  double friction = config("friction", mc_rbdyn::Contact::defaultFriction);
  int ambiguityId = config("ambiguityId", -1);
  return mc_rbdyn::Contact(robots, r1Index, r2Index, config("r1Surface"), config("r2Surface"), X_r2s_r1s, X_b_s,
                           friction, ambiguityId);
}

mc_rtc::Configuration ConfigurationLoader<mc_rbdyn::Contact>::save(const mc_rbdyn::Contact & c)
{
  mc_rtc::Configuration config;
  // FIXME saves by index even if the configuration was created by name
  config.add("r1Index", c.r1Index());
  config.add("r2Index", c.r2Index());
  config.add("r1Surface", c.r1Surface()->name());
  config.add("r2Surface", c.r2Surface()->name());
  config.add("X_b_s", c.X_b_s());
  config.add("ambiguityId", c.ambiguityId());
  config.add("isFixed", c.isFixed());
  if(c.isFixed())
  {
    config.add("X_r2s_r1s", c.X_r2s_r1s());
  }
  return config;
}

tasks::qp::JointGains ConfigurationLoader<tasks::qp::JointGains>::load(const mc_rtc::Configuration & config)
{
  if(config.has("damping"))
  {
    return tasks::qp::JointGains(config("jointName"), config("stiffness"), config("damping"));
  }
  else
  {
    return tasks::qp::JointGains(config("jointName"), config("stiffness"));
  }
}

mc_rtc::Configuration ConfigurationLoader<tasks::qp::JointGains>::save(const tasks::qp::JointGains & jg)
{
  mc_rtc::Configuration config;
  config.add("jointName", jg.jointName);
  config.add("stiffness", jg.stiffness);
  config.add("damping", jg.damping);
  return config;
}

} // namespace mc_rtc

ext: cpp


text:
// Distributed under the MIT License.
// See LICENSE.txt for details.

#pragma once

#include <array>
#include <boost/optional.hpp>
#include <cstddef>

#include "DataStructures/DataVector.hpp"
#include "DataStructures/Tensor/EagerMath/DotProduct.hpp"
#include "DataStructures/Tensor/EagerMath/Magnitude.hpp"  // For Tags::Normalized
#include "DataStructures/Tensor/Tensor.hpp"
#include "Domain/InterfaceHelpers.hpp"
#include "Domain/Tags.hpp"
#include "Domain/TagsTimeDependent.hpp"
#include "Utilities/Gsl.hpp"
#include "Utilities/TMPL.hpp"

namespace domain {
namespace Tags {
/// Compute the characteristic speeds on the moving mesh given the
/// characteristic speeds if the mesh were stationary.
///
/// \note Assumes that `typename CharSpeedsComputeTag::return_type` is a
/// `std::array<DataVector, NumberOfCharSpeeds>`
template <typename CharSpeedsComputeTag, size_t Dim>
struct CharSpeedCompute : CharSpeedsComputeTag::base, db::ComputeTag {
  using base = typename CharSpeedsComputeTag::base;
  using return_type = typename CharSpeedsComputeTag::return_type;

  template <typename... Ts, typename T, size_t NumberOfCharSpeeds>
  static void function(
      const gsl::not_null<std::array<T, NumberOfCharSpeeds>*> result,
      const boost::optional<tnsr::I<DataVector, Dim, Frame::Inertial>>&
          grid_velocity,
      const tnsr::i<DataVector, Dim, Frame::Inertial>& unit_normal_covector,
      const Ts&... ts) noexcept {
    // Note that while the CharSpeedsComputeTag almost certainly also needs the
    // unit normal covector for computing the original characteristic speeds, we
    // don't know which of the `ts` it is, and thus we need the unit normal
    // covector to be passed explicitly.
    CharSpeedsComputeTag::function(result, ts...);
    if (static_cast<bool>(grid_velocity)) {
      const Scalar<DataVector> normal_dot_velocity =
          dot_product(*grid_velocity, unit_normal_covector);
      for (size_t i = 0; i < result->size(); ++i) {
        gsl::at(*result, i) -= get(normal_dot_velocity);
      }
    }
  }

  using argument_tags =
      tmpl::push_front<typename CharSpeedsComputeTag::argument_tags,
                       MeshVelocity<Dim, Frame::Inertial>,
                       ::Tags::Normalized<UnnormalizedFaceNormal<Dim>>>;
  using volume_tags = get_volume_tags<CharSpeedsComputeTag>;
};
}  // namespace Tags
}  // namespace domain

ext: hpp

max_stars_repo_name: tomwlodarczyk/spectre

max_issues_repo_name: tomwlodarczyk/spectre

max_forks_repo_name: tomwlodarczyk/spectre


text:
//          Copyright Oliver Kowalke 2009.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#include <stdexcept>
#include <sstream>
#include <string>

#include <boost/test/unit_test.hpp>
#include <boost/utility.hpp>

#include <boost/fiber.hpp>

bool runs_as_fiber = false;
std::string id;
int value = 0;

void runs_as_fn()
{ runs_as_fiber = boost::this_fiber::runs_as_fiber(); }

void get_id_fn()
{
	std::ostringstream os;
	os << boost::this_fiber::get_id();
	id = os.str();
}

void yield_fn( int n)
{
	for ( int i = 0; i < n; ++i)
	{
		++value;
		boost::this_fiber::yield();
	}
}

void cancel_fn( int n)
{
	if ( n < 3) throw std::invalid_argument("must be greater than 3");
	for ( int i = 0; i < n; ++i)
	{
		if ( i == 2) boost::this_fiber::cancel();
		++value;
		boost::this_fiber::yield();
	}
}

void submit_fn( int n)
{
	boost::this_fiber::submit_fiber(
			boost::fibers::make_fiber(
				& yield_fn, n, boost::fiber::default_stacksize) );
}

void test_case_1()
{
	boost::fibers::scheduler<> sched;
	sched.make_fiber( runs_as_fn, boost::fiber::default_stacksize);

	BOOST_CHECK( sched.run() );

	BOOST_CHECK( runs_as_fiber);
}

void test_case_2()
{
	boost::fibers::scheduler<> sched;
	sched.make_fiber( get_id_fn, boost::fiber::default_stacksize);

	BOOST_CHECK( sched.run() );

	BOOST_CHECK( ! id.empty() );
	BOOST_CHECK( std::string("{not-a-fiber}") != id);
}

void test_case_3()
{
	value = 0;
	boost::fibers::scheduler<> sched;
	sched.make_fiber( yield_fn, 3, boost::fiber::default_stacksize);
	BOOST_CHECK_EQUAL( 0, value);

	BOOST_CHECK( sched.run() );
	BOOST_CHECK_EQUAL( 1, value);

	BOOST_CHECK( sched.run() );
	BOOST_CHECK_EQUAL( 2, value);

	BOOST_CHECK( sched.run() );
	BOOST_CHECK_EQUAL( 3, value);

	BOOST_CHECK( sched.run() );
	BOOST_CHECK_EQUAL( 3, value);

	BOOST_CHECK( ! sched.run() );
	BOOST_CHECK_EQUAL( 3, value);
}

void test_case_4()
{
	value = 0;
	boost::fibers::scheduler<> sched;
	sched.make_fiber( cancel_fn, 5, boost::fiber::default_stacksize);
	BOOST_CHECK_EQUAL( 0, value);

	BOOST_CHECK( sched.run() );
	BOOST_CHECK_EQUAL( 1, value);

	BOOST_CHECK( sched.run() );
	BOOST_CHECK_EQUAL( 2, value);

	BOOST_CHECK( sched.run() );
	BOOST_CHECK( sched.empty() );
	BOOST_CHECK_EQUAL( std::size_t( 0), sched.size() );
	BOOST_CHECK( ! sched.run() );
	BOOST_CHECK_EQUAL( 2, value);
}

void test_case_5()
{
	value = 0;
	boost::fibers::scheduler<> sched;
	sched.make_fiber( submit_fn, 5, boost::fiber::default_stacksize);
	BOOST_CHECK_EQUAL( 0, value);

	for (;;)
	{
		while ( sched.run() );
		if ( sched.empty() ) break;
	}
	BOOST_CHECK_EQUAL( 5, value);
}

boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
	boost::unit_test::test_suite * test =
		BOOST_TEST_SUITE("Boost.Fiber: utility test suite");

	test->add( BOOST_TEST_CASE( & test_case_1) );
	test->add( BOOST_TEST_CASE( & test_case_2) );
	test->add( BOOST_TEST_CASE( & test_case_3) );
	test->add( BOOST_TEST_CASE( & test_case_4) );
	test->add( BOOST_TEST_CASE( & test_case_5) );

	return test;
}

max_stars_repo_name: ghisguth/tasks

max_issues_repo_name: ghisguth/tasks

max_forks_repo_name: ghisguth/tasks


text:
#line 397 "/home/daniel/dev/boost/trunk/libs/parameter/doc/index.rst"
#include <boost/parameter/name.hpp>

namespace graphs
{
  BOOST_PARAMETER_NAME(graph)    // Note: no semicolon
  BOOST_PARAMETER_NAME(visitor)
  BOOST_PARAMETER_NAME(root_vertex)
  BOOST_PARAMETER_NAME(index_map)
  BOOST_PARAMETER_NAME(color_map)
}

max_stars_repo_name: ballisticwhisper/boost

max_issues_repo_name: ballisticwhisper/boost

max_forks_repo_name: ballisticwhisper/boost