Page MenuHomec4science

lm_object.hh
No OneTemporary

File Metadata

Created
Wed, Oct 2, 11:02

lm_object.hh

#ifndef __LIBMULTISCALE_LM_OBJECT_HH__
#define __LIBMULTISCALE_LM_OBJECT_HH__
/* -------------------------------------------------------------------------- */
#include "auto_arguments.hh"
#include "lm_common.hh"
#include "lm_globals.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
struct CommGroup;
/* -------------------------------------------------------------------------- */
using dispatch = AutoDispatch::dispatch;
template <typename T, typename... Ts>
using enable_if_type = AutoDispatch::enable_if_type<T, Ts...>;
/* -------------------------------------------------------------------------- */
/**
* Class LMObject
* objects having an ID
*/
class LMObject : public AutoDispatch::Argument {
public:
LMObject(const LMID &id) : id(id), comm_group(nullptr){};
virtual const LMID &getID() const { return id; };
virtual void setID(const LMID &id) { this->id = id; };
//! set the communication group
virtual void setCommGroup(CommGroup &group) { comm_group = &group; };
//! return the communication group
CommGroup &getCommGroup() const {
if (comm_group == nullptr)
LM_FATAL("invalid group");
return *comm_group;
};
virtual void acquireContext(const LMObject &obj) {
this->setCommGroup(obj.getCommGroup());
this->setRelease(std::max(obj.release, release));
}
//! return actual release
UInt getRelease() const { return release; };
//! return actual release
void setRelease(UInt r) { release = r; };
//! increment the release
void incRelease() { ++release; };
private:
//! general id
LMID id;
//! general release number
UInt release = 0;
protected:
CommGroup *comm_group;
};
__END_LIBMULTISCALE__
#endif // __LIBMULTISCALE_LM_OBJECT_HH__

Event Timeline