GCC Code Coverage Report


./
File: libs/__/activity/validator/activity.hpp
Date: 2025-01-21 16:21:04
Lines:
1/7
14.3%
Functions:
0/3
0.0%
Branches:
0/11
0.0%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2016-2024 IRCAD France
4 * Copyright (C) 2016-2019 IHU Strasbourg
5 *
6 * This file is part of Sight.
7 *
8 * Sight is free software: you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Sight is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
20 *
21 ***********************************************************************/
22
23 #pragma once
24
25 #include <sight/activity/config.hpp>
26
27 #include "activity/validator/base.hpp"
28
29 #include <core/base.hpp>
30
31 #include <data/activity.hpp>
32
33 namespace sight::data
34 {
35
36 class Activity;
37
38 } // namespace sight::data
39
40 namespace sight::activity::validator
41 {
42
43 /**
44 * @brief Base class for all activity validator's classes.
45 *
46 * This validator allows to check if all the required data are valid for the activity.
47 */
48 26 class SIGHT_ACTIVITY_CLASS_API activity : public validator::base
49 {
50 public:
51
52 SIGHT_DECLARE_CLASS(activity, validator::base);
53
54 /// Does nothing.
55 SIGHT_ACTIVITY_API return_t validate(
56 const extension::activity_info& /*activity_info*/,
57 const CSPTR(data::vector)&
58 /*currentSelection*/
59 ) const override
60 {
61 return_t validation;
62 validation.first = true;
63 validation.second = "This validator does not validate this selection of data.";
64 return validation;
65 }
66
67 /**
68 * @brief Performs the validation of the given activity data.
69 * @return pair <isValid, errorMsg> : errorMsg is empty if the data are valid else it contains detailed error.
70 */
71 SIGHT_ACTIVITY_API virtual return_t validate(const CSPTR(data::activity)& _activity) const = 0;
72
73 /**
74 * @brief Checks if all the required data are present in the activity.
75 * @return pair <isValid, errorMsg> : errorMsg is empty if the data are valid else it contains the list of missing
76 * (or not valid) data.
77 */
78 static SIGHT_ACTIVITY_API return_t check_requirements(const CSPTR(data::activity)& _activity);
79
80 /**
81 * @brief Calls the object validator if it is defined.
82 * @param _object object to validate
83 * @param _validator_impl implementation of the validator to apply (if it is empty, check is assumed as valid).
84 * @return pair <isValid, errorMsg> : errorMsg is empty if the object is valid else it contains the detailed error.
85 * @see activity::validator::object
86 */
87 static SIGHT_ACTIVITY_API return_t check_object(
88 const CSPTR(data::object)& _object,
89 const std::string& _validator_impl
90 );
91 };
92
93 } // namespace sight::activity::validator
94