Page MenuHomePhorge

No OneTemporary

Size
92 KB
Referenced Files
None
Subscribers
None
diff --git a/include/rosa/deluxe/DeluxeAgent.hpp b/include/rosa/deluxe/DeluxeAgent.hpp
index 0e83a7c..535a2ec 100755
--- a/include/rosa/deluxe/DeluxeAgent.hpp
+++ b/include/rosa/deluxe/DeluxeAgent.hpp
@@ -1,673 +1,698 @@
//===-- rosa/deluxe/DeluxeAgent.hpp -----------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/deluxe/DeluxeAgent.hpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017-2019
///
/// \brief Specialization of \c rosa::Agent for *agent* role of the *deluxe
/// interface*.
///
/// \see \c rosa::deluxe::DeluxeContext
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_DELUXE_DELUXEAGENT_HPP
#define ROSA_DELUXE_DELUXEAGENT_HPP
#include "rosa/core/Agent.hpp"
#include "rosa/deluxe/DeluxeAtoms.hpp"
+#include "rosa/deluxe/DeluxeExecutionPolicy.h"
#include <map>
/// Local helper macros to deal with built-in types.
///
///@{
/// Creates function name for member functions in \c rosa::deluxe::DeluxeAgent.
///
/// \param N name suffix to use
#define DAHANDLERNAME(N) handleSlave_##N
/// Defines member functions for handling messages from *slaves* in
/// \c rosa::deluxe::DeluxeAgent.
///
/// \see \c DeluxeAgentInputHandlers
///
/// \note No pre- and post-conditions are validated directly by these functions,
/// they rather rely on \c rosa::deluxe::DeluxeAgent::saveInput to do that.
///
/// \param T the type of input to handle
/// \param N name suffix for the function identifier
#define DAHANDLERDEFN(T, N) \
void DAHANDLERNAME(N)(atoms::Slave, id_t SlaveId, T Value) noexcept { \
saveInput(SlaveId, Value); \
}
/// Convenience macro for \c DAHANDLERDEFN with identical arguments.
///
/// \see \c DAHANDLERDEFN
///
/// This macro can be used instead of \c DAHANDLERDEFN if the actual value of
/// \p T can be used as a part of a valid identifier.
///
/// \param T the type of input to handle
#define DAHANDLERDEF(T) DAHANDLERDEFN(T, T)
/// Results in a \c THISMEMBER reference to a member function defined by
/// \c DAHANDLERDEFN.
///
/// Used in the constructor of \c rosa::deluxe::DeluxeAgent to initialize super
/// class \c rosa::Agent with member function defined by \c DAHANDLERDEFN.
///
/// \see \c DAHANDLERDEFN, \c THISMEMBER
///
/// \param N name suffix for the function identifier
#define DAHANDLERREF(N) THISMEMBER(DAHANDLERNAME(N))
///@}
namespace rosa {
namespace deluxe {
/// Specialization of \c rosa::Agent for *agent* role of the *deluxe interface*.
///
/// \see \c rosa::deluxe::DeluxeContext
///
/// \invariant All input-related container objects have a size matching
/// \c rosa::deluxe::DeluxeAgent::NumberOfInputs, thus having a corresponding
/// entry for each input. Types of input values are consistent throughout all
/// the input-related containers. No *slave* is registered at more than one
/// input position. *Slave* registrations and corresponding reverse lookup
/// information are consistent.
///
/// \see Definition of \c rosa::deluxe::DeluxeAgent::inv on the class invariant
///
/// \note All member functions validate the class invariant as part of their
/// precondition. Moreover, non-const functions validate the invariant before
/// return as their postcondition.
class DeluxeAgent : public Agent {
/// Checks whether \p this object holds the class invariant.
///
/// \see Invariant of the class \c rosa::deluxe::DeluxeAgent
///
/// \return if \p this object holds the class invariant
bool inv(void) const noexcept;
+ /// The \p DeluxeExecutionPolicy that controls the execution of \t this
+ /// object.
+ std::unique_ptr<DeluxeExecutionPolicy> ExecutionPolicy;
+
public:
/// Template alias for function objects used to process input and generate
/// output for \c rosa::deluxe::DeluxeAgent.
///
/// The output generated by the function is optional as an agent may decide
/// not to output anything at some situation.
///
/// \note The function used for \c D is to be \c noexcept.
///
/// \tparam T type of output
/// \tparam As types of input values
template <typename T, typename... As>
using D = std::function<Optional<T>(std::pair<As, bool>...)>;
/// The type of values produced by \p this object.
///
/// That is the type of values \p this object sends to its *master*.
///
/// \see \c rosa::deluxe::DeluxeAgent::master
const TypeNumber OutputType;
/// Number of inputs processed by \p this object.
const size_t NumberOfInputs;
private:
/// Types of input values produced by *slaves* of \p this object.
///
/// \note The \c rosa::TypeNumber values stored here match the corresponding
/// values in \c rosa::deluxe::DeluxeAgent::InputValues.
///
/// \note The position of a type in the \c std::vector indicates which
/// argument of \p this object's processing function it belongs to. See also
/// \c rosa::deluxe::DeluxeAgent::D.
const std::vector<TypeNumber> InputTypes;
/// Indicates whether any particular input value has been changed since the
/// last trigger received from the system.
///
/// All the flags are reset to \c false upon handling a trigger and then set
/// to \c true by \c rosa::deluxe::DeluxeAgent::saveInput when storing a new
/// input value in \c rosa::deluxe::DeluxeAgent::InputValues.
///
/// \note The position of a flag in the \c std::vector indicates which
/// argument of \p this object's processing function it belongs to. See also
/// \c rosa::deluxe::DeluxeAgent::D.
std::vector<bool> InputChanged;
/// Stores the actual input values.
///
/// \note The types of stored values match the corresponding
/// \c rosa::TypeNumber values in \c rosa::deluxe::DeluxeAgent::InputTypes.
///
/// \note The position of a value in the \c rosa::AbstractTokenizedStorage
/// indicates which argument of \p this object's processing function it is.
/// See also \c rosa::deluxe::DeluxeAgent::D.
const std::unique_ptr<AbstractTokenizedStorage> InputValues;
/// Alias for function objects used as trigger handler for
/// \c rosa::deluxe::DeluxeAgent.
///
/// \note The function used for \c H is to be \c noexcept.
///
/// \see \c rosa::deluxe::DeluxeAgent::FP
using H = std::function<void(void)>;
/// Handles trigger from the system.
///
/// The actual function processing *slave* inputs and generating optional
/// output to *master* is captured in a lambda expression that is in turn
/// wrapped in a \c std::function object. The lambda expression calls the
/// processing function with the actual input data and sends its result -- if
/// any -- to *master* by calling \c rosa::deluxe::DeluxeAgent::sendToMaster.
/// Also, all the flags stored in \c rose::deluxe::DeluxeAgent::InputChanged
/// are reset when the current input values are processed. The function
/// \c rosa::deluxe::DeluxeAgent::handleTrigger needs only to call the
/// function object.
///
/// \see \c rosa::deluxe::DeluxeAgent::triggerHandlerFromProcessingFunction
const H FP;
/// The *master* to send values to.
///
/// \note *Masters* are set dynamically, hence it is possible that a
/// \c rosa::deluxe::DeluxeAgent instance does not have any *master* at a
/// given moment.
Optional<AgentHandle> Master;
/// The *slaves* sending input to \p this object.
///
/// \note The position of a *slave* in the \c std::vector indicates which
/// argument of \p this object's processing function it belongs to. See also
/// \c rosa::deluxe::DeluxeAgent::D.
///
/// \note *Slaves* are set dynamically, hence it is possible that a
/// \c rosa::deluxe::DeluxeAgent instance does have input positions without
/// any *slave* associated to them.
///
/// \note Reverse lookup information is maintained in
/// \c rosa::deluxe::DeluxeAgent::SlaveIds, which is to be kept in sync with
/// the *slaves* stored here.
std::vector<Optional<AgentHandle>> Slaves;
/// Associates \c rosa::id_t values to corresponding indices of registered
/// *slaves*.
///
/// \see \c rosa::deluxe::DeluxeAgent::Slaves
std::map<id_t, size_t> SlaveIds;
/// Tells whether types \p As... match the input types of \p this object.
///
/// \tparam As types to match against values in
/// \c rosa::deluxe::DeluxeAgent::InputTypes
///
/// \return if types \p As... match \c rosa::TypeNumber values stored in
/// \c rosa::deluxe::DeluxeAgent::InputTypes
template <typename... As> bool inputTypesMatch(void) const noexcept;
/// Gives an \c std::tuple containing the current input values and their
/// change flags so that they can be used for the processing function.
///
/// \tparam As types of the input values
/// \tparam S0 indices for accessing input values and their change flags
///
/// \note The only argument provides indices statically as template arguments
/// \p S0..., so its actual value is ignored.
///
/// \return current input values and their change flags prepared for invoking
/// the processing function with them
///
/// \pre The type arguments \p As... match the input types of \p this object
/// and the provided indices \p S0... constitute a proper sequence for
/// accessing input values and their change flags: \code
/// inputTypesMatch<As...>() && sizeof...(As) == sizeof...(S0)
/// \endcode
template <typename... As, size_t... S0>
std::tuple<std::pair<As, bool>...> prepareCurrentInputs(Seq<S0...>) const
noexcept;
/// Invokes a processing function matching the output and input types of
/// \p this object with actual arguments provided in a \c std::tuple.
///
/// \note \p Args providing the actual arguments for \p F is to be created by
/// \c rosa::deluxe::DeluxeAgent::prepareCurrentInputs.
///
/// \tparam T output type of the processing function
/// \tparam As types of inputs for the processing function
/// \tparam S0 indices starting with `0` for extracting actual arguments from
/// \p Args
///
/// \param F the processing function to invoke
/// \param Args the actual arguments to invoke \p F with
///
/// \note The last argument provides indices statically as template arguments
/// \p S0..., so its actual value is ignored.
///
/// \return the result of \p F for actual arguments \p Args
///
/// \pre The provided sequence of indices \p S0... constitutes a proper
/// sequence for extracting all actual arguments for
/// \p F from \p Args: \code
/// sizeof...(As) == sizeof...(S0)
/// \endcode
template <typename T, typename... As, size_t... S0>
static Optional<T> invokeWithTuple(D<T, As...> F,
std::tuple<std::pair<As, bool>...> Args,
Seq<S0...>) noexcept;
/// Wraps a processing function into a trigger handler.
///
/// \see \c rosa::deluxe::DeluxeAgent::FP
///
/// \note The function cannot be const qualified because the lambda
/// expression defined in it needs to capture \p this object by a non-const
/// reference
///
/// \tparam T type of output
/// \tparam As types of input values
///
/// \param F function processing inputs and generating output
///
/// \pre Template arguments \p T and \p As... match the corresponding
/// types \p this object was created with: \code
/// OutputType == TypeNumberOf<T>::Value && inputTypesMatch<As...>()
/// \endcode
template <typename T, typename... As>
H triggerHandlerFromProcessingFunction(D<T, As...> &&F) noexcept;
public:
/// Creates a new instance.
///
/// The constructor instantiates the base-class with functions to handle
/// messages as defined for the *deluxe interface*.
///
/// \todo Enforce F does not potentially throw exception.
///
/// \tparam T type of output of \p F
/// \tparam As types of input values of \p F
///
/// \note Instantiation fails if any of the type arguments \p T and \p As...
/// is not a built-in type.
///
/// \param Kind kind of the new \c rosa::Unit instance
/// \param Id unique identifier of the new \c rosa::Unit instance
/// \param Name name of the new \c rosa::Unit instance
/// \param S \c rosa::MessagingSystem owning the new instance
/// \param F function to process input values and generate output with
///
/// \pre Statically, all of the type arguments \p T and \p As... is a
/// built-in type: \code
/// TypeListSubsetOf<TypeList<T, As...>, BuiltinTypes>::Value
/// \endcode Dynamically, the instance is created as of kind
/// \c rosa::deluxe::atoms::AgentKind: \code
/// Kind == rosa::deluxe::atoms::AgentKind
/// \endcode
template <typename T, typename... As,
typename = std::enable_if_t<
TypeListSubsetOf<TypeList<T, As...>, BuiltinTypes>::Value>>
DeluxeAgent(const AtomValue Kind, const id_t Id, const std::string &Name,
MessagingSystem &S, D<T, As...> &&F) noexcept;
/// Destroys \p this object.
~DeluxeAgent(void) noexcept;
+ /// Returns the current \p DeluxeExecutionPolicy of \p this object.
+ ///
+ /// \note The returned reference is valid only as long as \p
+ /// setExecutionPolicy() is not called and \p this object is alive.
+ ///
+ /// \return the \p DeluxeExecutionPolicy from \p ExecutionPolicy
+ const DeluxeExecutionPolicy &executionPolicy(void) const noexcept;
+
+ /// Sets the current \p DeluxeExecutionPolicy of \this object to \p EP.
+ ///
+ /// \note \p EP is set only if it can handle \p this object.
+ ///
+ /// \param EP the new execution policy for \p this object
+ ///
+ /// \return if \p EP was successfully set for \p this object.
+ bool setExecutionPolicy(std::unique_ptr<DeluxeExecutionPolicy> &&EP) noexcept;
+
/// The *master* of \p this object, if any is registered.
///
/// \see \c rosa::deluxe::DeluxeAgent::registerMaster
///
/// \return the *master* registered for \p this object
Optional<AgentHandle> master(void) const noexcept;
/// Registers a *master* for \p this object.
///
/// The new *master* is registered by overwriting the reference to any
/// already registered *master*. One can clear the registered reference by
/// passing an *empty* \c rosa::Optional object as actual argument.
///
/// \note The role of the referred *master* is validated by checking its
/// *kind*.
///
/// \param _Master the *master* to register
///
/// \pre \p _Master is empty or of kind \c rosa::deluxe::atoms::AgentKind:
/// \code
/// !_Master || unwrapAgent(*_Master).Kind == rosa::deluxe::atoms::AgentKind
/// \endcode
void registerMaster(const Optional<AgentHandle> _Master) noexcept;
/// Tells the type of values consumed from the *slave* at a position.
///
/// That is the type of values \p this object expect to be sent to it by its
/// *slave* registered at position \p Pos.
///
/// \see \c rosa::deluxe::DeluxeAgent::slave
///
/// \param Pos position of *slave*
///
/// \return \c rosa::TypeNumber representing the type of values consumed from
/// the *slave* at position \p Pos
///
/// \pre \p Pos is a valid index of input: \code
/// Pos < NumberOfInputs
/// \endcode
TypeNumber inputType(const size_t Pos) const noexcept;
/// The *slave* of \p this object registered at a position, if any.
///
/// \see \c rosa::deluxe::DeluxeAgent::registerSlave
///
/// \param Pos position of *slave*
///
/// \return the *slave* registered for \p this object at position \p Pos
///
/// \pre \p Pos is a valid index of input: \code
/// Pos < NumberOfInputs
/// \endcode
Optional<AgentHandle> slave(const size_t Pos) const noexcept;
/// Registers a *slave* for \p this object at a position.
///
/// The new *slave* is registered by overwriting the reference to any already
/// registered *slave* at position \p Pos. One can clear the registered
/// reference by passing an *empty* \c rosa::Optional object as actual
/// argument. If \p Slave is already registered for another position, the
/// other position gets cleared.
///
/// \note The role of the referred *slave* is validated by checking its
/// *kind*.
///
/// \note The type of values produced by the referred *slave* is validated by
/// matching its `OutputType` against the corresponding value in
/// \c rosa::deluxe::DeluxeAgent::InputTypes.
///
/// \param Pos position to register \p Slave at
/// \param Slave the *slave* to register
///
/// \pre \p Pos is a valid index of input, \p Slave is empty or of kind
/// \c rosa::deluxe::atoms::AgentKind or \c rosa::deluxe::atoms::SensorKind,
/// and \p Slave -- if not empty -- produces values of types matching the
/// expected input type at position \p Pos:
/// \code
/// Pos < NumberOfInputs &&
/// (!Slave ||
/// (unwrapAgent(*Slave.)Kind == rosa::deluxe::atoms::SensorKind &&
/// static_cast<const DeluxeSensor &>(unwrapAgent(*Slave)).OutputType ==
/// InputTypes[Pos]) ||
/// (unwrapAgent(*Slave).Kind == rosa::deluxe::atoms::AgentKind &&
/// static_cast<const DeluxeAgent &>(unwrapAgent(*Slave)).OutputType ==
/// InputTypes[Pos]))
/// \endcode
void registerSlave(const size_t Pos,
const Optional<AgentHandle> Slave) noexcept;
/// Tells the position of a registered *slave*.
///
/// \param Slave \c rosa::AgentHandle for the *slave* to check
///
/// \return position of \p Slave if it is registered and found,
/// \c rosa::deluxe::DeluxeAgent::NumberOfInputs otherwise.
size_t positionOfSlave(AgentHandle Slave) const noexcept;
private:
/// Sends a value to the *master* of \p this object.
///
/// \p Value is getting sent to \c rosa::deluxe::DeluxeAgent::Master if it
/// contains a valid handle for a \c rosa::deluxe::DeluxeAgent. The function
/// does nothing otherwise.
///
/// \tparam T type of the value to send
///
/// \param Value value to send
///
/// \pre \p T matches \c rosa::deluxe::DeluxeiAgent::OutputType: \code
/// OutputType == TypeNumberOf<T>::Value
/// \endcode
template <typename T> void sendToMaster(const T &Value) noexcept;
/// Generates the next output by processing current input values upon trigger
/// from the system.
///
/// Executes \c rosa::deluxe::DeluxeAgent::FP.
///
/// \note The only argument is a \c rosa::AtomConstant, hence its actual
/// value is ignored.
void handleTrigger(atoms::Trigger) noexcept;
/// Stores a new input value from a *slave*.
///
/// The function stores \p Value in \c rosa::deluxe::DeluxeAgent::InputValues
/// at the position associated to \p Id in
/// \c rosa::deluxe::DeluxeAgent::SlaveIds and also sets the corresponding
/// flag in \c rosa::deluxe::DeluxeAgent::InputChanged.
///
/// \note Utilized by member functions of group \c DeluxeAgentInputHandlers.
///
/// \tparam T type of input to store
///
/// \param Id unique identifier of *slave*
/// \param Value the input value to store
///
/// \pre The *slave* with \p Id is registered and the input from it is
/// expected to be of type \p T: \code
/// SlaveIds.find(Id) != SlaveIds.end() &&
/// InputTypes[SlaveIds.find(Id)->second] == TypeNumberOf<T>::Value
/// \endcode
template <typename T> void saveInput(id_t Id, T Value) noexcept;
/// \defgroup DeluxeAgentInputHandlers Input handlers of rosa::deluxe::DeluxeAgent
///
/// Definition of member functions handling messages from *slaves* with
/// different types of input
///
/// A *master* generally needs to be prepared to deal with values of any
/// built-in type. Each type requires a separate message handler, which are
/// implemented by these functions. The functions instantiate
/// \c rosa::deluxe::DeluxeAgent::saveInput with the proper template argument
/// and pass the content of the message on for processing.
///
/// \note The member functions in this group are defined by \c DAHANDLERDEF.
///
/// \note Keep these definitions in sync with \c rosa::BuiltinTypes.
///
///@{
DAHANDLERDEF(AtomValue)
DAHANDLERDEF(int16_t)
DAHANDLERDEF(int32_t)
DAHANDLERDEF(int64_t)
DAHANDLERDEF(int8_t)
DAHANDLERDEFN(long double, long_double)
DAHANDLERDEFN(std::string, std__string)
DAHANDLERDEF(uint16_t)
DAHANDLERDEF(uint32_t)
DAHANDLERDEF(uint64_t)
DAHANDLERDEF(uint8_t)
DAHANDLERDEF(unit_t)
DAHANDLERDEF(bool)
DAHANDLERDEF(double)
DAHANDLERDEF(float)
/// @}
};
/// Anonymous namespace with implementation for
/// \c rosa::deluxe::DeluxeAgent::inputTypesMatch, consider it private.
namespace {
/// Template \c struct whose specializations provide a recursive implementation
/// for \c rosa::deluxe::DeluxeAgent::inputTypesMatch.
///
/// \note Matching a list of types \p As... against a \c std::vector of
/// \c rosa::TypeNumber values, \c InputTypes, like \code
/// bool match = InputTypesMatchImpl<As...>::f(InputTypes, 0);
/// \endcode
///
/// \tparam As types to match
template <typename... As> struct InputTypesMatchImpl;
/// Template specialization for the general case, when at least one type is to
/// be matched.
///
/// \tparam A first type to match
/// \tparam As further types to match
template <typename A, typename... As> struct InputTypesMatchImpl<A, As...> {
/// Tells whether types \p A, \p As... match \c rosa::TypeNumber values
/// stored in \p InputTypes starting at position \p Pos.
///
/// The function has got a recursive implementation: it matches the first
/// type \p A against \c rosa::TypeNumber at position \p Pos of \p
/// InputTypes, then further types \p As.. are matched recursively starting
/// at position \c (Pos + 1).
///
/// \param InputTypes container of \c rosa::TypeNumber values to match
/// types against
/// \param Pos position in \p InputTypes to start matching at
///
/// \return if types \p A, \p As... match \c rosa::TypeNumber values stored
/// in \p InputTypes starting at position \p Pos
static bool f(const std::vector<TypeNumber> &InputTypes,
size_t Pos) noexcept {
return Pos < InputTypes.size() &&
TypeNumberOf<A>::Value == InputTypes[Pos] &&
InputTypesMatchImpl<As...>::f(InputTypes, Pos + 1);
}
};
/// Template specialization for the terminal case, when no type remains to
/// check.
template <> struct InputTypesMatchImpl<> {
/// Tells whether \p Pos is the number of values stored in \p InputTypes.
///
/// In this terminal case, there is no more types to matchi because all the
/// types are supposed to be already matched successfully. The whole list of
/// types already matched is a complete match if it covers all values in
/// \p InputTypes. That is true if \p Pos points exactly to the end of
/// \p InputTypes.
///
/// \param InputTypes container of \c rosa::TypeNumber values to match
/// types against
/// \param Pos position in \p InputTypes to start matching at
///
/// \return if \p Pos is the number of values stored in \p InputTypes
static bool f(const std::vector<TypeNumber> &InputTypes,
size_t Pos) noexcept {
return Pos == InputTypes.size();
}
};
} // End namespace
template <typename... As>
bool DeluxeAgent::inputTypesMatch(void) const noexcept {
return InputTypesMatchImpl<As...>::f(InputTypes, 0);
}
template <typename... As, size_t... S0>
std::tuple<std::pair<As, bool>...>
DeluxeAgent::prepareCurrentInputs(Seq<S0...>) const noexcept {
// Need to indirectly reference \c rosa::deluxe::DeluxeAgent::inputTypesMatch
// inside \c ASSERT because of the comma in its template argument list.
auto MFP = &DeluxeAgent::inputTypesMatch<As...>;
ASSERT(inv() && (this->*MFP)() && sizeof...(As) == sizeof...(S0));
return std::make_tuple(
std::make_pair(*static_cast<const As *>(InputValues->pointerTo(S0)),
InputChanged[S0])...);
}
template <typename T, typename... As, size_t... S0>
Optional<T> DeluxeAgent::invokeWithTuple(
D<T, As...> F,
std::tuple<std::pair<As, bool>...> Args,
Seq<S0...>) noexcept {
ASSERT(sizeof...(As) == sizeof...(S0));
return F(std::get<S0>(Args)...);
}
template <typename T, typename... As>
DeluxeAgent::H
DeluxeAgent::triggerHandlerFromProcessingFunction(D<T, As...> &&F) noexcept {
// Need to indirectly reference \c rosa::deluxe::DeluxeAgent::inputTypesMatch
// inside \c ASSERT because of the comma in its template argument list.
auto MFP = &DeluxeAgent::inputTypesMatch<As...>;
ASSERT(OutputType == TypeNumberOf<T>::Value && (this->*MFP)());
return [ this, F ]() noexcept {
- using Indices = typename GenSeq<sizeof...(As)>::Type;
- auto Args = prepareCurrentInputs<As...>(Indices());
- std::fill(InputChanged.begin(), InputChanged.end(), false);
- Optional<T> R = invokeWithTuple(F, Args, Indices());
- if (R) {
- sendToMaster(*R);
+ // Call the processing function only if \p ExecutionPolicy allows.
+ if (ExecutionPolicy->doExecute(InputChanged)) {
+ using Indices = typename GenSeq<sizeof...(As)>::Type;
+ auto Args = prepareCurrentInputs<As...>(Indices());
+ std::fill(InputChanged.begin(), InputChanged.end(), false);
+ Optional<T> R = invokeWithTuple(F, Args, Indices());
+ if (R) {
+ sendToMaster(*R);
+ }
}
};
}
template <typename T, typename... As, typename>
DeluxeAgent::DeluxeAgent(const AtomValue Kind, const id_t Id,
const std::string &Name, MessagingSystem &S,
D<T, As...> &&F) noexcept
: Agent(Kind, Id, Name, S, THISMEMBER(handleTrigger),
DAHANDLERREF(AtomValue), DAHANDLERREF(int16_t),
DAHANDLERREF(int32_t), DAHANDLERREF(int64_t), DAHANDLERREF(int8_t),
DAHANDLERREF(long_double), DAHANDLERREF(std__string),
DAHANDLERREF(uint16_t), DAHANDLERREF(uint32_t),
DAHANDLERREF(uint64_t), DAHANDLERREF(uint8_t), DAHANDLERREF(unit_t),
DAHANDLERREF(bool), DAHANDLERREF(double), DAHANDLERREF(float)),
- OutputType(TypeNumberOf<T>::Value),
- NumberOfInputs(sizeof...(As)),
+ ExecutionPolicy(DeluxeExecutionPolicy::decimation(1)),
+ OutputType(TypeNumberOf<T>::Value), NumberOfInputs(sizeof...(As)),
InputTypes({TypeNumberOf<As>::Value...}),
InputChanged(NumberOfInputs, false),
InputValues(new TokenizedStorage<As...>()),
FP(triggerHandlerFromProcessingFunction(std::move(F))),
Slaves(NumberOfInputs) {
ASSERT(Kind == atoms::AgentKind);
LOG_TRACE("DeluxeAgent is created.");
ASSERT(inv());
}
template <typename T>
void DeluxeAgent::sendToMaster(const T &Value) noexcept {
ASSERT(inv() && OutputType == TypeNumberOf<T>::Value);
// There is a handle and the referred *master* is in a valid state.
if (Master && *Master) {
Master->sendMessage(Message::create(atoms::Slave::Value, Id, Value));
}
}
template <typename T> void DeluxeAgent::saveInput(id_t Id, T Value) noexcept {
ASSERT(inv() && SlaveIds.find(Id) != SlaveIds.end() &&
InputTypes[SlaveIds.find(Id)->second] == TypeNumberOf<T>::Value);
size_t Pos = SlaveIds.at(Id);
*static_cast<T *>(InputValues->pointerTo(Pos)) = Value;
InputChanged[Pos] = true;
ASSERT(inv());
}
} // End namespace deluxe
} // End namespace rosa
#undef DAHANDLEREF
#undef DAHANDLEDEF
#undef DAHANDLEDEFN
#undef DAHANDLENAME
#endif // ROSA_DELUXE_DELUXEAGENT_HPP
diff --git a/include/rosa/deluxe/DeluxeContext.hpp b/include/rosa/deluxe/DeluxeContext.hpp
index 29794a1..b6bd20f 100755
--- a/include/rosa/deluxe/DeluxeContext.hpp
+++ b/include/rosa/deluxe/DeluxeContext.hpp
@@ -1,294 +1,331 @@
//===-- rosa/deluxe/DeluxeContext.hpp ---------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/deluxe/DeluxeContext.hpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017-2019
///
/// \brief Public interface for the *deluxe interface* for working with agent
/// systems.
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_DELUXE_DELUXECONTEXT_HPP
#define ROSA_DELUXE_DELUXECONTEXT_HPP
#include "rosa/deluxe/DeluxeSystem.hpp"
#include "rosa/support/types.hpp"
#include <iterator>
#include <memory>
#include <set>
/// Local helper macro to log and return a
/// \c rosa::deluxe::DeluxeContext::ErrorCode value.
///
/// Creates a debug message with the stringified value and returns the value.
///
/// \param Err \c rosa::deluxe::DeluxeContext::ErrorCode value to log and
/// return
#define DCRETERROR(Err) \
{ \
LOG_DEBUG(#Err); \
return Err; \
}
namespace rosa {
namespace deluxe {
/// Defines the *deluxe interface*.
class DeluxeContext {
/// A system owned by \p this object.
///
/// \note The reference is kept in a \c std::shared_ptr because of the member
/// function \c rosa::deluxe::DeluxeContext::getSystem.
std::shared_ptr<DeluxeSystem> System;
/// References to all *sensors* and *agents* created by \p this object.
std::set<AgentHandle> DeluxeUnits;
public:
/// Errors that may be resulted by some of the member functions of the class.
enum struct ErrorCode {
NoError,
TypeMismatch,
NotSensor,
NotAgent,
+ NotUnit,
WrongPosition,
AlreadyHasSlave,
AlreadyHasMaster,
- AlreadyHasValueStream
+ AlreadyHasValueStream,
+ UnsuitableExecutionPolicy
};
/// Returns a new instance of \c rosa::deluxe::DeluxeContext.
///
/// \param Name name of the underlying \c rosa::DeluxeSystem
///
/// \return \c std::unique_ptr for the new instance of
/// \c rosa::deluxe::DeluxeContext with a new, empty \c rosa::DeluxeSystem
static std::unique_ptr<DeluxeContext>
create(const std::string &Name) noexcept;
private:
/// Creates a new instance.
///
/// \note Private constructor restricts instantiation to member functions of
/// the class.
///
/// \param Name name of the underlying \c rosa::MessagingSystem
DeluxeContext(const std::string &Name) noexcept;
public:
/// Destroys \p this object.
~DeluxeContext(void) noexcept;
/// Returns a reference for the underlying \c rosa::MessagingSystem.
///
/// \note One cannot do much with a \c rosa::MessagingSystem currently, this
/// is for future use.
///
/// \return reference for the underlying \c rosa::MessagingSystem.
std::weak_ptr<MessagingSystem> getSystem(void) const noexcept;
/// Creates a new *sensor* in the context of \p this object.
///
/// \tparam T type of data the new *sensor* operates on
///
/// \param Name name of the new *sensor*
/// \param F function for the new *sensor* to generate the next value with
/// during normal operation
///
/// \note \p F is not used during simulation, in which case
/// \c rosa::deluxe::DeluxeContext::registerSensorValues is used to register
/// an alternative simulation data source with
/// \c rosa::deluxe::DeluxeSensor::registerSimulationDataSource. One may
/// safely keep relying on the default value of \p F as long as only
/// simulation of the system is to be done.
///
/// \return \c rosa::AgentHandle for the new *sensor*
template <typename T>
AgentHandle createSensor(const std::string &Name,
DeluxeSensor::D<T> &&F = [](void) {
return T();
}) noexcept;
/// Creates a new *agent* in the context of \p this object.
///
/// \tparam T type of data the new *agent* outputs
/// \tparam As types of inputs the new *agent* takes
///
/// \param Name name of the new *agent*
/// \param F function for the new *agent* to process input values and
/// generate output with
///
/// \return \c rosa::AgentHandle for the new *agent*
template <typename T, typename... As>
AgentHandle createAgent(const std::string &Name,
DeluxeAgent::D<T, As...> &&F) noexcept;
+ /// Returns the current \p DeluxeExecutionPolicy of the referred \p Unit
+ ///
+ /// \note The referred \p Unit is either *sensor* or *agent*.
+ ///
+ /// \note The returned reference is valid only as long as \p
+ /// setExecutionPolicy() is not called with the *unit* referred by \p Unit and
+ /// the *unit* is alive.
+ ///
+ /// \param Unit the *unit* whose execution policy is to be obtained
+ ///
+ /// \return the \p DeluxeExecutionPolicy from \p Unit if \p Unit is valid
+ Optional<const DeluxeExecutionPolicy &>
+ getExecutionPolicy(AgentHandle Unit) const noexcept;
+
+ /// Sets current \p DeluxeExecutionPolicy of the referred \p Unit to \p
+ /// ExecutionPolicy.
+ ///
+ /// \note The referred \p Unit is either *sensor* or *agent*.
+ ///
+ /// \param Unit the *unit* whose execution policy is to be set
+ /// \param ExecutionPolicy the new execution policy for \p Unit
+ ///
+ /// \return how successful setting \p ExecutionPolicy for \p Unit was
+ ///
+ /// \note The function may return the following
+ /// \c rosa::deluxe::DeluxeContext::ErrorCode values:
+ /// `ErrorCode` | Comment
+ /// ----------- | -------
+ /// `NoError` | Success
+ /// `NotUnit` | Referred \p Unit is not valid
+ /// `UnsuitableExecutionPolicy` | \p ExecutionPolicy cannot handle \p Unit
+ ErrorCode setExecutionPolicy(
+ AgentHandle Unit,
+ std::unique_ptr<DeluxeExecutionPolicy> &&ExecutionPolicy) noexcept;
+
/// Connectes a *sensor* to an *agent* in the context of \p this object.
///
/// \param Agent the *agent* to connect to
/// \param Pos the index of slot of \p Agent to connect \p Sensor to
/// \param Sensor the *sensor* to connect
/// \param Description optional textual description of the connection
///
/// \return how successfull connecting \p Sensor to \p Agent at slot index
/// \p Pos was
///
/// \note The function may return the following
/// \c rosa::deluxe::DeluxeContext::ErrorCode values:
/// `ErrorCode` | Comment
/// ----------- | -------
/// `NoError` | Success
/// `NotAgent` | Referred \p Agent is not \c rosa::deluxe::DeluxeAgent
/// `NotSensor` | Referred \p Sensor is not \c rosa::deluxe::DeluxeSensor
/// `WrongPosition` | \p Pos is not a valid input position of \p Agent
/// `TypeMismatch` | Expected input type at position \p Pos of \p Agent is other than the output type of \p Sensor
/// `AlreadyHasSlave` | \p Agent at position \p Pos already has a *slave* registered
/// `AlreadyHasMaster` | \p Sensor already has a *master* registered
ErrorCode connectSensor(AgentHandle Agent, const size_t Pos,
AgentHandle Sensor,
const std::string &Description = "") noexcept;
/// Connectes two *agents* in the context of \p this object.
///
/// \param Master the *agent* to connect to
/// \param Pos the index of slot of \p Master to connect \p Slave to
/// \param Slave the *agent* to connect
/// \param Description optional textual description of the connection
///
/// \return how succesfull connecting \p Slave to \p Master at slot index
/// \p Pos was
///
/// \note The function may return the following
/// \c rosa::deluxe::DeluxeContext::ErrorCode values:
/// `ErrorCode` | Comment
/// ----------- | -------
/// `NoError` | Success
/// `NotAgent` | Referred \p Master or \p Slave is not \c rosa::deluxe::DeluxeAgent
/// `WrongPosition` | \p Pos is not a valid input position of \p Master
/// `TypeMismatch` | Expected input type at position \p Pos of \p Master is other than the output type of \p Slave
/// `AlreadyHasSlave` | \p Master at position \p Pos already has a *slave* registered
/// `AlreadyHasMaster` | \p Slave already has a *master* registered
ErrorCode connectAgents(AgentHandle Master, const size_t Pos,
AgentHandle Slave,
const std::string &Description = "") noexcept;
/// Initializes \c this object and others managed by \p this object for
/// setting up and performing simulation.
///
/// \see \c rosa::deluxe::DeluxeContext::registerSensorValues,
/// \c rosa::deluxe::DeluxeContext::simulate
///
/// Need to clear simulation data sources from all the *sensors*.
void initializeSimulation(void) noexcept;
/// Registers a stream providing values for a *sensor* during simulation.
///
/// \tparam Iterator type of iterator providing values for \p Sensor
/// \tparam T type of values \p Sensor is operating on, always use default!
///
/// \param Sensor the *sensor* to register values for
/// \param Start provides values for \p Sensor
/// \param End denotes the end of stream of values
/// \param Default value to be used when input stream is depleted during
/// simulation
///
/// \return how successful registering \p Source for \p Sensor
///
/// \note The function may return the following
/// \c rosa::deluxe::DeluxeContext::ErrorCode values:
/// `ErrorCode` | Comment
/// ----------- | -------
/// `NoError` | Success
/// `TypeMismatch` | \p Sensor generates values of a type other than \p T
/// `NotSensor` | Referred \p Sensor is not \c rosa::deluxe::DeluxeSensor
/// `AlreadyHasValueStream` | \p Sensor already has simulation data source set
template <typename Iterator, typename T = typename Iterator::value_type>
ErrorCode registerSensorValues(AgentHandle Sensor, Iterator &&Start,
const Iterator &End, T Default = {}) noexcept;
/// Performs the system contained by \p this object.
///
/// The function performs \p NumCycles cycle of simulation. In each cycle,
/// all the *agents* and *sensors* registered in
/// \c rosa::deluxe::DeluxeContext::DeluxeUnits are trigged for execution.
///
/// \param NumCycles number of cycles to perform
///
/// \pre All the *sensors* in the system contained by \p this object generate
/// their output from simulation data sources.
void simulate(const size_t NumCycles) const noexcept;
};
template <typename T>
AgentHandle DeluxeContext::createSensor(const std::string &Name,
DeluxeSensor::D<T> &&F) noexcept {
AgentHandle H = System->createSensor<T>(Name, std::move(F));
DeluxeUnits.emplace(H);
return H;
}
template <typename T, typename... As>
AgentHandle DeluxeContext::createAgent(const std::string &Name,
DeluxeAgent::D<T, As...> &&F) noexcept {
AgentHandle H = System->createAgent(Name, std::move(F));
DeluxeUnits.emplace(H);
return H;
}
template <typename Iterator, typename T>
DeluxeContext::ErrorCode
DeluxeContext::registerSensorValues(AgentHandle Sensor, Iterator &&Start,
const Iterator &End, T Default) noexcept {
// Get the type of values provided by \p Iterator.
STATIC_ASSERT((std::is_same<T, typename Iterator::value_type>::value),
"type mismatch");
// Make sure preconditions are met.
if (!System->isDeluxeSensor(Sensor)) {
DCRETERROR(ErrorCode::NotSensor);
}
auto S = System->getDeluxeSensor(Sensor);
ASSERT(S); // Sanity check.
if (S->OutputType != TypeNumberOf<T>::Value) {
DCRETERROR(ErrorCode::TypeMismatch);
} else if (S->simulationDataSourceIsSet()) {
DCRETERROR(ErrorCode::AlreadyHasValueStream);
}
// Register input stream.
// \note Need to capture parameters by value so having local copies.
S->registerSimulationDataSource(
DeluxeSensor::D<T>([=](void) mutable noexcept {
if (Start != End) {
LOG_TRACE_STREAM << "Reading next value for sensor '" << S->FullName
<< "': " << *Start << '\n';
return *Start++;
} else {
LOG_TRACE_STREAM << "Providing default value for sensor '"
<< S->FullName << "': " << Default << '\n';
return Default;
}
}));
return ErrorCode::NoError;
}
} // End namespace deluxe
} // End namespace rosa
// Undef local macro if not used in the corresponding implementation.
#ifndef ROSA_LIB_DELUXE_DELUXECONTEXT_CPP
#undef DCRETERROR
#endif
#endif // ROSA_DELUXE_DELUXECONTEXT_HPP
diff --git a/include/rosa/deluxe/DeluxeExecutionPolicy.h b/include/rosa/deluxe/DeluxeExecutionPolicy.h
new file mode 100644
index 0000000..33bb063
--- /dev/null
+++ b/include/rosa/deluxe/DeluxeExecutionPolicy.h
@@ -0,0 +1,76 @@
+//===-- rosa/deluxe/DeluxeExecutionPolicy.h ---------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file rosa/deluxe/DeluxeExecutionPolicy.h
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Public interface of *execution policies* in the *deluxe interface*.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef ROSA_DELUXE_DELUXEEXECUTIONPOLICY_H
+#define ROSA_DELUXE_DELUXEEXECUTIONPOLICY_H
+
+#include "rosa/core/AgentHandle.hpp"
+
+#include <memory>
+#include <set>
+#include <vector>
+
+namespace rosa {
+namespace deluxe {
+
+// Forward declaration of DeluxeSystem. Do not include the corresponding header
+// in this file because of cyclic dependency.
+class DeluxeSystem;
+
+/// \todo Extend the interface with query functions about what kind of execution
+/// policy is behind the interface. This can be done in relation to the existing
+/// factory functions; for example, if the actual object is decimation and with
+/// what rate.
+class DeluxeExecutionPolicy {
+protected:
+ DeluxeExecutionPolicy(void) noexcept = default;
+
+private:
+ DeluxeExecutionPolicy(const DeluxeExecutionPolicy &) = delete;
+ DeluxeExecutionPolicy(DeluxeExecutionPolicy &&) = delete;
+ DeluxeExecutionPolicy &operator=(const DeluxeExecutionPolicy &) = delete;
+ DeluxeExecutionPolicy &operator=(DeluxeExecutionPolicy &&) = delete;
+
+public:
+ virtual ~DeluxeExecutionPolicy(void) noexcept = default;
+
+ static std::unique_ptr<DeluxeExecutionPolicy> decimation(const size_t D);
+
+ static std::unique_ptr<DeluxeExecutionPolicy>
+ awaitAll(const std::set<size_t> &S);
+
+ static std::unique_ptr<DeluxeExecutionPolicy>
+ awaitAny(const std::set<size_t> &S);
+
+ virtual bool canHandle(const AgentHandle H, const DeluxeSystem &S) const
+ noexcept = 0;
+
+ virtual bool doExecute(const std::vector<bool> &InputChanged) noexcept = 0;
+
+ virtual std::string dump(void) const noexcept = 0;
+
+protected:
+
+ bool isDeluxeAgent(const AgentHandle H, const DeluxeSystem &S) const noexcept;
+
+ size_t numberOfDeluxeAgentInputs(const AgentHandle H,
+ const DeluxeSystem &S) const noexcept;
+};
+
+} // End namespace deluxe
+} // End namespace rosa
+
+#endif // ROSA_DELUXE_DELUXEEXECUTIONPOLICY_H
diff --git a/include/rosa/deluxe/DeluxeSensor.hpp b/include/rosa/deluxe/DeluxeSensor.hpp
index 46ca0c1..5c6dce8 100755
--- a/include/rosa/deluxe/DeluxeSensor.hpp
+++ b/include/rosa/deluxe/DeluxeSensor.hpp
@@ -1,257 +1,293 @@
//===-- rosa/deluxe/DeluxeSensor.hpp ----------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/deluxe/DeluxeSensor.hpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017-2019
///
/// \brief Specialization of \c rosa::Agent for *sensor* role of the the *deluxe
/// interface*.
///
/// \see \c rosa::deluxe::DeluxeContext
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_DELUXE_DELUXESENSOR_HPP
#define ROSA_DELUXE_DELUXESENSOR_HPP
#include "rosa/core/Agent.hpp"
#include "rosa/deluxe/DeluxeAtoms.hpp"
+#include "rosa/deluxe/DeluxeExecutionPolicy.h"
namespace rosa {
namespace deluxe {
/// Specialization of \c rosa::Agent for *sensor* role of the *deluxe
/// interface*.
///
/// \see \c rosa::deluxe::DeluxeContext
class DeluxeSensor : public Agent {
+private:
+ /// The \p DeluxeExecutionPolicy that controls the execution of \t this
+ /// object.
+ std::unique_ptr<DeluxeExecutionPolicy> ExecutionPolicy;
+
public:
/// Template alias for function objects used as data source for
/// \c rosa::deluxe::DeluxeSensor.
///
/// \note The function used for \c D is to be \c noexcept.
///
/// \tparam T type of data provided by the function
template <typename T> using D = std::function<T(void)>;
/// The type of values produced by \p this object.
///
/// That is the type of values \p this object sends to its *master*.
///
/// \see \c rosa::deluxe::DeluxeSensor::master
const TypeNumber OutputType;
private:
/// Alias for function objects used as trigger handler for
/// \c rosa::deluxe::DeluxeSensor.
///
/// \note The function used for \c H is to be \c noexcept.
///
/// \see \c DeluxeSensorTriggerHandlers
using H = std::function<void(void)>;
/// \defgroup DeluxeSensorTriggerHandlers Trigger handlers of rosa::deluxe::DeluxeSensor
///
/// \brief Trigger handler functions of \c rosa::deluxe::DeluxeSensor
///
/// The actual data source functions are captured in a lambda expression that
/// is in turn wrapped in a \c std::function object. The lambda expression
/// calls the data source function to obtain the next sensory value and sends
/// it to *master* by calling \c rosa::deluxe::DeluxeSensor::sendToMaster. The
/// function \c rosa::deluxe::DeluxeSensor::handleTrigger needs only to call
/// the proper function object.
/// Handles trigger during normal execution.
///
/// \ingroup DeluxeSensorTriggerHandlers
///
/// The function is used during normal execution. During simulation, the
/// simulation environment sets \c rosa::deluxe::DeluxeSensor::SFP, which is
/// used instead of \c rosa::deluxe::DeluxeSensor::FP.
const H FP;
/// Handles trigger during simulation.
///
/// \ingroup DeluxeSensorTriggerHandlers
///
/// The function is empty by default. The simulation environment sets it to be
/// used during simulation.
H SFP;
/// The *master* to send values to.
///
/// \note *Masters* are set dynamically, hence it is possible that a
/// \c rosa::deluxe::DeluxeSensor instance does not have any *master* at a
/// given moment.
Optional<AgentHandle> Master;
/// Wraps a data source function into a trigger handler.
///
/// \see \c DeluxeSensorTriggerHandlers
///
/// \tparam T type of data provided by \p F
///
/// \param F function to generate value with
+ /// \param inSimulation if F is a data source for Simulation
///
/// \pre \p T matches \c rosa::deluxe::DeluxeSensor::OutputType: \code
/// OutputType == TypeNumberOf<T>::Value
/// \endcode
- template <typename T> H triggerHandlerFromDataSource(D<T> &&F) noexcept;
+ template <typename T>
+ H triggerHandlerFromDataSource(D<T> &&F, bool inSimulation) noexcept;
public:
/// Creates a new instance.
///
/// The constructor instantiates the base-class with functions to handle
/// messages as defined for the *deluxe interface*.
///
/// \todo Enforce F does not potentially throw exception.
///
/// \tparam T type of data to operate on
///
/// \param Kind kind of the new \c rosa::Unit instance
/// \param Id unique identifier of the new \c rosa::Unit instance
/// \param Name name of the new \c rosa::Unit instance
/// \param S \c rosa::MessagingSystem owning the new instance
/// \param F function to generate the next value with during normal operation
///
/// \pre Statically, \p T is a built-in type:\code
/// TypeListContains<BuiltinTypes, T>::Value
/// \endcode
/// Dynamically, the instance is created as of kind
/// \c rosa::deluxe::atoms::SensorKind:
/// \code
/// Kind == rosa::deluxe::atoms::SensorKind
/// \endcode
template <typename T, typename = std::enable_if_t<
TypeListContains<BuiltinTypes, T>::Value>>
DeluxeSensor(const AtomValue Kind, const id_t Id, const std::string &Name,
MessagingSystem &S, D<T> &&F) noexcept;
/// Destroys \p this object.
~DeluxeSensor(void) noexcept;
+ /// Returns the current \p DeluxeExecutionPolicy of \p this object.
+ ///
+ /// \note The returned reference is valid only as long as \p
+ /// setExecutionPolicy() is not called and \p this object is alive.
+ ///
+ /// \return the \p DeluxeExecutionPolicy from \p ExecutionPolicy
+ const DeluxeExecutionPolicy &executionPolicy(void) const noexcept;
+
+ /// Sets the current \p DeluxeExecutionPolicy of \this object to \p EP.
+ ///
+ /// \note \p EP is set only if it can handle \p this object.
+ ///
+ /// \param EP the new execution policy for \p this object
+ ///
+ /// \return if \p EP was successfully set for \p this object.
+ bool setExecutionPolicy(std::unique_ptr<DeluxeExecutionPolicy> &&EP) noexcept;
+
/// The *master* of \p this object, if any.
///
/// \see \c rosa::deluxe::DeluxeSensor::registerMaster
///
/// \return the *master* registered for \p this object
Optional<AgentHandle> master(void) const noexcept;
/// Registers a *master* for \p this object.
///
/// The new *master* is registered by overwriting the reference to any
/// already registered *master*. One can clear the registered reference by
/// passing an *empty* \c rosa::Optional object as actual argument.
///
/// \note The role of the referred *master* is validated by checking its
/// *kind*.
///
/// \param _Master the *master* to register
///
/// \pre \p Master is empty or of kind \c rosa::deluxe::atoms::AgentKind:
/// \code
/// !_Master || unwrapAgent(*_Master).Kind == rosa::deluxe::atoms::AgentKind
/// \endcode
void registerMaster(const Optional<AgentHandle> _Master) noexcept;
/// Clears the simulation trigger handler of \p this object.
///
/// The function assigns \c rosa::deluxe::DeluxeSensor::SFP with \c nullptr.
void clearSimulationDataSource(void) noexcept;
/// Tells whether a simulation trigger handler is set for \p this object.
///
/// The function returns whether \c rosa::deluxe::DeluxeSensor::SFP is not
/// \c nullptr.
///
/// \return if a simulation trigger handler is set for \p this object.
bool simulationDataSourceIsSet(void) const noexcept;
/// Registers a simulation data source for \p this object.
///
/// A new simulation trigger handler wrapping \p SF is stored in
/// \c rosa::deluxe::DeluxeSensor::SFP by overwriting any already registered
/// simulation data source.
///
/// \todo Enforce SF does not potentially throw exception.
///
/// \tparam T type of data provided by \p SF
///
/// \param SF function to generate value with
///
/// \pre \p T matches \c rosa::deluxe::DeluxeSensor::OutputType: \code
/// OutputType == TypeNumberOf<T>::Value
/// \endcode
template <typename T> void registerSimulationDataSource(D<T> &&SF) noexcept;
private:
/// Sends a value to the *master* of \p this object.
///
/// \p Value is getting sent to \c rosa::deluxe::DeluxeSensor::Master if it
/// contains a valid handle for a \c rosa::deluxe::DeluxeAgent. The function
/// does nothing otherwise.
///
/// \tparam T type of the value to send
///
/// \param Value value to send
///
/// \pre \p T matches \c rosa::deluxe::DeluxeSensor::OutputType: \code
/// OutputType == TypeNumberOf<T>::Value
/// \endcode
template <typename T> void sendToMaster(const T &Value) noexcept;
/// Generates the next sensory value upon trigger from the system.
///
/// Executes \c rosa::deluxe::DeluxeSensor::FP or
/// \c rosa::deluxe::DeluxeSensor::SFP if set.
///
/// \note The only argument is a \c rosa::AtomConstant, hence its actual
/// value is ignored.
void handleTrigger(atoms::Trigger) noexcept;
};
template <typename T>
-DeluxeSensor::H DeluxeSensor::triggerHandlerFromDataSource(D<T> &&F) noexcept {
+DeluxeSensor::H
+DeluxeSensor::triggerHandlerFromDataSource(D<T> &&F,
+ bool inSimulation) noexcept {
ASSERT(OutputType == TypeNumberOf<T>::Value);
- return [this, F](void) noexcept { sendToMaster(F()); };
+ return [ this, F, inSimulation ](void) noexcept {
+ // Get value and send it to master only if \p ExecutionPolicy allows it.
+ if (ExecutionPolicy->doExecute({})) {
+ sendToMaster(F());
+ } else if (inSimulation) {
+ // But read input value in Simulation anyway as input values are provided
+ // for the highest execution frequency for simulation
+ F();
+ }
+ };
}
template <typename T, typename>
DeluxeSensor::DeluxeSensor(const AtomValue Kind, const id_t Id,
const std::string &Name, MessagingSystem &S,
D<T> &&F) noexcept
: Agent(Kind, Id, Name, S, THISMEMBER(handleTrigger)),
+ ExecutionPolicy(DeluxeExecutionPolicy::decimation(1)),
OutputType(TypeNumberOf<T>::Value),
- FP(triggerHandlerFromDataSource(std::move(F))),
- SFP(nullptr) {
+ FP(triggerHandlerFromDataSource(std::move(F), false)), SFP(nullptr) {
ASSERT(Kind == atoms::SensorKind);
LOG_TRACE("DeluxeSensor is created.");
}
template <typename T>
void DeluxeSensor::registerSimulationDataSource(D<T> &&SF) noexcept {
ASSERT(OutputType == TypeNumberOf<T>::Value);
- SFP = triggerHandlerFromDataSource(std::move(SF));
+ SFP = triggerHandlerFromDataSource(std::move(SF), true);
}
template <typename T>
void DeluxeSensor::sendToMaster(const T &Value) noexcept {
ASSERT(OutputType == TypeNumberOf<T>::Value);
// There is a handle and the referred *master* is in a valid state.
if (Master && *Master) {
Master->sendMessage(Message::create(atoms::Slave::Value, Id, Value));
}
}
} // End namespace deluxe
} // End namespace rosa
#endif // ROSA_DELUXE_DELUXESENSOR_HPP
diff --git a/include/rosa/deluxe/DeluxeSystem.hpp b/include/rosa/deluxe/DeluxeSystem.hpp
index 4388a4e..8ab143f 100755
--- a/include/rosa/deluxe/DeluxeSystem.hpp
+++ b/include/rosa/deluxe/DeluxeSystem.hpp
@@ -1,211 +1,212 @@
//===-- rosa/deluxe/DeluxeSystem.hpp ----------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/deluxe/DeluxeSystem.hpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017-2019
///
/// \brief Specialization of \c rosa::MessagingSystem for the *deluxe
/// interface*.
///
/// \see \c rosa::deluxe::DeluxeContext
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_DELUXE_DELUXESYSTEM_HPP
#define ROSA_DELUXE_DELUXESYSTEM_HPP
#include "rosa/core/MessagingSystem.hpp"
#include "rosa/deluxe/DeluxeAgent.hpp"
#include "rosa/deluxe/DeluxeSensor.hpp"
namespace rosa {
namespace deluxe {
/// Implements and extends the \c rosa::MessagingSystem interface to be
/// used by \c rosa::deluxe::DeluxeContext.
///
/// The class is a specialization of \c rosa::MessagingSystem, where objects
/// of two specialized subtypes of \c rosa::Agent, \c rosa::deluxe::DeluxeSensor
/// and \c rosa::deluxe::DeluxeAgent, constitute a system. The class extends the
/// \c rosa::MessagingSystem interface with features required to implement the
/// *deluxe interface*.
///
/// \see rosa::deluxe::DeluxeContext
class DeluxeSystem : public MessagingSystem {
friend class DeluxeContext;
+ friend class DeluxeExecutionPolicy;
public:
/// Returns an object implementing the \c rosa::deluxe::DeluxeSystem
/// interface.
///
/// \param Name name of the new instance
///
/// \return \c std::unique_ptr for the new instance of
/// \c rosa::DeluxeSystem
static std::unique_ptr<DeluxeSystem>
createSystem(const std::string &Name) noexcept;
protected:
/// Creates a new instance.
///
/// \note Protected constructor restricts instantiation for subclasses.
DeluxeSystem(void) noexcept = default;
public:
/// Creates a \c rosa::deluxe::DeluxeSensor instance owned by \p this object
/// and returns a \p rosa::AgentHandle for it.
///
/// \tparam T type of data the new \c rosa::deluxe::DeluxeSensor operates on
///
/// \param Name name of the new \c rosa::deluxe::DeluxeSensor
/// \param F function to generate the next value with during normal operation
///
/// \return \c rosa::AgentHandle for new \c rosa::deluxe::DeluxeSensor
template <typename T>
AgentHandle createSensor(const std::string &Name,
DeluxeSensor::D<T> &&F) noexcept;
/// Creates a \c rosa::deluxe::DeluxeAgent instance owned by \p this object
/// and returns a \c rosa::AgentHandle for it.
///
/// \tparam T type of data the new \c rosa::deluxe::DeluxeAgent outputs
/// \tparam As types of inputs the new \c rosa::deluxe::DeluxeAgent takes
///
/// \param Name name of the new \c rosa::deluxe::DeluxeAgent
/// \param F function for the new \c rosa::deluxe::DeluxeAgent to process
/// input values and generate output with
///
/// \return \c rosa::AgentHandle for new \c rosa::deluxe::DeluxeAgent
template <typename T, typename... As>
AgentHandle createAgent(const std::string &Name,
DeluxeAgent::D<T, As...> &&F) noexcept;
protected:
/// Tells whether a \c rosa::AgentHandle refers to a
/// \c rosa::deluxe::DeluxeSensor owned by \p this object.
///
/// \param H \c rosa::AgentHandle to check
///
/// \return whether \p H refers to a \c rosa::deluxe::DeluxeSensor owned by
/// \p this object
virtual bool isDeluxeSensor(const AgentHandle &H) const noexcept = 0;
/// Extracts a const qualified \c rosa::deluxe::DeluxeSensor reference from a
/// const qualified \c rosa::AgentHandle if possible.
///
/// The function returns a \c rosa::Optional object containing a const
/// qualified reference to a \c rosa::deluxe::DeluxeSensor object extracted
/// from a const qualified \c rosa::AgentHandle instance if the referred
/// object is of type \c rosa::deluxeDeluxeSensor and owned by \p this object.
/// The returned \c rosa::Optional object is empty otherwise.
///
/// \see rosa::deluxe::DeluxeSystem::isDeluxeSensor
///
/// \param H \c rosa::AgentHandle to extract a \c rosa::deluxe::DeluxeSensor
/// from
///
/// \return const qualified reference to \c rosa::deluxe::DeluxeSensor if
/// \p H refers to an object which is of that type and is owned by \p this
/// object
Optional<const DeluxeSensor &> getDeluxeSensor(const AgentHandle &H) const
noexcept;
/// Extracts a \c rosa::deluxe::DeluxeSensor reference from a
/// \c rosa::AgentHandle if possible.
///
/// The function returns a \c rosa::Optional object containing a reference to
/// a \c rosa::deluxe::DeluxeSensor object extracted from a
/// \c rosa::AgentHandle instance if the referred object is of type
/// \c rosa::deluxeDeluxeSensor and owned by \p this object. The returned
/// \c rosa::Optional object is empty otherwise.
///
/// \see rosa::deluxe::DeluxeSystem::isDeluxeSensor
///
/// \param H \c rosa::AgentHandle to extract a \c rosa::deluxe::DeluxeSensor
/// from
///
/// \return reference to \c rosa::deluxe::DeluxeSensor if \p H refers to an
/// object which is of that type and is owned by \p this object
Optional<DeluxeSensor &> getDeluxeSensor(AgentHandle &H) const noexcept;
/// Tells whether a \c rosa::AgentHandle refers to a
/// \c rosa::deluxe::DeluxeAgent owned by \p this object.
///
/// \param H \c rosa::AgentHandle to check
///
/// \return whether \p H refers to a \c rosa::deluxe::DeluxeAgent owned by
/// \p this object
virtual bool isDeluxeAgent(const AgentHandle &H) const noexcept = 0;
/// Extracts a const qualified \c rosa::deluxe::DeluxeAgent reference from a
/// const qualified \c rosa::AgentHandle if possible.
///
/// The function returns a \c rosa::Optional object containing a const
/// qualified reference to a \c rosa::deluxe::DeluxeAgent object extracted
/// from a const qualified \c rosa::AgentHandle instance if the referred
/// object is of type \c rosa::deluxeDeluxeAgent and owned by \p this object.
/// The returned \c rosa::Optional object is empty otherwise.
///
/// \see rosa::deluxe::DeluxeSystem::isDeluxeAgent
///
/// \param H \c rosa::AgentHandle to extract a \c rosa::deluxe::DeluxeAgent
/// from
///
/// \return const qualified reference to \c rosa::deluxe::DeluxeAgent if \p H
/// refers to an object which is of that type and is owned by \p this object
Optional<const DeluxeAgent &> getDeluxeAgent(const AgentHandle &H) const
noexcept;
/// Extracts a \c rosa::deluxe::DeluxeAgent reference from a
/// \c rosa::AgentHandle if possible.
///
/// The function returns a \c rosa::Optional object containing a reference to
/// a \c rosa::deluxe::DeluxeAgent object extracted from a
/// \c rosa::AgentHandle instance if the referred object is of type
/// \c rosa::deluxeDeluxeAgent and owned by \p this object. The returned
/// \c rosa::Optional object is empty otherwise.
///
/// \see rosa::deluxe::DeluxeSystem::isDeluxeAgent
///
/// \param H \c rosa::AgentHandle to extract a \c rosa::deluxe::DeluxeAgent
/// from
///
/// \return reference to \c rosa::deluxe::DeluxeAgent if \p H refers to an
/// object which is of that type and is owned by \p this object
Optional<DeluxeAgent &> getDeluxeAgent(AgentHandle &H) const noexcept;
};
template <typename T>
AgentHandle DeluxeSystem::createSensor(const std::string &Name,
DeluxeSensor::D<T> &&F) noexcept {
Agent &DS = createUnit<DeluxeSensor, MessagingSystem>(
[&](const id_t Id, MessagingSystem &S) {
return new DeluxeSensor(atoms::SensorKind, Id, Name, S, std::move(F));
});
return {DS};
}
template <typename T, typename... As>
AgentHandle
DeluxeSystem::createAgent(const std::string &Name,
DeluxeAgent::D<T, As...> &&F) noexcept {
Agent &DA = createUnit<DeluxeAgent, DeluxeSystem>(
[&](const id_t Id, DeluxeSystem &S) {
return new DeluxeAgent(atoms::AgentKind, Id, Name, S, std::move(F));
});
return {DA};
}
} // End namespace deluxe
} // End namespace rosa
#endif // ROSA_LIB_DELUXE_DELUXESYSTEM_HPP
diff --git a/lib/deluxe/CMakeLists.txt b/lib/deluxe/CMakeLists.txt
index 41a22b3..ab86f2c 100755
--- a/lib/deluxe/CMakeLists.txt
+++ b/lib/deluxe/CMakeLists.txt
@@ -1,20 +1,30 @@
set(LIB_INCLUDE_DIR ${ROSA_MAIN_INCLUDE_DIR}/rosa/deluxe)
add_library(ROSADeluxe
${LIB_INCLUDE_DIR}/namespace.h
namespace.cpp
${LIB_INCLUDE_DIR}/DeluxeAtoms.hpp
DeluxeAtoms.cpp
+ executionpolicies/Decimation.h
+ executionpolicies/Decimation.cpp
+ executionpolicies/AwaitBase.h
+ executionpolicies/AwaitBase.cpp
+ executionpolicies/AwaitAll.h
+ executionpolicies/AwaitAll.cpp
+ executionpolicies/AwaitAny.h
+ executionpolicies/AwaitAny.cpp
+ ${LIB_INCLUDE_DIR}/DeluxeExecutionPolicy.h
+ DeluxeExecutionPolicy.cpp
${LIB_INCLUDE_DIR}/DeluxeSensor.hpp
DeluxeSensor.cpp
${LIB_INCLUDE_DIR}/DeluxeAgent.hpp
DeluxeAgent.cpp
${LIB_INCLUDE_DIR}/DeluxeSystem.hpp
DeluxeSystem.cpp
DeluxeSystemImpl.hpp
DeluxeSystemImpl.cpp
${LIB_INCLUDE_DIR}/DeluxeContext.hpp
DeluxeContext.cpp
)
ROSA_add_library_dependencies(ROSADeluxe ROSACore)
diff --git a/lib/deluxe/DeluxeAgent.cpp b/lib/deluxe/DeluxeAgent.cpp
index 78d1cd4..278c1af 100755
--- a/lib/deluxe/DeluxeAgent.cpp
+++ b/lib/deluxe/DeluxeAgent.cpp
@@ -1,205 +1,222 @@
//===-- deluxe/DeluxeAgent.cpp ----------------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file deluxe/DeluxeAgent.cpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017-2019
///
/// \brief Implementation of rosa/deluxe/DeluxeAgent.hpp.
///
//===----------------------------------------------------------------------===//
#include "rosa/deluxe/DeluxeAgent.hpp"
-#include "rosa/deluxe/DeluxeSensor.hpp"
+#include "rosa/deluxe/DeluxeSystem.hpp"
#include <algorithm>
namespace rosa {
namespace deluxe {
bool DeluxeAgent::inv(void) const noexcept {
// Check container sizes.
if (!(InputTypes.size() == NumberOfInputs &&
InputChanged.size() == NumberOfInputs &&
InputValues->size() == NumberOfInputs &&
Slaves.size() == NumberOfInputs)) {
return false;
}
// Check *slave* types and validate *slave* registrations and reverse lookup
// information.
std::map<id_t, size_t> RefIds; // Build up a reference of SlaveIds in this.
for (size_t I = 0; I < NumberOfInputs; ++I) {
// First, validate input types at position \c I.
const TypeNumber T = InputTypes[I];
if (InputValues->typeAt(I) != T) {
return false;
}
// Check the registered *slave* at position \c I.
const auto &Slave = Slaves[I];
// If \c Slave is empty, nothing to check.
if (!Slave)
continue;
// \c Slave is not empty here.
// Check the `OutputType` of the registered *slave*.
const auto &A = unwrapAgent(*Slave);
if (!((A.Kind == atoms::SensorKind &&
static_cast<const DeluxeSensor &>(A).OutputType == T) ||
(A.Kind == atoms::AgentKind &&
static_cast<const DeluxeAgent &>(A).OutputType == T))) {
return false;
}
// Validate that the *slave* is not registered more than once.
if (std::any_of(
Slaves.begin() + I + 1, Slaves.end(),
[&Slave](const Optional<AgentHandle> &O) { return O && *Slave == *O; })) {
return false;
}
// Build the content of \c RefIds.
RefIds.emplace(A.Id, I);
}
// Validate *slave* reverse lookup information against our reference.
if (RefIds != SlaveIds) {
return false;
}
// All checks were successful, the invariant is held.
return true;
}
DeluxeAgent::~DeluxeAgent(void) noexcept {
ASSERT(inv());
LOG_TRACE("Destroying DeluxeAgent...");
// Make sure \p this object is not a registered *slave*.
if (Master) {
ASSERT(unwrapAgent(*Master).Kind == atoms::AgentKind); // Sanity check.
DeluxeAgent &M = static_cast<DeluxeAgent&>(unwrapAgent(*Master));
ASSERT(M.positionOfSlave(self()) != M.NumberOfInputs); // Sanity check.
M.registerSlave(M.positionOfSlave(self()), {});
Master = {};
}
// Also, make sure \p this object is no acting *master*.
for (size_t Pos = 0; Pos < NumberOfInputs; ++Pos) {
registerSlave(Pos, {});
}
// Now there is no connection with other entities, safe to destroy.
}
+const DeluxeExecutionPolicy &DeluxeAgent::executionPolicy(void) const noexcept {
+ return *ExecutionPolicy;
+}
+
+bool DeluxeAgent::setExecutionPolicy(
+ std::unique_ptr<DeluxeExecutionPolicy> &&EP) noexcept {
+ // \note The \c rosa::System the \c rosa::Unit is created with is a
+ // \c rosa::DeluxeSystem.
+ const DeluxeSystem &DS = static_cast<DeluxeSystem &>(Unit::system());
+ if (EP && EP->canHandle(self(), DS)) {
+ ExecutionPolicy.swap(EP);
+ return true;
+ } else {
+ return false;
+ }
+}
+
Optional<AgentHandle> DeluxeAgent::master(void) const noexcept {
ASSERT(inv());
return Master;
}
void DeluxeAgent::registerMaster(const Optional<AgentHandle> _Master) noexcept {
ASSERT(inv() && (!_Master || unwrapAgent(*_Master).Kind == atoms::AgentKind));
Master = _Master;
ASSERT(inv());
}
TypeNumber DeluxeAgent::inputType(const size_t Pos) const noexcept {
ASSERT(inv() && Pos < NumberOfInputs);
return InputTypes[Pos];
}
Optional<AgentHandle> DeluxeAgent::slave(const size_t Pos) const noexcept {
ASSERT(inv() && Pos < NumberOfInputs);
return Slaves[Pos];
}
void DeluxeAgent::registerSlave(const size_t Pos,
const Optional<AgentHandle> Slave) noexcept {
ASSERT(inv() && Pos < NumberOfInputs &&
(!Slave ||
(unwrapAgent(*Slave).Kind == atoms::SensorKind &&
static_cast<const DeluxeSensor &>(unwrapAgent(*Slave)).OutputType ==
InputTypes[Pos]) ||
(unwrapAgent(*Slave).Kind == atoms::AgentKind &&
static_cast<const DeluxeAgent &>(unwrapAgent(*Slave)).OutputType ==
InputTypes[Pos])));
// If registering an actual *slave*, not just clearing the slot, make sure
// the same *slave* is not registered to another slot.
if (Slave) {
auto It = SlaveIds.find(unwrapAgent(*Slave).Id);
if (It != SlaveIds.end()) {
Slaves[It->second] = {};//Optional<AgentHandle>();
SlaveIds.erase(It);
}
}
// Obtain the place whose content is to be replaced with \p Slave
auto &OldSlave = Slaves[Pos];
// If there is already a *slave* registered at \p Pos, clear reverse lookup
// information for it, and make sure it no longer has \p this object as
// *master*.
if (OldSlave) {
auto &A = unwrapAgent(*OldSlave);
ASSERT(SlaveIds.find(A.Id) != SlaveIds.end()); // Sanity check.
SlaveIds.erase(A.Id);
if (A.Kind == atoms::AgentKind) {
static_cast<DeluxeAgent &>(A).registerMaster({});
} else {
ASSERT(A.Kind == atoms::SensorKind); // Sanity check.
static_cast<DeluxeSensor &>(A).registerMaster({});
}
}
// Register \p Slave at \p Pos.
OldSlave = Slave;
// If registering an actual *slave*, not just clearing the slot, register
// reverse lookup information for the new *slave*.
if (Slave) {
SlaveIds.emplace(unwrapAgent(*Slave).Id, Pos);
}
ASSERT(inv());
}
size_t DeluxeAgent::positionOfSlave(const AgentHandle Slave) const noexcept {
ASSERT(inv());
bool Found = false;
size_t Pos = 0;
while (!Found && Pos < NumberOfInputs) {
auto &ExistingSlave = Slaves[Pos];
if (ExistingSlave && *ExistingSlave == Slave) {
Found = true;
} else {
++Pos;
}
}
ASSERT(Found || Pos == NumberOfInputs); // Sanity check.
return Pos;
}
void DeluxeAgent::handleTrigger(atoms::Trigger) noexcept {
ASSERT(inv());
FP();
ASSERT(inv());
}
} // End namespace deluxe
} // End namespace rosa
diff --git a/lib/deluxe/DeluxeContext.cpp b/lib/deluxe/DeluxeContext.cpp
index f3fb417..0e363fe 100755
--- a/lib/deluxe/DeluxeContext.cpp
+++ b/lib/deluxe/DeluxeContext.cpp
@@ -1,151 +1,197 @@
//===-- deluxe/DeluxeContext.cpp --------------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file deluxe/DeluxeContext.cpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017
///
/// \brief Implementation for rosa/deluxe/DeluxeContext.hpp.
///
//===----------------------------------------------------------------------===//
#define ROSA_LIB_DELUXE_DELUXECONTEXT_CPP // For including helper macros.
#include "rosa/deluxe/DeluxeContext.hpp"
#include <algorithm>
namespace rosa {
namespace deluxe {
std::unique_ptr<DeluxeContext>
DeluxeContext::create(const std::string &Name) noexcept {
return std::unique_ptr<DeluxeContext>(new DeluxeContext(Name));
}
DeluxeContext::DeluxeContext(const std::string &Name) noexcept
: System(DeluxeSystem::createSystem(Name)) {
LOG_TRACE("DeluxeContext for '" + System->name() + "' is created.");
}
DeluxeContext::~DeluxeContext(void) noexcept {
// \c rosa::deluxe::DeluxeContext::System is not used outside, just clean it.
for(auto U : DeluxeUnits) {
System->destroyAgent(U);
}
// \note \c System will be marked clean by SystemImpl::~SystemImpl.
LOG_TRACE("DeluxeContext for '" + System->name() +
"' prepared for destruction.");
}
+Optional<const DeluxeExecutionPolicy &>
+DeluxeContext::getExecutionPolicy(AgentHandle Unit) const noexcept {
+ if (System->isDeluxeSensor(Unit)) {
+ return {System->getDeluxeSensor(Unit)->executionPolicy()};
+ } else if (System->isDeluxeAgent(Unit)) {
+ return {System->getDeluxeAgent(Unit)->executionPolicy()};
+ } else {
+ return {};
+ }
+}
+
+DeluxeContext::ErrorCode DeluxeContext::setExecutionPolicy(
+ AgentHandle Unit,
+ std::unique_ptr<DeluxeExecutionPolicy> &&ExecutionPolicy) noexcept {
+ // Generate trace log.
+ auto &Trace = LOG_TRACE_STREAM;
+ Trace << "Setting execution policy of " << System->unwrapAgent(Unit).FullName
+ << " to ";
+ if (ExecutionPolicy) {
+ Trace << "'" << ExecutionPolicy->dump() << "'\n";
+ } else {
+ Trace << "[]\n";
+ DCRETERROR(ErrorCode::UnsuitableExecutionPolicy);
+ }
+
+ if (System->isDeluxeSensor(Unit)) {
+ const bool Success = System->getDeluxeSensor(Unit)->setExecutionPolicy(
+ std::move(ExecutionPolicy));
+ if (!Success) {
+ DCRETERROR(ErrorCode::UnsuitableExecutionPolicy);
+ } else {
+ return ErrorCode::NoError;
+ }
+ } else if (System->isDeluxeAgent(Unit)) {
+ const bool Success = System->getDeluxeAgent(Unit)->setExecutionPolicy(
+ std::move(ExecutionPolicy));
+ if (!Success) {
+ DCRETERROR(ErrorCode::UnsuitableExecutionPolicy);
+ } else {
+ return ErrorCode::NoError;
+ }
+ } else {
+ DCRETERROR(ErrorCode::NotUnit);
+ }
+}
+
DeluxeContext::ErrorCode
DeluxeContext::connectSensor(AgentHandle Agent, const size_t Pos,
AgentHandle Sensor,
const std::string &Description) noexcept {
// Generate trace log.
auto &Trace = LOG_TRACE_STREAM;
Trace << "Establishing connection";
if (!Description.empty()) {
Trace << " '" << Description << "'";
}
Trace << " between '" << System->unwrapAgent(Sensor).FullName << "' and '"
<< System->unwrapAgent(Agent).FullName << "'\n";
// Make sure preconditions are met.
if (!System->isDeluxeAgent(Agent)) {
DCRETERROR(ErrorCode::NotAgent);
} else if (!System->isDeluxeSensor(Sensor)) {
DCRETERROR(ErrorCode::NotSensor);
}
auto A = System->getDeluxeAgent(Agent);
auto S = System->getDeluxeSensor(Sensor);
ASSERT(A && S); // Sanity check.
if (Pos >= A->NumberOfInputs) {
DCRETERROR(ErrorCode::WrongPosition);
} else if (A->inputType(Pos) != S->OutputType) {
DCRETERROR(ErrorCode::TypeMismatch);
} else if (A->slave(Pos)) {
DCRETERROR(ErrorCode::AlreadyHasSlave);
} else if (S->master()) {
DCRETERROR(ErrorCode::AlreadyHasMaster);
}
// Do register.
A->registerSlave(Pos, {Sensor});
S->registerMaster({Agent});
return ErrorCode::NoError;
}
DeluxeContext::ErrorCode
DeluxeContext::connectAgents(AgentHandle Master, const size_t Pos,
AgentHandle Slave,
const std::string &Description) noexcept {
// Generate trace log.
auto &Trace = LOG_TRACE_STREAM;
Trace << "Establishing connection";
if (!Description.empty()) {
Trace << " '" << Description << "'";
}
Trace << " between '" << System->unwrapAgent(Slave).FullName << "' and '"
<< System->unwrapAgent(Master).FullName << "'\n";
// Make sure preconditions are met.
if (!(System->isDeluxeAgent(Master) && System->isDeluxeAgent(Slave))) {
DCRETERROR(ErrorCode::NotAgent);
}
auto M = System->getDeluxeAgent(Master);
auto S = System->getDeluxeAgent(Slave);
ASSERT(M && S); // Sanity check.
if (Pos >= M->NumberOfInputs) {
DCRETERROR(ErrorCode::WrongPosition);
} else if (M->inputType(Pos) != S->OutputType) {
DCRETERROR(ErrorCode::TypeMismatch);
} else if (M->slave(Pos)) {
DCRETERROR(ErrorCode::AlreadyHasSlave);
} else if (S->master()) {
DCRETERROR(ErrorCode::AlreadyHasMaster);
}
// Do register.
M->registerSlave(Pos, {Slave});
S->registerMaster({Master});
return ErrorCode::NoError;
}
std::weak_ptr<MessagingSystem> DeluxeContext::getSystem(void) const noexcept {
return std::weak_ptr<MessagingSystem>(System);
}
void DeluxeContext::initializeSimulation(void) noexcept {
// Clear simulation data sources from sensors.
for (auto U : DeluxeUnits) {
if (auto S = System->getDeluxeSensor(U)) {
S->clearSimulationDataSource();
}
}
}
void DeluxeContext::simulate(const size_t NumCycles) const noexcept {
ASSERT(std::all_of(
DeluxeUnits.begin(), DeluxeUnits.end(), [&](const AgentHandle &H) {
return System->isDeluxeAgent(H) ||
System->isDeluxeSensor(H) &&
System->getDeluxeSensor(H)->simulationDataSourceIsSet();
}));
for (size_t I = 1; I <= NumCycles; ++I) {
LOG_TRACE("Simulation cycle: " + std::to_string(I));
for (auto U : DeluxeUnits) {
U.sendMessage(Message::create(atoms::Trigger::Value));
}
}
}
} // End namespace deluxe
} // End namespace rosa
diff --git a/lib/deluxe/DeluxeExecutionPolicy.cpp b/lib/deluxe/DeluxeExecutionPolicy.cpp
new file mode 100644
index 0000000..ee59bcd
--- /dev/null
+++ b/lib/deluxe/DeluxeExecutionPolicy.cpp
@@ -0,0 +1,53 @@
+//===-- deluxe/DeluxeExecutionPolicy.cpp ------------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/DeluxeExecutionPolicy.cpp
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Implementation for rosa/deluxe/DeluxeExecutionPolicy.h.
+///
+//===----------------------------------------------------------------------===//
+
+#include "rosa/deluxe/DeluxeExecutionPolicy.h"
+#include "rosa/deluxe/DeluxeSystem.hpp"
+
+#include "executionpolicies/Decimation.h"
+#include "executionpolicies/AwaitAll.h"
+#include "executionpolicies/AwaitAny.h"
+
+namespace rosa {
+namespace deluxe {
+
+std::unique_ptr<DeluxeExecutionPolicy>
+DeluxeExecutionPolicy::decimation(const size_t D) {
+ return std::unique_ptr<DeluxeExecutionPolicy>(new Decimation(D));
+}
+
+std::unique_ptr<DeluxeExecutionPolicy>
+DeluxeExecutionPolicy::awaitAll(const std::set<size_t> &S) {
+ return std::unique_ptr<DeluxeExecutionPolicy>(new AwaitAll(S));
+}
+
+std::unique_ptr<DeluxeExecutionPolicy>
+DeluxeExecutionPolicy::awaitAny(const std::set<size_t> &S) {
+ return std::unique_ptr<DeluxeExecutionPolicy>(new AwaitAny(S));
+}
+
+bool DeluxeExecutionPolicy::isDeluxeAgent(const AgentHandle H, const DeluxeSystem &S) const noexcept {
+ return S.isDeluxeAgent(H);
+}
+
+size_t DeluxeExecutionPolicy::numberOfDeluxeAgentInputs(
+ const AgentHandle H, const DeluxeSystem &S) const noexcept {
+ auto A = S.getDeluxeAgent(H);
+ return A ? A->NumberOfInputs : 0;
+}
+
+} // End namespace deluxe
+} // End namespace rosa
diff --git a/lib/deluxe/DeluxeSensor.cpp b/lib/deluxe/DeluxeSensor.cpp
index c55ef7f..83d3c37 100755
--- a/lib/deluxe/DeluxeSensor.cpp
+++ b/lib/deluxe/DeluxeSensor.cpp
@@ -1,63 +1,81 @@
//===-- deluxe/DeluxeSensor.cpp ---------------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file deluxe/DeluxeSensor.cpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017-2019
///
/// \brief Implementation of rosa/deluxe/DeluxeSensor.hpp.
///
//===----------------------------------------------------------------------===//
#include "rosa/deluxe/DeluxeSensor.hpp"
-#include "rosa/deluxe/DeluxeAgent.hpp"
+#include "rosa/deluxe/DeluxeSystem.hpp"
namespace rosa {
namespace deluxe {
DeluxeSensor::~DeluxeSensor(void) noexcept {
LOG_TRACE("Destroying DeluxeSensor...");
// Make sure \p this object is not a registered *slave*.
if (Master) {
ASSERT(unwrapAgent(*Master).Kind == atoms::AgentKind); // Sanity check.
DeluxeAgent &M = static_cast<DeluxeAgent&>(unwrapAgent(*Master));
ASSERT(M.positionOfSlave(self()) != M.NumberOfInputs); // Sanity check.
M.registerSlave(M.positionOfSlave(self()), {});
Master = {};
}
}
+const DeluxeExecutionPolicy &DeluxeSensor::executionPolicy(void) const
+ noexcept {
+ return *ExecutionPolicy;
+}
+
+bool DeluxeSensor::setExecutionPolicy(
+ std::unique_ptr<DeluxeExecutionPolicy> &&EP) noexcept {
+ // \note The \c rosa::System the \c rosa::Unit is created with is a
+ // \c rosa::DeluxeSystem.
+ const DeluxeSystem &DS = static_cast<DeluxeSystem &>(Unit::system());
+ if (EP && EP->canHandle(self(), DS)) {
+ ExecutionPolicy.swap(EP);
+ return true;
+ } else {
+ return false;
+ }
+}
+
Optional<AgentHandle> DeluxeSensor::master(void) const noexcept {
return Master;
}
void DeluxeSensor::registerMaster(const Optional<AgentHandle> _Master) noexcept {
ASSERT(!_Master || unwrapAgent(*_Master).Kind == atoms::AgentKind);
Master = _Master;
}
void DeluxeSensor::clearSimulationDataSource(void) noexcept {
SFP = nullptr;
}
bool DeluxeSensor::simulationDataSourceIsSet(void) const noexcept {
return SFP != nullptr;
}
void DeluxeSensor::handleTrigger(atoms::Trigger) noexcept {
// Use \c rosa::deluxe::DeluxeSensor::SFP if set, otherwise
// \c rosa::deluxe::DeluxeSensor::FP.
const H &F = SFP ? SFP : FP;
F();
}
} // End namespace deluxe
} // End namespace rosa
diff --git a/lib/deluxe/executionpolicies/AwaitAll.cpp b/lib/deluxe/executionpolicies/AwaitAll.cpp
new file mode 100644
index 0000000..70740b2
--- /dev/null
+++ b/lib/deluxe/executionpolicies/AwaitAll.cpp
@@ -0,0 +1,34 @@
+//===-- deluxe/executionpolicies/AwaitAll.cpp -------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/executionpolicies/AwaitAll.cpp
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Implementation for deluxe/executionpolicies/AwaitAll.h.
+///
+//===----------------------------------------------------------------------===//
+
+#include "AwaitAll.h"
+
+#include <algorithm>
+
+namespace rosa {
+namespace deluxe {
+
+AwaitAll::AwaitAll(const std::set<size_t> &S)
+ : AwaitBase(S,
+ CheckerType(std::all_of<std::set<size_t>::const_iterator,
+ std::function<bool(const size_t)>>)) {}
+
+std::string AwaitAll::dump(void) const noexcept {
+ return "Await all of " + dumpS();
+}
+
+} // End namespace deluxe
+} // End namespace rosa
diff --git a/lib/deluxe/executionpolicies/AwaitAll.h b/lib/deluxe/executionpolicies/AwaitAll.h
new file mode 100644
index 0000000..28a42fe
--- /dev/null
+++ b/lib/deluxe/executionpolicies/AwaitAll.h
@@ -0,0 +1,35 @@
+//===-- deluxe/executionpolicies/AwaitAll.h ---------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/executionpolicies/AwaitAll.h
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Declaration of the DeluxeExecutionPolicy AwaitAll.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITALL_H
+#define ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITALL_H
+
+#include "AwaitBase.h"
+
+namespace rosa {
+namespace deluxe {
+
+class AwaitAll : public AwaitBase {
+public:
+ AwaitAll(const std::set<size_t> &S);
+
+ std::string dump(void) const noexcept override;
+};
+
+} // End namespace deluxe
+} // End namespace rosa
+
+#endif // ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITALL_H
diff --git a/lib/deluxe/executionpolicies/AwaitAny.cpp b/lib/deluxe/executionpolicies/AwaitAny.cpp
new file mode 100644
index 0000000..109c4cd
--- /dev/null
+++ b/lib/deluxe/executionpolicies/AwaitAny.cpp
@@ -0,0 +1,34 @@
+//===-- deluxe/executionpolicies/AwaitAny.cpp -------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/executionpolicies/AwaitAny.cpp
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Implementation for deluxe/executionpolicies/AwaitAny.h.
+///
+//===----------------------------------------------------------------------===//
+
+#include "AwaitAny.h"
+
+#include <algorithm>
+
+namespace rosa {
+namespace deluxe {
+
+AwaitAny::AwaitAny(const std::set<size_t> &S)
+ : AwaitBase(S,
+ CheckerType(std::any_of<std::set<size_t>::const_iterator,
+ std::function<bool(const size_t)>>)) {}
+
+std::string AwaitAny::dump(void) const noexcept {
+ return "Await any of " + dumpS();
+}
+
+} // End namespace deluxe
+} // End namespace rosa
diff --git a/lib/deluxe/executionpolicies/AwaitAny.h b/lib/deluxe/executionpolicies/AwaitAny.h
new file mode 100644
index 0000000..53fc3b4
--- /dev/null
+++ b/lib/deluxe/executionpolicies/AwaitAny.h
@@ -0,0 +1,35 @@
+//===-- deluxe/executionpolicies/AwaitAny.h ---------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/executionpolicies/AwaitAny.h
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Declaration of the DeluxeExecutionPolicy AwaitAny.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITANY_H
+#define ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITANY_H
+
+#include "AwaitBase.h"
+
+namespace rosa {
+namespace deluxe {
+
+class AwaitAny : public AwaitBase {
+public:
+ AwaitAny(const std::set<size_t> &S);
+
+ std::string dump(void) const noexcept override;
+};
+
+} // End namespace deluxe
+} // End namespace rosa
+
+#endif // ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITANY_H
diff --git a/lib/deluxe/executionpolicies/AwaitBase.cpp b/lib/deluxe/executionpolicies/AwaitBase.cpp
new file mode 100644
index 0000000..65a858e
--- /dev/null
+++ b/lib/deluxe/executionpolicies/AwaitBase.cpp
@@ -0,0 +1,60 @@
+//===-- deluxe/executionpolicies/AwaitBase.cpp ------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/executionpolicies/AwaitBase.cpp
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Implementation for deluxe/executionpolicies/AwaitBase.h.
+///
+//===----------------------------------------------------------------------===//
+
+#include "AwaitBase.h"
+#include "rosa/support/debug.hpp"
+
+#include <algorithm>
+#include <sstream>
+
+namespace rosa {
+namespace deluxe {
+
+AwaitBase::AwaitBase(const std::set<size_t> &S, CheckerType &&Checker)
+ : Set(S), Checker(Checker) {}
+
+bool AwaitBase::canHandle(const AgentHandle H, const DeluxeSystem &S) const
+ noexcept {
+ return isDeluxeAgent(H, S) &&
+ canHandleNumberOfInputs(numberOfDeluxeAgentInputs(H, S));
+}
+
+bool AwaitBase::doExecute(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 deluxe
+} // End namespace rosa
diff --git a/lib/deluxe/executionpolicies/AwaitBase.h b/lib/deluxe/executionpolicies/AwaitBase.h
new file mode 100644
index 0000000..17f3d93
--- /dev/null
+++ b/lib/deluxe/executionpolicies/AwaitBase.h
@@ -0,0 +1,55 @@
+//===-- deluxe/executionpolicies/AwaitBase.h --------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/executionpolicies/AwaitBase.h
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Declaration of the DeluxeExecutionPolicy AwaitBase.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITBASE_H
+#define ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITBASE_H
+
+#include "rosa/deluxe/DeluxeExecutionPolicy.h"
+
+#include <functional>
+
+namespace rosa {
+namespace deluxe {
+
+class AwaitBase : public DeluxeExecutionPolicy {
+protected:
+ const std::set<size_t> Set;
+
+ using CheckerType = std::function<bool(std::set<size_t>::const_iterator,
+ std::set<size_t>::const_iterator,
+ std::function<bool(const size_t)>)>;
+
+ const CheckerType Checker;
+
+ AwaitBase(const std::set<size_t> &S, CheckerType &&Checker);
+
+public:
+ bool canHandle(const AgentHandle H, const DeluxeSystem &S) const
+ noexcept override;
+
+ bool doExecute(const std::vector<bool> &InputChanged) noexcept override;
+
+private:
+ bool canHandleNumberOfInputs(const size_t NumberOfInputs) const noexcept;
+
+protected:
+ std::string dumpS(void) const noexcept;
+};
+
+} // End namespace deluxe
+} // End namespace rosa
+
+#endif // ROSA_LIB_DELUXE_EXECUTIONPOLICIES_AWAITBASE_H
diff --git a/lib/deluxe/executionpolicies/Decimation.cpp b/lib/deluxe/executionpolicies/Decimation.cpp
new file mode 100644
index 0000000..676cd1e
--- /dev/null
+++ b/lib/deluxe/executionpolicies/Decimation.cpp
@@ -0,0 +1,41 @@
+//===-- deluxe/executionpolicies/Decimation.cpp -----------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/executionpolicies/Decimation.cpp
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Implementation for deluxe/executionpolicies/Decimation.h.
+///
+//===----------------------------------------------------------------------===//
+
+#include "Decimation.h"
+
+#include <algorithm>
+
+namespace rosa {
+namespace deluxe {
+
+Decimation::Decimation(const size_t D)
+ : Rate(std::max<size_t>(D, 1)), Cycle(0) {}
+
+bool Decimation::canHandle(const AgentHandle, const DeluxeSystem &) const
+ noexcept {
+ return true;
+}
+
+bool Decimation::doExecute(const std::vector<bool> &) noexcept {
+ return (Cycle++ % Rate) == 0;
+}
+
+std::string Decimation::dump(void) const noexcept {
+ return "Decimation with rate " + std::to_string(Rate);
+}
+
+} // End namespace deluxe
+} // End namespace rosa
diff --git a/lib/deluxe/executionpolicies/Decimation.h b/lib/deluxe/executionpolicies/Decimation.h
new file mode 100644
index 0000000..84db28d
--- /dev/null
+++ b/lib/deluxe/executionpolicies/Decimation.h
@@ -0,0 +1,44 @@
+//===-- deluxe/executionpolicies/Decimation.h -------------------*- C++ -*-===//
+//
+// The RoSA Framework
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file deluxe/executionpolicies/Decimation.h
+///
+/// \author David Juhasz (david.juhasz@tuwien.ac.at)
+///
+/// \date 2019
+///
+/// \brief Declaration of the DeluxeExecutionPolicy Decimation.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef ROSA_LIB_DELUXE_EXECUTIONPOLICIES_DECIMATION_H
+#define ROSA_LIB_DELUXE_EXECUTIONPOLICIES_DECIMATION_H
+
+#include "rosa/deluxe/DeluxeExecutionPolicy.h"
+
+namespace rosa {
+namespace deluxe {
+
+class Decimation : public DeluxeExecutionPolicy {
+ const size_t Rate;
+
+ size_t Cycle;
+
+public:
+ Decimation(const size_t D);
+
+ bool canHandle(const AgentHandle H, const DeluxeSystem &S) const
+ noexcept override;
+
+ bool doExecute(const std::vector<bool> &InputChanged) noexcept override;
+
+ std::string dump(void) const noexcept override;
+};
+
+} // End namespace deluxe
+} // End namespace rosa
+
+#endif // ROSA_LIB_DELUXE_EXECUTIONPOLICIES_DECIMATION_H

File Metadata

Mime Type
text/x-diff
Expires
Mon, Oct 20, 1:20 PM (16 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
199723
Default Alt Text
(92 KB)

Event Timeline