This file is indexed.

/usr/include/arc/compute/JobDescriptionParserPlugin.h is in nordugrid-arc-dev 5.4.2-1build1.

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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// -*- 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 <utility>
#include <algorithm>

#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
   */


  /**
   * \since Added in 5.1.0
   **/
  class JobDescriptionParsingError {
  public:
    JobDescriptionParsingError() {}
    JobDescriptionParsingError(const std::string& message, const std::pair<int, int>& line_pos = std::make_pair(0, 0), const std::string& failing_code = "")
      : message(message), failing_code(failing_code), line_pos(line_pos) {}
    ~JobDescriptionParsingError() {}
    std::string message;
    std::string failing_code;
    std::pair<int, int> line_pos;
  };

  class JobDescriptionParserPluginResult {
  public:
    typedef enum {
      Success,
      Failure, /**< Parsing failed **/
      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); };
    /**
     * \since Added in 5.1.0
     **/
    bool HasErrors() const { return !errors_.empty(); };
    /**
     * \since Added in 5.1.0
     **/
    const std::list<JobDescriptionParsingError>& GetErrors() const { return errors_; };
    /**
     * \since Added in 5.1.0
     **/
    void AddError(const JobDescriptionParsingError& error) { errors_.push_back(error); };
    /**
     * \since Added in 5.1.0
     **/
    void AddError(const IString& msg,
                  const std::pair<int, int>& location = std::make_pair(0, 0),
                  const std::string& failing_code = "") {
      errors_.push_back(JobDescriptionParsingError(msg.str(), location, failing_code));
    }
    /**
     * \since Added in 5.1.0
     **/
    void SetSuccess() { v_ = Success; };
    /**
     * \since Added in 5.1.0
     **/
    void SetFailure() { v_ = Failure; };
    /**
     * \since Added in 5.1.0
     **/
    void SetWrongLanguage() {v_ = WrongLanguage; };
  private:
    Result v_;
    std::list<JobDescriptionParsingError> errors_;
  };

  /// Abstract plugin class for different parsers
  /**
   * The JobDescriptionParserPlugin class is abstract which provide an interface
   * for job description parsers. A job description parser should inherit this
   * class and overwrite the JobDescriptionParserPlugin::Parse and
   * JobDescriptionParserPlugin::UnParse methods. The inheriating class should
   * add the job description languages that it supports to the
   * 'supportedLanguages' member, formatted according to the GLUE2
   * JobDescription_t type (GFD-R-P.147). The created job description parser
   * will then be available to the JobDescription::Parse,
   * JobDescription::ParseFromFile and JobDescription::Assemble methods, adding
   * the ability to parse and assemble job descriptions in the specified
   * languages.
   *
   * Using the methods in JobDescription class for parsing job descriptions is
   * recommended, however it is also possible to use parser plugins directly,
   * which can be done by loading them using the
   * JobDescriptionParserPluginLoader class.
   *
   * Since this class inheriates from the Plugin class, inheriating classes
   * should be compiled as a loadable module. See xxx for information on
   * creating loadable modules for ARC.
   *
   * \ingroup accplugins
   * \headerfile JobDescriptionParserPlugin.h arc/compute/JobDescriptionParserPlugin.h
   */
  class JobDescriptionParserPlugin
    : public Plugin {
  public:
    virtual ~JobDescriptionParserPlugin();

    /// Parse string into JobDescription objects
    /**
     * Parses the string argument \p source into JobDescription objects. If the
     * \p language argument is specified the method will only parse the string
     * if it supports that language - a JobDescriptionParserPluginResult object
     * with status \ref JobDescriptionParserPluginResult::WrongLanguage "WrongLanguage"
     * is returned if language is not supported. Similar for the \p dialect
     * argument, if specified, string is only parsed if that dialect is known
     * by parser.
     * If the \p language argument is not specified an attempt at parsing
     * \p source using any of the supported languages is tried.
     * If parsing is successful the generated JobDescription objects is appended
     * to the \p jobdescs argument. If parsing is unsuccessful the \p jobdescs
     * argument is untouched, and details of the failure is returned.
     *
     * Inheriating classes must extend this method. The extended method should
     * parse the \p source argument string into a JobDescription object, possibly
     * into multiple objects. Some languages can contain multiple alternative
     * views, in such cases alternatives should be added using the
     * JobDescription::AddAlternative method. Only if parsing is successful
     * should the generated JobDescription objects be added to the \p jobdescs
     * argument. Note: The only allowed modification of the \p jobdescs list is
     * adding elements. If the \p language argument is specified parsing should
     * only be initiated if the specified language is among the supported
     * ones, if that is not the case \ref JobDescriptionParserPluginResult::WrongLanguage "WrongLanguage"
     * should be returned.
     * If the \p language argument
     * For some languages different dialects exist (e.g. user- and GM- side xRSL,
     * JSDL, JSDL-POSIX), and if the \p dialect argument is specified the
     * parsing must strictly conform to that dialect. If the dialect is unknown
     * \ref JobDescriptionParserPluginResult::WrongLanguage "WrongLanguage"
     * should be returned.
     *
     * \param source should contain a representation of job description as a
     *  string.
     * \param jobdescs a reference to a list of JobDescription object which
     *  parsed job descriptions should be appended to.
     * \param language if specified parse in specified language (if not supported
     *  \ref JobDescriptionParserPluginResult::WrongLanguage "WrongLanguage" is
     *  returned).
     * \param dialect if specified parsing conforms strictly to specified
     *  dialect.
     * \return A JobDescriptionParserPluginResult is returned indicating outcome
     *  of parsing.
     * \see JobDescriptionParserPlugin::Assemble
     * \see JobDescriptionParserPluginResult
     **/
    virtual JobDescriptionParserPluginResult Parse(const std::string& source, std::list<JobDescription>& jobdescs, const std::string& language = "", const std::string& dialect = "") const = 0;

    /// Assemble job description into string
    /**
     * \since Added in 5.1.0
     **/
    virtual JobDescriptionParserPluginResult Assemble(const JobDescription& job, std::string& output, const std::string& language, const std::string& dialect = "") const = 0;

    /// [DEPRECATED] Assemble job description into string
    /**
     * \deprecated Deprecated as of 5.1.0, use the
     *  JobDescriptionParserPlugin::Assemble method instead - expected to be
     *  removed in 6.0.0.
     **/
    virtual JobDescriptionParserPluginResult UnParse(const JobDescription& job, std::string& output, const std::string& language, const std::string& dialect = "") const { return Assemble(job, output, language, dialect); };

    /// Get supported job description languages
    /**
     * \return A list of job description languages supported by this parser is
     * returned.
     **/
    const std::list<std::string>& GetSupportedLanguages() const { return supportedLanguages; }

    /// Check if language is supported
    /**
     * \param language a string formatted according to the GLUE2
     *  JobDescription_t type (GFD-R-P.147), e.g. nordugrid:xrsl.
     * \return \c true is returned if specified language is supported.
     **/
    bool IsLanguageSupported(const std::string& language) const { return std::find(supportedLanguages.begin(), supportedLanguages.end(), language) != supportedLanguages.end(); }

    /// [DEPRECATED] Get parsing error
    /**
     * \deprecated Deprecated as of 5.1.0 - expected to be removed in 6.0.0.
     **/
    const std::string& GetError(void) { return error; };

  protected:
    JobDescriptionParserPlugin(PluginArgument* parg);

    /// [DEPRECATED] Get reference to sourceLanguage member
    /**
     * \deprecated Deprecated as of 5.1.0 - expected to be removed in 6.0.0.
     **/
    std::string& SourceLanguage(JobDescription& j) const;

    /// List of supported job description languages
    /**
     * Inheriating classes should add languages supported to this list in
     * the constructor.
     **/
    std::list<std::string> supportedLanguages;

    /// [DEPRECATED] Parsing error
    /**
     * \deprecated Deprecated as of 5.1.0 - expected to be removed in 6.0.0.
     **/
    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__