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