From 191e4abd9c28e7c777b0873f325868d493dd649b Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 1 Feb 2017 14:23:08 +0100 Subject: [PATCH] eap::ui_context class for inter-process exchange introduced --- lib/EAPBase/build/EAPBase.vcxproj | 2 + lib/EAPBase/build/EAPBase.vcxproj.filters | 6 ++ lib/EAPBase/include/UIContext.h | 103 ++++++++++++++++++++++ lib/EAPBase/src/StdAfx.h | 1 + lib/EAPBase/src/UIContext.cpp | 101 +++++++++++++++++++++ 5 files changed, 213 insertions(+) create mode 100644 lib/EAPBase/include/UIContext.h create mode 100644 lib/EAPBase/src/UIContext.cpp diff --git a/lib/EAPBase/build/EAPBase.vcxproj b/lib/EAPBase/build/EAPBase.vcxproj index 9294069..2cfc0a9 100644 --- a/lib/EAPBase/build/EAPBase.vcxproj +++ b/lib/EAPBase/build/EAPBase.vcxproj @@ -85,6 +85,7 @@ + @@ -99,6 +100,7 @@ Create Create + diff --git a/lib/EAPBase/build/EAPBase.vcxproj.filters b/lib/EAPBase/build/EAPBase.vcxproj.filters index baddccc..d9c63ec 100644 --- a/lib/EAPBase/build/EAPBase.vcxproj.filters +++ b/lib/EAPBase/build/EAPBase.vcxproj.filters @@ -32,6 +32,9 @@ Header Files + + Header Files + @@ -52,5 +55,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/lib/EAPBase/include/UIContext.h b/lib/EAPBase/include/UIContext.h new file mode 100644 index 0000000..7c5cd4a --- /dev/null +++ b/lib/EAPBase/include/UIContext.h @@ -0,0 +1,103 @@ +/* + Copyright 2015-2017 Amebis + Copyright 2016-2017 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GÉANTLink is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GÉANTLink. If not, see . +*/ + +namespace eap +{ + class ui_context; +} + +#pragma once + +#include "Config.h" +#include "Credentials.h" +#include "Module.h" + +#include "../../../include/Version.h" + + +namespace eap +{ + /// + /// \defgroup EAPBaseUICtx UI Context + /// Back and front-end inter-process data exchange + /// + /// @{ + + /// + /// UI context + /// + class ui_context : public config + { + public: + /// + /// Constructs context + /// + /// \param[in] mod EAP module to use for global services + /// \param[in] cfg Connection configuration + /// \param[in] cred Connection credentials + /// + ui_context(_In_ module &mod, _In_ config_connection &cfg, _In_ credentials_connection &cred); + + /// + /// Copies context + /// + /// \param[in] other Credentials to copy from + /// + ui_context(_In_ const ui_context &other); + + /// + /// Moves context + /// + /// \param[in] other Credentials to move from + /// + ui_context(_Inout_ ui_context &&other); + + /// + /// Copies context + /// + /// \param[in] other Credentials to copy from + /// + /// \returns Reference to this object + /// + ui_context& operator=(_In_ const ui_context &other); + + /// + /// Moves context + /// + /// \param[in] other Configuration to move from + /// + /// \returns Reference to this object + /// + ui_context& operator=(_Inout_ ui_context &&other); + + /// \name BLOB management + /// @{ + virtual void operator<<(_Inout_ cursor_out &cursor) const; + virtual size_t get_pk_size() const; + virtual void operator>>(_Inout_ cursor_in &cursor); + /// @} + + public: + config_connection &m_cfg; ///< Connection configuration + credentials_connection &m_cred; ///< Connection credentials + }; + + /// @} +} diff --git a/lib/EAPBase/src/StdAfx.h b/lib/EAPBase/src/StdAfx.h index ae21bec..ded417e 100644 --- a/lib/EAPBase/src/StdAfx.h +++ b/lib/EAPBase/src/StdAfx.h @@ -24,6 +24,7 @@ #include "../include/Credentials.h" #include "../include/Method.h" #include "../include/Module.h" +#include "../include/UIContext.h" #include "../include/EAP.h" #include "../include/EAPXML.h" diff --git a/lib/EAPBase/src/UIContext.cpp b/lib/EAPBase/src/UIContext.cpp new file mode 100644 index 0000000..ecb0658 --- /dev/null +++ b/lib/EAPBase/src/UIContext.cpp @@ -0,0 +1,101 @@ +/* + Copyright 2015-2016 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GÉANTLink is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GÉANTLink. If not, see . +*/ + +#include "StdAfx.h" + +using namespace std; +using namespace winstd; + + +////////////////////////////////////////////////////////////////////// +// eap::ui_context +////////////////////////////////////////////////////////////////////// + +eap::ui_context::ui_context(_In_ module &mod, _In_ config_connection &cfg, _In_ credentials_connection &cred) : + config(mod), + m_cfg(cfg), + m_cred(cred) +{ +} + + +eap::ui_context::ui_context(_In_ const ui_context &other) : + m_cfg (other.m_cfg ), + m_cred(other.m_cred), + config(other ) +{ +} + + +eap::ui_context::ui_context(_Inout_ ui_context &&other) : + m_cfg ( other.m_cfg ), + m_cred( other.m_cred ), + config(std::move(other )) +{ +} + + +eap::ui_context& eap::ui_context::operator=(_In_ const ui_context &other) +{ + if (this != &other) { + assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Copy context within same configuration only! + assert(std::addressof(m_cred) == std::addressof(other.m_cred)); // Copy context within same credentials only! + (config&)*this = other; + } + + return *this; +} + + +eap::ui_context& eap::ui_context::operator=(_Inout_ ui_context &&other) +{ + if (this != &other) { + assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move context within same configuration only! + assert(std::addressof(m_cred) == std::addressof(other.m_cred)); // Move context within same credentials only! + (config&)*this = std::move(other); + } + + return *this; +} + + +void eap::ui_context::operator<<(_Inout_ cursor_out &cursor) const +{ + config::operator<<(cursor); + cursor << m_cfg ; + cursor << m_cred; +} + + +size_t eap::ui_context::get_pk_size() const +{ + return + config::get_pk_size() + + pksizeof(m_cfg ) + + pksizeof(m_cred); +} + + +void eap::ui_context::operator>>(_Inout_ cursor_in &cursor) +{ + config::operator>>(cursor); + cursor >> m_cfg ; + cursor >> m_cred; +}