46 #ifndef MUELU_VARIABLECONTAINER_HPP
47 #define MUELU_VARIABLECONTAINER_HPP
53 #include <Xpetra_Matrix.hpp>
54 #include <Xpetra_Operator.hpp>
79 virtual const std::type_info&
type()
const = 0;
80 virtual std::string
typeName()
const = 0;
87 const std::type_info&
type()
const {
return typeid(T); }
99 "Error, cast to type Data<" << typeName <<
"> failed since the content is NULL");
102 "Error, cast to type Data<" << typeName <<
"> failed since the actual underlying type is "
111 "Error, cast to type Data<" << typeName <<
"> failed but should not have and the actual underlying type is "
112 "\'" <<
data_->
typeName() <<
"! The problem might be related to incompatible RTTI systems in static and shared libraries!");
175 return std::string(
"");
190 request_container::iterator it =
requests_.find(reqFactory);
200 request_container::iterator it =
requests_.find(reqFactory);
202 "cannot call Release if factory has not been requested before by factory " << reqFactory);
203 if (--(it->second) == 0)
210 request_container::const_iterator it =
requests_.find(reqFactory);
211 return (it !=
requests_.end()) ? it->second : 0;
245 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
247 typedef Xpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node>
Operator;
248 typedef Xpetra::Matrix <Scalar,LocalOrdinal,GlobalOrdinal,Node>
Matrix;
265 "\'" <<
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!");
291 "\'" <<
datah_->
typeName() <<
"! The problem might be related to incompatible RTTI systems in static and shared libraries!");
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.
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
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > Matrix
void Request(const FactoryBase *reqFactory)
Request data.
const std::type_info & type() const
bool available_
is data available?
std::map< const FactoryBase *, int > request_container
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()
Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > Operator
Base class for MueLu classes.
virtual const std::type_info & type() const =0
DataBase * data_
the data itself
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)