wxObjectWithData helper template introduced

This commit is contained in:
Simon Rozman 2016-08-27 11:13:55 +02:00
parent d604e81604
commit 6c94ff59be
4 changed files with 60 additions and 0 deletions

View File

@ -39,6 +39,7 @@
<ClInclude Include="..\include\wxex\comutils.h" />
<ClInclude Include="..\include\wxex\crypto.h" />
<ClInclude Include="..\include\wxex\hex.h" />
<ClInclude Include="..\include\wxex\object.h" />
<ClInclude Include="..\include\wxex\persist\auimanager.h" />
<ClInclude Include="..\include\wxex\persist\dialog.h" />
<ClInclude Include="..\include\wxex\url.h" />

View File

@ -81,6 +81,9 @@
<ClInclude Include="..\include\wxex\url.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\wxex\object.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\locale\wxExtend.pot">

55
include/wxex/object.h Normal file
View File

@ -0,0 +1,55 @@
/*
Copyright 2015-2016 Amebis
This file is part of wxExtend.
wxExtend 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.
wxExtend 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 wxExtend. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common.h"
#include <wx/object.h>
///
/// Helper template for event user data
///
template <class T>
class wxObjectWithData : public wxObject
{
public:
///
/// Default constructor
///
inline wxObjectWithData() {}
///
/// Construct object with data
///
/// \param[in] data Data to initialize object with
///
inline wxObjectWithData(const T &data) : m_data(data) {}
///
/// Construct object with data
///
/// \param[in] data Data to move to object
///
inline wxObjectWithData(T &&data) : m_data(std::move(data)) {}
public:
T m_data; ///< Data
};

View File

@ -27,6 +27,7 @@
#include "../include/wxex/comutils.h"
#include "../include/wxex/crypto.h"
#include "../include/wxex/hex.h"
#include "../include/wxex/object.h"
#include "../include/wxex/url.h"
#include "../include/wxex/valhex.h"
#include "../include/wxex/xml.h"