/usr/include/facter/facts/resolver.hpp is in facter-dev 3.10.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | /**
* @file
* Declares the base class for fact resolvers.
*/
#pragma once
#include "../export.h"
#include <vector>
#include <memory>
#include <stdexcept>
#include <string>
#include <boost/regex.hpp>
namespace facter { namespace facts {
/**
* Thrown when a resolver is constructed with an invalid fact name pattern.
*/
struct LIBFACTER_EXPORT invalid_name_pattern_exception : std::runtime_error
{
/**
* Constructs a invalid_name_pattern_exception.
* @param message The exception message.
*/
explicit invalid_name_pattern_exception(std::string const& message);
};
struct collection;
/**
* Base class for fact resolvers.
* A fact resolver is responsible for resolving one or more facts.
* This type can be moved but cannot be copied.
*/
struct LIBFACTER_EXPORT resolver
{
/**
* Constructs a resolver.
* @param name The fact resolver name.
* @param names The fact names the resolver is responsible for.
* @param patterns Regular expression patterns for additional ("dynamic") facts the resolver is responsible for.
*/
resolver(std::string name, std::vector<std::string> names, std::vector<std::string> const& patterns = {});
/**
* Destructs the resolver.
*/
virtual ~resolver();
/**
* Prevents the resolver from being copied.
*/
resolver(resolver const&) = delete;
/**
* Prevents the resolver from being copied.
* @returns Returns this resolver.
*/
resolver& operator=(resolver const&) = delete;
/**
* Moves the given resolver into this resolver.
* @param other The resolver to move into this resolver.
*/
// Visual Studio 12 still doesn't allow default for move constructor.
resolver(resolver&& other);
/**
* Moves the given resolver into this resolver.
* @param other The resolver to move into this resolver.
* @return Returns this resolver.
*/
// Visual Studio 12 still doesn't allow default for move assignment.
resolver& operator=(resolver&& other);
/**
* Gets the name of the fact resolver.
* @return Returns the fact resolver's name.
*/
std::string const& name() const;
/**
* Gets the fact names the resolver is responsible for resolving.
* @return Returns a vector of fact names.
*/
std::vector<std::string> const& names() const;
/**
* Determines if the resolver has patterns.
* @return Returns true if the resolver has patterns or false if it does not.
*/
bool has_patterns() const;
/**
* Determines if the given name matches a pattern for the resolver.
* @param name The fact name to check.
* @return Returns true if the name matches a pattern or returns false if it does not.
*/
bool is_match(std::string const& name) const;
/**
* Gets list of languages accepted by the fact resolver for HTTP requests.
* @return Returns the fact resolver's accepted languages (comma-separated list of language tags formatted for the HTTP Accept-Language header.)
*/
std::string const& http_langs();
/**
* Called to resolve all facts the resolver is responsible for.
* @param facts The fact collection that is resolving facts.
*/
virtual void resolve(collection& facts) = 0;
/**
* Determines if this resolver can be blocked from collecting its facts.
* @return Returns true if this resolver can be blocked, false otherwise
*/
virtual bool is_blockable() const;
private:
std::string _name;
std::vector<std::string> _names;
std::vector<boost::regex> _regexes;
std::string _http_langs;
};
}} // namespace facter::facts
|