/usr/include/qgis/qgsoptional.h is in libqgis-dev 2.18.17+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | /***************************************************************************
qgsoptional.h - QgsOptional
---------------------
begin : 7.9.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSOPTIONAL_H
#define QGSOPTIONAL_H
/**
* \ingroup core
*
* \brief QgsOptional is a container for other classes and adds an additional enabled/disabled flag.
*
* Often it is used for configuration options which can be enabled or disabled but also have
* more internal configuration information that should not be lost when disabling and re-enabling.
*
* @note Added in QGIS 2.18
* @note For python you need to use implementations for specific template classes
*/
template<class T>
class CORE_EXPORT QgsOptional
{
public:
/**
* A QgsOptional is disabled by default if default constructed.
*/
QgsOptional()
: mEnabled( false )
{
}
/**
* A QgsOptional is enabled by default if constructed with payload.
*/
QgsOptional( const T& data )
: mEnabled( true )
, mData( data )
{
}
/**
* A QgsOptional constructed with enabled status and data
*/
QgsOptional( const T& data, bool enabled )
: mEnabled( enabled )
, mData( data )
{
}
/**
* Compare this QgsOptional to another one.
*
* This will compare the enabled flag and call the == operator
* of the contained class.
*
* @note Added in QGIS 2.18
*/
bool operator== ( const QgsOptional<T>& other ) const
{
return mEnabled == other.mEnabled && mData == other.mData;
}
/**
* Boolean operator. Will return true if this optional is enabled.
*/
operator bool() const
{
return mEnabled;
}
/**
* Check if this optional is enabled
*
* @note Added in QGIS 2.18
*/
bool enabled() const
{
return mEnabled;
}
/**
* Set if this optional is enabled
*
* @note Added in QGIS 2.18
*/
void setEnabled( bool enabled )
{
mEnabled = enabled;
}
/**
* Access the payload data
*
* @note Added in QGIS 2.18
*/
const T* operator->() const
{
return &mData;
}
/**
* Access the payload data
*
* @note Added in QGIS 2.18
*/
T data() const
{
return mData;
}
/**
* Set the payload data
*
* @note Added in QGIS 2.18
*/
void setData( const T& data )
{
mData = data;
}
private:
bool mEnabled;
T mData;
};
#endif // QGSOPTIONAL_H
|