//===-- app/AppSystem.cpp ---------------------------------------*- C++ -*-===//
//
//                                 The RoSA Framework
//
// Distributed under the terms and conditions of the Boost Software License 1.0.
// See accompanying file LICENSE.
//
// If you did not receive a copy of the license file, see
// http://www.boost.org/LICENSE_1_0.txt.
//
//===----------------------------------------------------------------------===//
///
/// \file app/AppSystem.cpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017-2020
///
/// \brief Implementation of rosa/app/AppSystem.hpp.
///
//===----------------------------------------------------------------------===//

#include "rosa/app/AppSystem.hpp"

#include "AppSystemImpl.hpp"

namespace rosa {
namespace app {

std::unique_ptr<AppSystem>
AppSystem::createSystem(const std::string &Name) noexcept {
  return std::unique_ptr<AppSystem>(new AppSystemImpl(Name));
}

Optional<const AppSensor &> AppSystem::getAppSensor(const AgentHandle &H) const
    noexcept {
  if (isAppSensor(H)) {
    return {static_cast<const AppSensor &>(unwrapAgent(H))};
  } else {
    return {};
  }
}

Optional<AppSensor &> AppSystem::getAppSensor(AgentHandle &H) const noexcept {
  if (isAppSensor(H)) {
    return {static_cast<AppSensor &>(unwrapAgent(H))};
  } else {
    return {};
  }
}

Optional<const AppAgent &> AppSystem::getAppAgent(const AgentHandle &H) const
    noexcept {
  if (isAppAgent(H)) {
    return {static_cast<const AppAgent &>(unwrapAgent(H))};
  } else {
    return {};
  }
}

Optional<AppAgent &> AppSystem::getAppAgent(AgentHandle &H) const noexcept {
  if (isAppAgent(H)) {
    return {static_cast<AppAgent &>(unwrapAgent(H))};
  } else {
    return {};
  }
}

} // End namespace app
} // End namespace rosa
