10 #ifndef MUELU_VARIABLECONTAINER_HPP
11 #define MUELU_VARIABLECONTAINER_HPP
43 virtual const std::type_info&
type()
const = 0;
44 virtual std::string
typeName()
const = 0;
52 const std::type_info&
type()
const {
return typeid(T); }
64 "Error, cast to type Data<" << typeName <<
"> failed since the content is NULL");
67 "Error, cast to type Data<" << typeName <<
"> failed since the actual underlying type is "
77 "Error, cast to type Data<" << typeName <<
"> failed but should not have and the actual underlying type is "
79 <<
data_->
typeName() <<
"! The problem might be related to incompatible RTTI systems in static and shared libraries!");
88 if ((data_ == NULL) || (data_->
type() !=
typeid(T)))
139 template <
typename T>
150 template <
typename T>
157 template <
typename T>
164 template <
typename T>
171 return std::string(
"");
186 request_container::iterator it =
requests_.find(reqFactory);
196 request_container::iterator it =
requests_.find(reqFactory);
198 "MueLu::VariableContainer::Release(): "
199 "cannot call Release if factory has not been requested before by factory "
201 if (--(it->second) == 0)
208 request_container::const_iterator it =
requests_.find(reqFactory);
209 return (it !=
requests_.end()) ? it->second : 0;
242 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
263 <<
data_->
typeName() <<
"! The problem might be related to incompatible RTTI systems in static and shared libraries!");
281 <<
data_->
typeName() <<
"! The problem might be related to incompatible RTTI systems in static and shared libraries!");
292 <<
datah_->
typeName() <<
"! The problem might be related to incompatible RTTI systems in static and shared libraries!");
std::map< const FactoryBase *, int > request_container
bool IsAvailable() const
Returns true if data is available, i.e.
const request_container & Requests() const
virtual std::string typeName() const =0
VariableContainer()
Default constructor.
virtual ~DataBase()=default
int NumRequests(const FactoryBase *reqFactory) const
Return the number of times the data has been requested by a specific factory.
void AddKeepFlag(KeepType keep=UserData)
Adds a keep flag to the flag combination.
static T & get(DataBase *data_, DataBase *&)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
KeepType GetKeepFlag() const
Returns the keep flag combination.
void SetData(const T &entry)
Store data in container class and set the "Available" status true.
User data are always kept. This flag is set automatically when Level::Set("data", data) is used...
bool IsRequested() const
Returns true, if data is requested by at least one factory.
void RemoveKeepFlag(KeepType keep=UserData)
Removes a keep flag to the flag combination.
int count_
number of requests by all factories
void Request(const FactoryBase *reqFactory)
Request data.
static bool check(DataBase *data_, DataBase *&)
const std::type_info & type() const
bool available_
is data available?
Base class for factories (e.g., R, P, and A_coarse).
request_container requests_
requesting factories
bool IsKept(KeepType keep) const
Returns true if at least one keep flag is set.
const T & GetData() const
void Release(const FactoryBase *reqFactory)
Release data.
std::string GetTypeName()
Base class for MueLu classes.
virtual const std::type_info & type() const =0
DataBase * data_
the data itself
Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > Operator
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > Matrix
Exception throws to report errors in the internal logical of the program.
Class that stores all relevant data for a variable.
int NumAllRequests() const
Returns the number of times the data has been requested.
bool IsRequested(const FactoryBase *reqFactory) const
Returns true, if data is requested by reqFactory.
std::string typeName() const
static std::string name()
std::string typeName(const T &t)