/usr/include/arc/compute/JobDescriptionParserPlugin.h is in nordugrid-arc-dev 4.2.0-2.
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | // -*- indent-tabs-mode: nil -*-
#ifndef __ARC_JOBDESCRIPTIONPARSERPLUGIN_H__
#define __ARC_JOBDESCRIPTIONPARSERPLUGIN_H__
/** \file
* \brief Plugin, loader and argument classes for job description parser specialisation.
*/
#include <map>
#include <string>
#include <arc/loader/Loader.h>
#include <arc/loader/Plugin.h>
namespace Arc {
class JobDescription;
class Logger;
/**
* \ingroup accplugins
* \headerfile JobDescriptionParserPlugin.h arc/compute/JobDescriptionParserPlugin.h
*/
class JobDescriptionParserPluginResult {
public:
typedef enum {
Success,
Failure,
WrongLanguage
} Result;
JobDescriptionParserPluginResult(void):v_(Success) { };
JobDescriptionParserPluginResult(bool v):v_(v?Success:Failure) { };
JobDescriptionParserPluginResult(Result v):v_(v) { };
operator bool(void) { return (v_ == Success); };
bool operator!(void) { return (v_ != Success); };
bool operator==(bool v) { return ((v_ == Success) == v); };
bool operator==(Result v) { return (v_ == v); };
private:
Result v_;
};
/// Abstract class for the different parsers
/**
* The JobDescriptionParserPlugin class is abstract which provide a interface
* for job description parsers. A job description parser should inherit this
* class and overwrite the JobDescriptionParserPlugin::Parse and
* JobDescriptionParserPlugin::UnParse methods.
*
* \ingroup accplugins
* \headerfile JobDescriptionParserPlugin.h arc/compute/JobDescriptionParserPlugin.h
*/
class JobDescriptionParserPlugin
: public Plugin {
public:
virtual ~JobDescriptionParserPlugin();
virtual JobDescriptionParserPluginResult Parse(const std::string& source, std::list<JobDescription>& jobdescs, const std::string& language = "", const std::string& dialect = "") const = 0;
virtual JobDescriptionParserPluginResult UnParse(const JobDescription& job, std::string& output, const std::string& language, const std::string& dialect = "") const = 0;
const std::list<std::string>& GetSupportedLanguages() const { return supportedLanguages; }
bool IsLanguageSupported(const std::string& language) const { return std::find(supportedLanguages.begin(), supportedLanguages.end(), language) != supportedLanguages.end(); }
const std::string& GetError(void) { return error; };
protected:
JobDescriptionParserPlugin(PluginArgument* parg);
std::string& SourceLanguage(JobDescription& j) const;
std::list<std::string> supportedLanguages;
mutable std::string error;
static Logger logger;
};
/** Class responsible for loading JobDescriptionParserPlugin plugins
* The JobDescriptionParserPlugin objects returned by a
* JobDescriptionParserPluginLoader must not be used after the
* JobDescriptionParserPluginLoader goes out of scope.
*
* \ingroup accplugins
* \headerfile JobDescriptionParserPlugin.h arc/compute/JobDescriptionParserPlugin.h
*/
class JobDescriptionParserPluginLoader
: public Loader {
public:
/** Constructor
* Creates a new JobDescriptionParserPluginLoader.
*/
JobDescriptionParserPluginLoader();
/** Destructor
* Calling the destructor destroys all JobDescriptionParserPlugin object
* loaded by the JobDescriptionParserPluginLoader instance.
*/
~JobDescriptionParserPluginLoader();
/** Load a new JobDescriptionParserPlugin
* \param name The name of the JobDescriptionParserPlugin to load.
* \return A pointer to the new JobDescriptionParserPlugin (NULL on error).
*/
JobDescriptionParserPlugin* load(const std::string& name);
/** Retrieve the list of loaded JobDescriptionParserPlugin objects.
* \return A reference to the list of JobDescriptionParserPlugin objects.
*/
const std::list<JobDescriptionParserPlugin*>& GetJobDescriptionParserPlugins() const { return jdps; }
class iterator {
private:
iterator(JobDescriptionParserPluginLoader& jdpl);
iterator& operator=(const iterator& it) { return *this; }
public:
~iterator() {}
//iterator& operator=(const iterator& it) { current = it.current; jdpl = it.jdpl; return *this; }
JobDescriptionParserPlugin& operator*() { return **current; }
const JobDescriptionParserPlugin& operator*() const { return **current; }
JobDescriptionParserPlugin* operator->() { return *current; }
const JobDescriptionParserPlugin* operator->() const { return *current; }
iterator& operator++();
operator bool() { return !jdpl->jdpDescs.empty() || current != jdpl->jdps.end(); }
friend class JobDescriptionParserPluginLoader;
private:
void LoadNext();
std::list<JobDescriptionParserPlugin*>::iterator current;
JobDescriptionParserPluginLoader* jdpl;
};
iterator GetIterator() { return iterator(*this); }
private:
std::list<JobDescriptionParserPlugin*> jdps;
std::list<ModuleDesc> jdpDescs;
void scan();
bool scaningDone;
};
} // namespace Arc
#endif // __ARC_JOBDESCRIPTIONPARSERPLUGIN_H__
|