Remove building with NOCRYPTO option
[minix3.git] / external / bsd / kyua-cli / dist / engine / metadata.hpp
blob3d3baa3d9bb9396ea3008f9682d1e0822dda161c
1 // Copyright 2012 Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Google Inc. nor the names of its contributors
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 /// \file engine/metadata.hpp
30 /// Representation of the metadata of a test program or test case.
32 #if !defined(ENGINE_METADATA_HPP)
33 #define ENGINE_METADATA_HPP
35 #include <map>
36 #include <memory>
37 #include <ostream>
38 #include <set>
39 #include <string>
41 #include "utils/noncopyable.hpp"
42 #include "utils/shared_ptr.hpp"
44 namespace utils {
45 namespace config { class tree; }
46 namespace datetime { class delta; }
47 namespace fs { class path; }
48 namespace units { class bytes; }
49 } // namespace utils
51 namespace engine {
54 // TODO(jmmv): All these types should probably be in individual header files so
55 // that we could include them without pulling in additional dependencies.
56 /// Collection of paths.
57 typedef std::set< utils::fs::path > paths_set;
58 /// Collection of strings.
59 typedef std::set< std::string > strings_set;
60 /// Collection of test properties in their textual form.
61 typedef std::map< std::string, std::string > properties_map;
64 extern utils::datetime::delta default_timeout;
67 class metadata_builder;
70 /// Collection of metadata properties of a test.
71 class metadata {
72 struct impl;
74 /// Pointer to the shared internal implementation.
75 std::shared_ptr< impl > _pimpl;
77 friend class metadata_builder;
79 public:
80 metadata(const utils::config::tree&);
81 ~metadata(void);
83 const strings_set& allowed_architectures(void) const;
84 const strings_set& allowed_platforms(void) const;
85 properties_map custom(void) const;
86 const std::string& description(void) const;
87 bool has_cleanup(void) const;
88 const strings_set& required_configs(void) const;
89 const paths_set& required_files(void) const;
90 const utils::units::bytes& required_memory(void) const;
91 const paths_set& required_programs(void) const;
92 const std::string& required_user(void) const;
93 const utils::datetime::delta& timeout(void) const;
95 engine::properties_map to_properties(void) const;
97 bool operator==(const metadata&) const;
98 bool operator!=(const metadata&) const;
102 std::ostream& operator<<(std::ostream&, const metadata&);
105 /// Builder for a metadata object.
106 class metadata_builder : utils::noncopyable {
107 struct impl;
109 /// Pointer to the shared internal implementation.
110 std::auto_ptr< impl > _pimpl;
112 public:
113 metadata_builder(void);
114 explicit metadata_builder(const engine::metadata&);
115 ~metadata_builder(void);
117 metadata_builder& add_allowed_architecture(const std::string&);
118 metadata_builder& add_allowed_platform(const std::string&);
119 metadata_builder& add_custom(const std::string&, const std::string&);
120 metadata_builder& add_required_config(const std::string&);
121 metadata_builder& add_required_file(const utils::fs::path&);
122 metadata_builder& add_required_program(const utils::fs::path&);
124 metadata_builder& set_allowed_architectures(const strings_set&);
125 metadata_builder& set_allowed_platforms(const strings_set&);
126 metadata_builder& set_custom(const properties_map&);
127 metadata_builder& set_description(const std::string&);
128 metadata_builder& set_has_cleanup(const bool);
129 metadata_builder& set_required_configs(const strings_set&);
130 metadata_builder& set_required_files(const paths_set&);
131 metadata_builder& set_required_memory(const utils::units::bytes&);
132 metadata_builder& set_required_programs(const paths_set&);
133 metadata_builder& set_required_user(const std::string&);
134 metadata_builder& set_string(const std::string&, const std::string&);
135 metadata_builder& set_timeout(const utils::datetime::delta&);
137 metadata build(void) const;
141 std::string check_reqs(const engine::metadata&, const utils::config::tree&,
142 const std::string&);
145 } // namespace engine
148 #endif // !defined(ENGINE_METADATA_HPP)