Skip to content
Snippets Groups Projects
FacilityInfo.h 5.69 KiB
Newer Older
#ifndef MANTID_KERNEL_FACILITYINFO_H_
#define MANTID_KERNEL_FACILITYINFO_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/CatalogInfo.h"
#include "MantidKernel/ComputeResourceInfo.h"
#include "MantidKernel/InstrumentInfo.h"
#include "MantidKernel/RemoteJobManager.h"
#include <boost/shared_ptr.hpp>
#include <vector>
#include <string>

//----------------------------------------------------------------------
// Forward declarations
//----------------------------------------------------------------------
namespace Poco {
namespace XML {
class Element;
}
namespace Mantid {
namespace Kernel {

/** A class that holds information about a facility.

    Copyright &copy; 2007-2012 ISIS Rutherford Appleton Laboratory, NScD Oak
   Ridge National Laboratory & European Spallation Source

    This file is part of Mantid.

    Mantid is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    Mantid is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    File change history is stored at: <https://github.com/mantidproject/mantid>.
    Code Documentation is available at: <http://doxygen.mantidproject.org>
 */
class MANTID_KERNEL_DLL FacilityInfo {
  explicit FacilityInfo(const Poco::XML::Element *elem);
  const std::string &name() const { return m_name; }
  /// Returns default zero padding for this facility
  int zeroPadding() const { return m_zeroPadding; }
  /// Returns the default delimiter between instrument name and run number
  const std::string &delimiter() const { return m_delimiter; }
  /// Returns a list of file extensions
  const std::vector<std::string> extensions() const { return m_extensions; }
  const std::string &preferredExtension() const { return m_extensions.front(); }
  /// Return the archive search interface names
  const std::vector<std::string> &archiveSearch() const {
    return m_archiveSearch;
  }
  /// Returns a list of instruments of this facility
  const std::vector<InstrumentInfo> &instruments() const {
    return m_instruments;
  }
  /// Returns a list of instruments of given technique
  std::vector<InstrumentInfo> instruments(const std::string &tech) const;
  /// Returns instruments with given name
  const InstrumentInfo &instrument(std::string iName = "") const;

  /// Returns a vector of available compute resources
  std::vector<ComputeResourceInfo> computeResInfos() const;
  /// Returns a compute resource identified by name
  const ComputeResourceInfo &computeResource(const std::string &name) const;

  /// Returns a vector of the names of the available compute resources
  std::vector<std::string> computeResources() const;
  /// Returns the RemoteJobManager for the named compute resource
  boost::shared_ptr<RemoteJobManager>
  getRemoteJobManager(const std::string &name) const;
  /// Returns the catalogInfo class.
  const CatalogInfo &catalogInfo() const { return m_catalogs; }
  /// Returns a bool indicating whether prefix is required in file names
  bool noFilePrefix() const { return m_noFilePrefix; }
  /// Returns the multiple file limit
  size_t multiFileLimit() const { return m_multiFileLimit; }

  void fillZeroPadding(const Poco::XML::Element *elem);
  void fillDelimiter(const Poco::XML::Element *elem);
  void fillExtensions(const Poco::XML::Element *elem);
  void fillArchiveNames(const Poco::XML::Element *elem);
  void fillInstruments(const Poco::XML::Element *elem);
  void fillHTTPProxy(const Poco::XML::Element *elem);
  void fillComputeResources(const Poco::XML::Element *elem);
  void fillNoFilePrefix(const Poco::XML::Element *elem);
  void fillMultiFileLimit(const Poco::XML::Element *elem);
  void addExtension(const std::string &ext);

  CatalogInfo m_catalogs;   ///< Gain access to the catalogInfo class.
  const std::string m_name; ///< facility name
  int m_zeroPadding;        ///< default zero padding for this facility
  std::string
      m_delimiter; ///< default delimiter between instrument name and run number
  std::vector<std::string>
      m_extensions; ///< file extensions in order of preference
  std::vector<std::string>
      m_archiveSearch; ///< names of the archive search interface
  std::vector<InstrumentInfo>
Michael Hart's avatar
Michael Hart committed
      m_instruments;   ///< list of instruments of this facility
  bool m_noFilePrefix; ///< flag indicating if prefix is required in file names
  size_t m_multiFileLimit; ///< the multiple file limit
  std::vector<ComputeResourceInfo> m_computeResInfos; ///< (remote) compute
  /// resources available in
  /// this facility

  // TODO: remove RemoteJobManager form here (trac ticket #11373)
  typedef std::map<std::string, boost::shared_ptr<RemoteJobManager>>
      ComputeResourcesMap;
  ComputeResourcesMap m_computeResources; ///< list of compute resources
                                          ///(clusters, etc...) available at
};

} // namespace Kernel
} // namespace Mantid

#endif /* MANTID_KERNEL_FACILITYINFO_H_ */