@@ -265,23 +265,25 @@ void getRunArgByIdx (IIStream& is, cv::util::variant<Ts...> &v, uint32_t idx) {
265265
266266namespace detail
267267{
268- template <typename T> struct deserialize_arg ;
268+ template <typename T> struct try_deserialize_comparg ;
269269
270- template <> struct deserialize_arg <std::tuple<>> {
271- static GCompileArg exec (cv::gapi::s11n::IIStream&, const std::string &) {
272- throw std::logic_error ( " Passed arg can't be deserialized! " ) ;
270+ template <> struct try_deserialize_comparg <std::tuple<>> {
271+ static cv::util::optional< GCompileArg> exec (const std::string&, cv::gapi::s11n::IIStream&) {
272+ return { } ;
273273 }
274274};
275275
276276template <typename T, typename ... Types>
277- struct deserialize_arg <std::tuple<T, Types...>> {
278- static GCompileArg exec (cv::gapi::s11n::IIStream& is, const std::string& tag ) {
277+ struct try_deserialize_comparg <std::tuple<T, Types...>> {
278+ static cv::util::optional< GCompileArg> exec (const std::string& tag, cv::gapi::s11n::IIStream& is) {
279279 if (tag == cv::detail::CompileArgTag<T>::tag ()) {
280- return GCompileArg {
281- cv::gapi::s11n::detail::S11N<T>::deserialize (is)
282- };
280+ static_assert (cv::gapi::s11n::detail::has_S11N_spec<T>::value,
281+ " cv::gapi::deserialize<GCompileArgs, Types...> expects Types to have S11N "
282+ " specializations with deserialization callbacks!" );
283+ return cv::util::optional<GCompileArg>(
284+ GCompileArg { cv::gapi::s11n::detail::S11N<T>::deserialize (is) });
283285 }
284- return deserialize_arg <std::tuple<Types...>>::exec (is, tag );
286+ return try_deserialize_comparg <std::tuple<Types...>>::exec (tag, is );
285287}
286288};
287289
@@ -303,17 +305,35 @@ static GRunArg exec(cv::gapi::s11n::IIStream& is, uint32_t idx) {
303305};
304306
305307template <typename ... Types>
306- cv::GCompileArgs getCompileArgs (const std::vector<char > &p) {
307- std::unique_ptr<cv::gapi::s11n::IIStream> pIs = cv::gapi::s11n::detail::getInStream (p);
308- cv::gapi::s11n::IIStream& is = *pIs;
308+ inline cv::util::optional<GCompileArg> tryDeserializeCompArg (const std::string& tag,
309+ const std::vector<char >& sArg ) {
310+ std::unique_ptr<cv::gapi::s11n::IIStream> pArgIs = cv::gapi::s11n::detail::getInStream (sArg );
311+ return try_deserialize_comparg<std::tuple<Types...>>::exec (tag, *pArgIs);
312+ }
313+
314+ template <typename ... Types>
315+ cv::GCompileArgs getCompileArgs (const std::vector<char > &sArgs ) {
309316 cv::GCompileArgs args;
310317
318+ std::unique_ptr<cv::gapi::s11n::IIStream> pIs = cv::gapi::s11n::detail::getInStream (sArgs );
319+ cv::gapi::s11n::IIStream& is = *pIs;
320+
311321 uint32_t sz = 0 ;
312322 is >> sz;
313323 for (uint32_t i = 0 ; i < sz; ++i) {
314324 std::string tag;
315325 is >> tag;
316- args.push_back (cv::gapi::detail::deserialize_arg<std::tuple<Types...>>::exec (is, tag));
326+
327+ std::vector<char > sArg ;
328+ is >> sArg ;
329+
330+ cv::util::optional<GCompileArg> dArg =
331+ cv::gapi::detail::tryDeserializeCompArg<Types...>(tag, sArg );
332+
333+ if (dArg.has_value ())
334+ {
335+ args.push_back (dArg.value ());
336+ }
317337 }
318338
319339 return args;
0 commit comments