Page MenuHomePhorge

AwaitBase.cpp
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

AwaitBase.cpp

//===-- app/executionpolicies/AwaitBase.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/executionpolicies/AwaitBase.cpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2019-2020
///
/// \brief Implementation for app/executionpolicies/AwaitBase.h.
///
//===----------------------------------------------------------------------===//
#include "AwaitBase.h"
#include "rosa/support/debug.hpp"
#include <algorithm>
#include <sstream>
namespace rosa {
namespace app {
AwaitBase::AwaitBase(const std::set<size_t> &S, CheckerType &&Checker)
: Set(S), Checker(Checker) {}
bool AwaitBase::canHandle(const AgentHandle H, const AppSystem &S) const
noexcept {
return isAppAgent(H, S) &&
canHandleNumberOfInputs(numberOfAppAgentInputs(H, S));
}
bool AwaitBase::shouldProcess(const std::vector<bool> &InputChanged) noexcept {
// Sanity check of usage.
ASSERT(canHandleNumberOfInputs(InputChanged.size()));
return Checker(Set.begin(), Set.end(),
[&InputChanged](const size_t I) { return InputChanged[I]; });
}
bool AwaitBase::canHandleNumberOfInputs(const size_t NumberOfInputs) const
noexcept {
const auto MaxElemIt = std::max_element(Set.begin(), Set.end());
const size_t MaxElem = (MaxElemIt == Set.end()) ? 0 : *MaxElemIt;
return MaxElem <= NumberOfInputs;
}
std::string AwaitBase::dumpS(void) const noexcept {
std::stringstream SS;
SS << "[";
for (const auto &Value : Set) {
SS << " " << Value;
}
SS << " ]";
return SS.str();
}
} // End namespace app
} // End namespace rosa

File Metadata

Mime Type
text/x-c++
Expires
Sun, Apr 12, 4:39 AM (5 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
280807
Default Alt Text
AwaitBase.cpp (1 KB)

Event Timeline