Click here to Skip to main content
15,885,985 members
Articles / Desktop Programming / MFC

ImageStone - A Powerful C++ Class Library for Image Manipulation

Rate me:
Please Sign up or sign in to vote.
4.81/5 (250 votes)
6 Dec 2011Zlib3 min read 117.8K   51.5K   405  
An article on a library for image manipulation
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>ImageStone: PCL_interface_composite.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a></div>
<h1>PCL_interface_composite.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
00002 <span class="comment"> *   Copyright (C) =USTC= Fu Li</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> *   Author   :  Fu Li</span>
00005 <span class="comment"> *   Create   :  2005-1-23</span>
00006 <span class="comment"> *   Home     :  http://www.crazy-bit.com/</span>
00007 <span class="comment"> *   Mail     :  crazybit@263.net</span>
00008 <span class="comment"> *   History  :  </span>
00009 <span class="comment"> */</span>
00010 <span class="preprocessor">#ifndef __PCL_INTERFACE_COMPOSITE__2005_01_23__H__</span>
00011 <span class="preprocessor"></span><span class="preprocessor">#define __PCL_INTERFACE_COMPOSITE__2005_01_23__H__</span>
00012 <span class="preprocessor"></span><span class="preprocessor">#include &lt;assert.h&gt;</span>
00013 <span class="preprocessor">#include &lt;deque&gt;</span>
00014 <span class="preprocessor">#include &lt;algorithm&gt;</span>
00015 
00016 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt; <span class="keyword">class </span><a class="code" href="class_p_c_l___interface___composite.html">PCL_Interface_Composite</a> ;
00017 
00018 <span class="comment">//=============================================================================</span>
00031 <span class="comment"></span><span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
<a name="l00032"></a><a class="code" href="class_p_c_l___interface___composite.html">00032</a> <span class="keyword">class </span><a class="code" href="class_p_c_l___interface___composite.html">PCL_Interface_Composite</a>
00033 {
00034 <span class="keyword">public</span>:
<a name="l00036"></a><a class="code" href="class_p_c_l___interface___composite.html#a0">00036</a>     <span class="keyword">virtual</span> <a class="code" href="class_p_c_l___interface___composite.html#a0">~PCL_Interface_Composite</a>() {<a class="code" href="class_p_c_l___interface___composite.html#a6">PCL_DeleteAllObjects</a>();}
00037 
<a name="l00039"></a><a class="code" href="class_p_c_l___interface___composite.html#a1">00039</a>     <span class="keywordtype">int</span> <a class="code" href="class_p_c_l___interface___composite.html#a1">PCL_GetObjectCount</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<span class="keywordtype">int</span>)m_objList.size();}
00040 
<a name="l00045"></a><a class="code" href="class_p_c_l___interface___composite.html#a2">00045</a>     <span class="keywordtype">void</span> <a class="code" href="class_p_c_l___interface___composite.html#a2">PCL_PushObject</a> (T* pObj) {m_objList.push_back (pObj);} <span class="comment">// push NULL is permitted</span>
00046 
<a name="l00048"></a><a class="code" href="class_p_c_l___interface___composite.html#a3">00048</a>     T* <a class="code" href="class_p_c_l___interface___composite.html#a3">PCL_GetObject</a> (<span class="keywordtype">int</span> nIndex)<span class="keyword"> const</span>
00049 <span class="keyword">    </span>{
00050         <span class="keywordflow">if</span> ((nIndex &gt;= 0) &amp;&amp; (nIndex &lt; <a class="code" href="class_p_c_l___interface___composite.html#a1">PCL_GetObjectCount</a>()))
00051             <span class="keywordflow">return</span> m_objList[nIndex] ;
00052         <span class="keywordflow">else</span>
00053             {assert(<span class="keyword">false</span>); <span class="keywordflow">return</span> 0;}
00054     }
00055 
<a name="l00057"></a><a class="code" href="class_p_c_l___interface___composite.html#a4">00057</a>     <span class="keywordtype">bool</span> <a class="code" href="class_p_c_l___interface___composite.html#a4">PCL_HasInList</a> (<span class="keyword">const</span> T* pObj)<span class="keyword"> const</span>
00058 <span class="keyword">    </span>{
00059         <span class="keywordflow">return</span> (std::find (m_objList.begin(), m_objList.end(), pObj) != m_objList.end()) ;
00060     }
00061 
<a name="l00063"></a><a class="code" href="class_p_c_l___interface___composite.html#a5">00063</a>     <span class="keywordtype">void</span> <a class="code" href="class_p_c_l___interface___composite.html#a5">PCL_ThrowOwnership</a> (std::deque&lt;T*&gt;&amp; listObj)
00064     {
00065         listObj = m_objList ;
00066         m_objList.clear() ;
00067     }
00068 
<a name="l00070"></a><a class="code" href="class_p_c_l___interface___composite.html#a6">00070</a>     <span class="keywordtype">void</span> <a class="code" href="class_p_c_l___interface___composite.html#a6">PCL_DeleteAllObjects</a>()
00071     {
00072         <span class="keywordflow">while</span> (!m_objList.empty())
00073         {
00074             T   * p = m_objList.back() ;
00075             m_objList.pop_back() ;
00076             <span class="keywordflow">if</span> (p)
00077                 <span class="keyword">delete</span> p ;
00078         }
00079     }
00080 
<a name="l00082"></a><a class="code" href="class_p_c_l___interface___composite.html#a7">00082</a>     <span class="keywordtype">void</span> <a class="code" href="class_p_c_l___interface___composite.html#a7">PCL_DeleteObject</a> (<span class="keywordtype">int</span> nIndex)
00083     {
00084         <span class="keywordflow">if</span> ((nIndex &gt;= 0) &amp;&amp; (nIndex &lt; <a class="code" href="class_p_c_l___interface___composite.html#a1">PCL_GetObjectCount</a>()))
00085         {
00086             T   * p = m_objList[nIndex] ;
00087             m_objList.erase(m_objList.begin() + nIndex) ;
00088             <span class="keywordflow">if</span> (p)
00089                 <span class="keyword">delete</span> p ;
00090         }
00091         <span class="keywordflow">else</span>
00092             {assert(<span class="keyword">false</span>);}
00093     }
00094 
<a name="l00096"></a><a class="code" href="class_p_c_l___interface___composite.html#a8">00096</a>     <span class="keywordtype">void</span> <a class="code" href="class_p_c_l___interface___composite.html#a7">PCL_DeleteObject</a> (T* pObj)
00097     {
00098         <span class="keywordflow">if</span> (std::find (m_objList.begin(), m_objList.end(), pObj) != m_objList.end())
00099         {
00100             m_objList.erase (std::find (m_objList.begin(), m_objList.end(), pObj)) ;
00101             <span class="keywordflow">if</span> (pObj)
00102                 <span class="keyword">delete</span> pObj ;
00103         }
00104         assert (std::find (m_objList.begin(), m_objList.end(), pObj) == m_objList.end()) ;
00105     }
00106 
00107 <span class="keyword">private</span>:
00108     std::deque&lt;T*&gt;   m_objList ;
00109 } ;
00110 
00111 <span class="comment">//=============================================================================</span>
00112 <span class="comment">// inline implement</span>
00113 <span class="comment">//=============================================================================</span>
00114 
00115 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Mar 8 11:12:46 2006 for ImageStone by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License


Written By
Team Leader PhoXo
China China
graduate from University of Science and Technology of China at 2002.

Now I work at www.phoxo.com.

Comments and Discussions