24 template<user_type UserType,
typename TAG = std::
nullptr_t>
46 operator UserType&() {
return get()->accessData(0, 0); }
50 operator const UserType&()
const {
return get()->accessData(0, 0); }
56 template<
typename OTHER_TAG>
64 template<
typename OTHER_TAG>
90 template<
typename COOKED_TYPE>
98 template<
typename COOKED_TYPE>
137 operator std::string&();
146 template<
typename COOKED_TYPE>
154 template<
typename COOKED_TYPE>
196 operator const bool&()
const {
return get()->accessData(0, 0); }
202 operator bool&() {
return get()->accessData(0, 0); }
208 template<user_type UserType,
typename TAG>
211 static_assert(!std::is_same<UserType, Void>::value,
212 "You cannot create ScalarRegisterAccessor<ChimeraTK::Void>! Use VoidRegisterAccessor instead.");
217 template<user_type UserType,
typename TAG>
219 static_assert(!std::is_same<UserType, Void>::value,
220 "You cannot create ScalarRegisterAccessor<ChimeraTK::Void>! Use VoidRegisterAccessor instead.");
225 template<user_type UserType,
typename TAG>
226 template<
typename OTHER_TAG>
234 template<user_type UserType,
typename TAG>
236 get()->accessData(0, 0) = rightHandSide;
242 template<user_type UserType,
typename TAG>
244 UserType v = get()->accessData(0, 0);
251 template<user_type UserType,
typename TAG>
253 UserType v = get()->accessData(0, 0);
260 template<user_type UserType,
typename TAG>
261 template<
typename COOKED_TYPE>
263 return get()->template getAsCooked<COOKED_TYPE>(0, 0);
268 template<user_type UserType,
typename TAG>
269 template<
typename COOKED_TYPE>
271 return get()->template setAsCooked<COOKED_TYPE>(0, 0, value);
276 template<user_type UserType,
typename TAG>
279 if(get()->accessData(0, 0) != newValue || this->getVersionNumber() ==
VersionNumber(
nullptr) ||
280 this->dataValidity() != validity) {
285 this->setDataValidity(validity);
286 this->
write(versionNumber);
292 template<user_type UserType,
typename TAG>
295 this->
write(versionNumber);
300 template<user_type UserType,
typename TAG>
303 return get()->accessData(0, 0);
316 return boost::static_pointer_cast<NDRegisterAccessor<std::string>>(_impl)->accessData(0, 0);
322 std::string rightHandSide) {
323 boost::static_pointer_cast<NDRegisterAccessor<std::string>>(_impl)->accessData(0, 0) = std::move(rightHandSide);
329 template<
typename COOKED_TYPE>
331 return get()->template getAsCooked<COOKED_TYPE>(0, 0);
336 template<
typename COOKED_TYPE>
338 return get()->template setAsCooked<COOKED_TYPE>(0, 0, value);
345 if(get()->accessData(0, 0) != newValue || this->getVersionNumber() ==
VersionNumber(
nullptr) ||
346 this->dataValidity() != validity) {
348 if(versionNumber ==
VersionNumber{
nullptr}) versionNumber = {};
349 this->setDataValidity(validity);
350 this->
write(versionNumber);
359 this->
write(versionNumber);
366 return get()->accessData(0, 0);
Wrapper Class to avoid vector<bool> problems.
Base class for the register accessor abstractors (ScalarRegisterAccessor, OneDRegisterAccessor and Tw...
NDRegisterAccessor< UserType > * get()
N-dimensional register accessor.
ScalarRegisterAccessor()=default
Accessor class to read and write scalar registers transparently by using the accessor object like a v...
UserType readAndGet()
Convenience function to read and return a value of UserType.
UserType operator++(int)
Post-increment operator for the first element.
void writeIfDifferent(UserType newValue, VersionNumber versionNumber=VersionNumber{nullptr}, DataValidity validity=DataValidity::ok)
Convenience function to set and write new value if it differes from the current value.
ScalarRegisterAccessor & operator--()
Pre-decrement operator for the first element.
ScalarRegisterAccessor & operator=(UserType rightHandSide)
Assignment operator, assigns the first element.
ScalarRegisterAccessor(boost::shared_ptr< NDRegisterAccessor< UserType > > impl)
Create instance from pointer to implementation.
COOKED_TYPE getAsCooked()
Get the cooked values in case the accessor is a raw accessor (which does not do data conversion).
ScalarRegisterAccessor & operator++()
Pre-increment operator for the first element.
void setAsCooked(COOKED_TYPE value)
Set the cooked values in case the accessor is a raw accessor (which does not do data conversion).
ScalarRegisterAccessor()
Placeholder constructor, to allow late initialisation of the accessor, e.g.
UserType operator--(int)
Post-decrement operator for the first element.
void setAndWrite(UserType newValue, VersionNumber versionNumber={})
Convenience function to set and write new value.
DataValidity dataValidity() const
Return current validity of the data.
Group multiple data accessors to efficiently trigger data transfers on the whole group.
Class for generating and holding version numbers without exposing a numeric representation.
DataValidity
The current state of the data.