blob: 500a6b49e51d086ce3fe53d440c9f762d5baa7dd [file] [log] [blame]
<!-- Copyright 2008 Lubomir Bourdev and Hailin Jin
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
-->
<!--
Copyright 2005-2007 Adobe Systems Incorporated
Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
or a copy at http://stlab.adobe.com/licenses.html)
Some files are held under additional license.
Please see "http://stlab.adobe.com/licenses.html" for more information.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<TITLE>Generic Image Library: variant Class Template Reference</TITLE>
<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/>
<LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr>
<td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'>
<div class="qindex"><a class="qindex" href="index.html">Modules</a>
| <a class="qindex" href="classes.html">Alphabetical List</a>
| <a class="qindex" href="annotated.html">Class List</a>
| <a class="qindex" href="dirs.html">Directories</a>
| <a class="qindex" href="files.html">File List</a>
| <a class="qindex" href="../index.html">GIL Home Page</a>
</div>
<!-- End Header -->
<!-- Generated by Doxygen 1.5.6 -->
<div class="navpath"><a class="el" href="namespaceboost.html">boost</a>::<b>gil</b>::<a class="el" href="g_i_l_0062.html">variant</a>
</div>
<div class="contents">
<h1>variant Class Template Reference<br>
<small>
[<a class="el" href="group___variant.html">Variant</a>]</small>
</h1><!-- doxytag: class="boost::gil::variant" --><code>#include &lt;<a class="el" href="g_i_l_0643.html">variant.hpp</a>&gt;</code>
<p>
<p>
<a href="g_i_l_0061.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;typename Types&gt;<br>
class boost::gil::variant&lt; Types &gt;</h3>
Represents a concrete instance of a run-time specified type from a set of types<p>
A concept is typically modeled by a collection of different types. They may be instantiations of a templated type with different template parameters or even completely unrelated types.
<p>
We call the type with which the concept is instantiated in a given place in the code "the concrete type". The concrete type must be chosen at compile time, which sometimes is a severe limitation. Consider, for example, having an <a class="el" href="g_i_l_0038.html" title="container interface over image view. Models ImageConcept, PixelBasedConcept">image</a> concept modeled by an <a class="el" href="g_i_l_0038.html" title="container interface over image view. Models ImageConcept, PixelBasedConcept">image</a> class templated over the color space. It would be difficult to write a function that reads an <a class="el" href="g_i_l_0038.html" title="container interface over image view. Models ImageConcept, PixelBasedConcept">image</a> from file preserving its native color space, since the type of the return value is only available at run time. It would be difficult to store images of different color spaces in the same container or apply operations on them uniformly.<p>
The <a class="el" href="g_i_l_0062.html" title="Represents a concrete instance of a run-time specified type from a set of typesA...">variant</a> class addresses this deficiency. It allows for run-time instantiation of a class from a given set of allowed classes specified at compile time. For example, the set of allowed classes may include 8-bit and 16-bit RGB and CMYK images. Such a <a class="el" href="g_i_l_0062.html" title="Represents a concrete instance of a run-time specified type from a set of typesA...">variant</a> can be constructed with rgb8_image_t and then assigned a cmyk16_image_t.<p>
The <a class="el" href="g_i_l_0062.html" title="Represents a concrete instance of a run-time specified type from a set of typesA...">variant</a> has a templated constructor, which allows us to construct it with any concrete type instantiation. It can also perform a generic operation on the concrete type via a call to apply_operation. The operation must be provided as a function object whose application operator has a single parameter which can be instantiated with any of the allowed types of the <a class="el" href="g_i_l_0062.html" title="Represents a concrete instance of a run-time specified type from a set of typesA...">variant</a>.<p>
<a class="el" href="g_i_l_0062.html" title="Represents a concrete instance of a run-time specified type from a set of typesA...">variant</a> breaks down the instantiated type into a non-templated underlying base type and a unique instantiation type identifier. In the most common implementation the concrete instantiation in stored 'in-place' - in 'bits_t'. bits_t contains sufficient space to fit the largest of the instantiated objects.<p>
GIL's <a class="el" href="g_i_l_0062.html" title="Represents a concrete instance of a run-time specified type from a set of typesA...">variant</a> is similar to boost::variant in spirit (hence we borrow the name from there) but it differs in several ways from the current <a class="el" href="namespaceboost.html">boost</a> implementation. Most notably, it does not take a variable number of template parameters but a single parameter defining the type enumeration. As such it can be used more effectively in generic code.<p>
The Types parameter specifies the set of allowable types. It models MPL Random Access Container <table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="7134669ce8033ee155ef5fbd15d74d18"></a><!-- doxytag: member="boost::gil::variant::types_t" ref="7134669ce8033ee155ef5fbd15d74d18" args="" -->
typedef Types&nbsp;</td><td class="memItemRight" valign="bottom"><b>types_t</b></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="bb2707bdfa3fbe55028ff31812b8c070"></a><!-- doxytag: member="boost::gil::variant::variant" ref="bb2707bdfa3fbe55028ff31812b8c070" args="(const T &amp;obj)" -->
template&lt;typename T&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>variant</b> (const T &amp;obj)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="da037b594ec15101938c88fc698d80b7"></a><!-- doxytag: member="boost::gil::variant::variant" ref="da037b594ec15101938c88fc698d80b7" args="(T &amp;obj, bool do_swap)" -->
template&lt;typename T&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>variant</b> (T &amp;obj, bool do_swap)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="3ae126b388a09f750c4fc2d2761600a7"></a><!-- doxytag: member="boost::gil::variant::operator=" ref="3ae126b388a09f750c4fc2d2761600a7" args="(const T &amp;obj)" -->
template&lt;typename T&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top"><a class="el" href="g_i_l_0062.html">variant</a> &amp;&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>operator=</b> (const T &amp;obj)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="dd6b734e8571d58bf212f9ee6e6251ab"></a><!-- doxytag: member="boost::gil::variant::operator=" ref="dd6b734e8571d58bf212f9ee6e6251ab" args="(const variant &amp;v)" -->
<a class="el" href="g_i_l_0062.html">variant</a> &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><b>operator=</b> (const <a class="el" href="g_i_l_0062.html">variant</a> &amp;v)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="d17d9c5c9f034b9a545a0e0b40a29049"></a><!-- doxytag: member="boost::gil::variant::variant" ref="d17d9c5c9f034b9a545a0e0b40a29049" args="(const variant &amp;v)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><b>variant</b> (const <a class="el" href="g_i_l_0062.html">variant</a> &amp;v)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="e003bd0bc96ce08b883dbf864a48b450"></a><!-- doxytag: member="boost::gil::variant::move_in" ref="e003bd0bc96ce08b883dbf864a48b450" args="(T &amp;obj)" -->
template&lt;typename T&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>move_in</b> (T &amp;obj)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="34ea494472846acdd760285d85d7dc22"></a><!-- doxytag: member="boost::gil::variant::_dynamic_cast" ref="34ea494472846acdd760285d85d7dc22" args="() const " -->
template&lt;typename T&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">const T &amp;&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>_dynamic_cast</b> () const </td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="7c84cd1f68db5e601c4721a8a2c5ba6f"></a><!-- doxytag: member="boost::gil::variant::_dynamic_cast" ref="7c84cd1f68db5e601c4721a8a2c5ba6f" args="()" -->
template&lt;typename T&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">T &amp;&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>_dynamic_cast</b> ()</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="6457b76cdd59d781e0ee841286806b1a"></a><!-- doxytag: member="boost::gil::variant::current_type_is" ref="6457b76cdd59d781e0ee841286806b1a" args="() const " -->
template&lt;typename T&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>current_type_is</b> () const </td></tr>
<tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="36f726b4e4a28a717b3a923895578559"></a><!-- doxytag: member="boost::gil::variant::has_type" ref="36f726b4e4a28a717b3a923895578559" args="()" -->
template&lt;typename T&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">static bool&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>has_type</b> ()</td></tr>
<tr><td colspan="2"><br><h2>Friends</h2></td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="8ddc806c49b5ebc278ed1df04659363c"></a><!-- doxytag: member="boost::gil::variant::operator==" ref="8ddc806c49b5ebc278ed1df04659363c" args="(const variant&lt; TS &gt; &amp;x, const variant&lt; TS &gt; &amp;y)" -->
template&lt;typename TS&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>operator==</b> (const <a class="el" href="g_i_l_0062.html">variant</a>&lt; TS &gt; &amp;x, const <a class="el" href="g_i_l_0062.html">variant</a>&lt; TS &gt; &amp;y)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="dc042a6804c230a421fa276fa28a3288"></a><!-- doxytag: member="boost::gil::variant::operator!=" ref="dc042a6804c230a421fa276fa28a3288" args="(const variant&lt; TS &gt; &amp;x, const variant&lt; TS &gt; &amp;y)" -->
template&lt;typename TS&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>operator!=</b> (const <a class="el" href="g_i_l_0062.html">variant</a>&lt; TS &gt; &amp;x, const <a class="el" href="g_i_l_0062.html">variant</a>&lt; TS &gt; &amp;y)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="7657b84c44bec27d2775a546982dd27d"></a><!-- doxytag: member="boost::gil::variant::swap" ref="7657b84c44bec27d2775a546982dd27d" args="(variant&lt; Cs &gt; &amp;x, variant&lt; Cs &gt; &amp;y)" -->
template&lt;typename Cs&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>swap</b> (<a class="el" href="g_i_l_0062.html">variant</a>&lt; Cs &gt; &amp;x, <a class="el" href="g_i_l_0062.html">variant</a>&lt; Cs &gt; &amp;y)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="5a2b09b34d730defa678a0577e2e044b"></a><!-- doxytag: member="boost::gil::variant::apply_operation" ref="5a2b09b34d730defa678a0577e2e044b" args="(variant&lt; Types2 &gt; &amp;var, UnaryOp op)" -->
template&lt;typename Types2, typename UnaryOp&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">UnaryOp::result_type&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>apply_operation</b> (<a class="el" href="g_i_l_0062.html">variant</a>&lt; Types2 &gt; &amp;var, UnaryOp op)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="78ada22248f20734361616cefbc6ef5c"></a><!-- doxytag: member="boost::gil::variant::apply_operation" ref="78ada22248f20734361616cefbc6ef5c" args="(const variant&lt; Types2 &gt; &amp;var, UnaryOp op)" -->
template&lt;typename Types2, typename UnaryOp&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">UnaryOp::result_type&nbsp;</td><td class="memTemplItemRight" valign="bottom"><b>apply_operation</b> (const <a class="el" href="g_i_l_0062.html">variant</a>&lt; Types2 &gt; &amp;var, UnaryOp op)</td></tr>
<tr><td class="memTemplParams" nowrap colspan="2"><a class="anchor" name="780f3b531376ac914d9b016631e2b081"></a><!-- doxytag: member="boost::gil::variant::apply_operation" ref="780f3b531376ac914d9b016631e2b081" args="(const variant&lt; Types1 &gt; &amp;arg1, const variant&lt; Types2 &gt; &amp;arg2, BinaryOp op)" -->
template&lt;typename Types1, typename Types2, typename BinaryOp&gt; </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">BinaryOp::result_type&nbsp;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="g_i_l_0062.html#780f3b531376ac914d9b016631e2b081">apply_operation</a> (const <a class="el" href="g_i_l_0062.html">variant</a>&lt; Types1 &gt; &amp;arg1, const <a class="el" href="g_i_l_0062.html">variant</a>&lt; Types2 &gt; &amp;arg2, BinaryOp op)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Invokes a generic constant operation (represented as a binary function object) on two variants. <br></td></tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="g_i_l_0643.html">variant.hpp</a></ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:18 2009 for Generic Image Library by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>