base.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. //
  5. // Copyright (C) 2020 Intel Corporation
  6. #ifndef OPENCV_GAPI_S11N_BASE_HPP
  7. #define OPENCV_GAPI_S11N_BASE_HPP
  8. #include <opencv2/gapi/own/assert.hpp>
  9. #include <opencv2/gapi/own/exports.hpp>
  10. namespace cv {
  11. namespace gapi {
  12. namespace s11n {
  13. struct IOStream;
  14. struct IIStream;
  15. namespace detail {
  16. struct NotImplemented {
  17. };
  18. // The default S11N for custom types is NotImplemented
  19. // Don't! sublass from NotImplemented if you actually implement S11N.
  20. template<typename T>
  21. struct S11N: public NotImplemented {
  22. static void serialize(IOStream &, const T &) {
  23. GAPI_Assert(false && "No serialization routine is provided!");
  24. }
  25. static T deserialize(IIStream &) {
  26. GAPI_Assert(false && "No deserialization routine is provided!");
  27. }
  28. };
  29. template<typename T> struct has_S11N_spec {
  30. static constexpr bool value = !std::is_base_of<NotImplemented,
  31. S11N<typename std::decay<T>::type>>::value;
  32. };
  33. } // namespace detail
  34. } // namespace s11n
  35. } // namespace gapi
  36. } // namespace cv
  37. #endif // OPENCV_GAPI_S11N_BASE_HPP