/* * SharedData.hh * * Created on: 5 апр. 2021 г. * Author: titov */ #ifndef UMLIBRARY_SYSTEMIC_SHAREDDATA_HH_ #define UMLIBRARY_SYSTEMIC_SHAREDDATA_HH_ #include "../peripheral/ProtectedMemory.hh" #include namespace systemic { struct SharedData { std::pair get() const; // exclusive ownership void lock(); // blocking bool try_lock(); void unlock(); // shared ownership void lock_shared(); // blocking bool try_lock_shared(); void unlock_shared(); SharedData(); SharedData( std::pair data ); SharedData( peripheral::protected_char * buff, std::size_t size ); SharedData( const SharedData & ); SharedData & operator=( SharedData data ); ~SharedData(); SharedData part( peripheral::protected_char * buff, std::size_t size ); private: std::pair data; }; struct ProtectedDataView { std::pair get() const; // shared ownership void lock_shared(); // blocking bool try_lock_shared(); void unlock_shared(); ProtectedDataView(); ProtectedDataView( std::pair data ); ProtectedDataView( const peripheral::protected_char * buff, std::size_t size ); ProtectedDataView( const ProtectedDataView & ); ProtectedDataView & operator=( ProtectedDataView data ); ~ProtectedDataView(); ProtectedDataView part( const peripheral::protected_char * buff, std::size_t size ); private: std::pair data; }; } #endif /* UMLIBRARY_SYSTEMIC_SHAREDDATA_HH_ */