17:39
[skypekit:skypekit.git] / skypekit_2.0.0.190_29281_CB30 / interfaces / skype / cpp_embedded / documentation / html / skype-ptr-vector_8cpp_source.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <title>SkypeKit C++ Wrapper: Main Page</title>
6 <link href="tabs.css" rel="stylesheet" type="text/css"/>
7 <link href="islander.css" rel="stylesheet" type="text/css"/>
8 </head>
9 <body>
10 <img src="..\skypekit.png" align="right">
11 <!-- Generated by Doxygen 1.6.2 -->
12 <script type="text/javascript">
13 <!--
14 function changeDisplayState (e){
15   var num=this.id.replace(/[^[0-9]/g,'');
16   var button=this.firstChild;
17   var sectionDiv=document.getElementById('dynsection'+num);
18   if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
19     sectionDiv.style.display='block';
20     button.src='open.gif';
21   }else{
22     sectionDiv.style.display='none';
23     button.src='closed.gif';
24   }
25 }
26 function initDynSections(){
27   var divs=document.getElementsByTagName('div');
28   var sectionCounter=1;
29   for(var i=0;i<divs.length-1;i++){
30     if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
31       var header=divs[i];
32       var section=divs[i+1];
33       var button=header.firstChild;
34       if (button!='IMG'){
35         divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
36         button=document.createElement('img');
37         divs[i].insertBefore(button,divs[i].firstChild);
38       }
39       header.style.cursor='pointer';
40       header.onclick=changeDisplayState;
41       header.id='dynheader'+sectionCounter;
42       button.src='closed.gif';
43       section.id='dynsection'+sectionCounter;
44       section.style.display='none';
45       section.style.marginLeft='14px';
46       sectionCounter++;
47     }
48   }
49 }
50 window.onload = initDynSections;
51 -->
52 </script>
53 <div class="navigation" id="top">
54   <div class="tabs">
55     <ul>
56       <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
57       <li><a href="annotated.html"><span>Classes</span></a></li>
58       <li class="current"><a href="files.html"><span>Files</span></a></li>
59       <li><a href="examples.html"><span>Examples</span></a></li>
60     </ul>
61   </div>
62   <div class="tabs">
63     <ul>
64       <li><a href="files.html"><span>File&nbsp;List</span></a></li>
65       <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
66     </ul>
67   </div>
68 <h1>skype-ptr-vector.cpp</h1><a href="skype-ptr-vector_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
69 <a name="l00002"></a>00002 <span class="preprocessor">#include &quot;<a class="code" href="skype-ptr-vector_8h.html">skype-ptr-vector.h</a>&quot;</span>
70 <a name="l00003"></a>00003 <span class="comment"></span>
71 <a name="l00004"></a>00004 <span class="comment">/** \cond INTERNAL */</span>
72 <a name="l00005"></a>00005 <span class="keyword">class </span>SEPtrVector::Data
73 <a name="l00006"></a>00006 {
74 <a name="l00007"></a>00007 <span class="keyword">public</span>:
75 <a name="l00008"></a>00008         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ref;
76 <a name="l00009"></a>00009         <span class="keywordtype">void</span>** list;
77 <a name="l00010"></a>00010         <span class="keywordtype">size_t</span> <a class="code" href="class_s_e_ptr_vector.html#afc280e80ebd7b255d03875b911c60f86">size</a>;
78 <a name="l00011"></a>00011 };<span class="comment"></span>
79 <a name="l00012"></a>00012 <span class="comment">/** \endcond */</span>
80 <a name="l00013"></a>00013 
81 <a name="l00014"></a><a class="code" href="class_s_e_ptr_vector.html#a49dd80e6291745c01374cd48039e81c1">00014</a> <a class="code" href="class_s_e_ptr_vector.html#a49dd80e6291745c01374cd48039e81c1">SEPtrVector::SEPtrVector</a>()
82 <a name="l00015"></a>00015                 :d(0)
83 <a name="l00016"></a>00016 {
84 <a name="l00017"></a>00017 
85 <a name="l00018"></a>00018 }
86 <a name="l00019"></a>00019 
87 <a name="l00020"></a><a class="code" href="class_s_e_ptr_vector.html#a93d232ee96364c7e7e8c0af5406cfa74">00020</a> <a class="code" href="class_s_e_ptr_vector.html#a49dd80e6291745c01374cd48039e81c1">SEPtrVector::SEPtrVector</a>(<span class="keywordtype">size_t</span> s)
88 <a name="l00021"></a>00021 {
89 <a name="l00022"></a>00022         <span class="keywordflow">if</span> (0 == s) {
90 <a name="l00023"></a>00023                 d = 0;
91 <a name="l00024"></a>00024                 <span class="keywordflow">return</span>;
92 <a name="l00025"></a>00025         }
93 <a name="l00026"></a>00026 
94 <a name="l00027"></a>00027         d = <span class="keyword">new</span> Data;
95 <a name="l00028"></a>00028 
96 <a name="l00029"></a>00029         d-&gt;size = s;
97 <a name="l00030"></a>00030         d-&gt;list = <span class="keyword">new</span> <span class="keywordtype">void</span>*[s];
98 <a name="l00031"></a>00031         d-&gt;ref = 1;
99 <a name="l00032"></a>00032 }
100 <a name="l00033"></a>00033 
101 <a name="l00034"></a><a class="code" href="class_s_e_ptr_vector.html#aaab31585bcbfb0cbdb34abab87d1d343">00034</a> <a class="code" href="class_s_e_ptr_vector.html#a49dd80e6291745c01374cd48039e81c1">SEPtrVector::SEPtrVector</a>(<span class="keyword">const</span> <a class="code" href="class_s_e_ptr_vector.html" title="Vector is an array that is reference counted.">SEPtrVector</a>&amp; pv)
102 <a name="l00035"></a>00035                 :d(0)
103 <a name="l00036"></a>00036 {
104 <a name="l00037"></a>00037         *<span class="keyword">this</span> = pv;
105 <a name="l00038"></a>00038 }
106 <a name="l00039"></a>00039 
107 <a name="l00040"></a><a class="code" href="class_s_e_ptr_vector.html#a53d4daaafc83f96e9312cad4ab701ec2">00040</a> <a class="code" href="class_s_e_ptr_vector.html#a53d4daaafc83f96e9312cad4ab701ec2">SEPtrVector::~SEPtrVector</a>()
108 <a name="l00041"></a>00041 {
109 <a name="l00042"></a>00042         d_unref();
110 <a name="l00043"></a>00043 }
111 <a name="l00044"></a>00044 
112 <a name="l00045"></a><a class="code" href="class_s_e_ptr_vector.html#af33bc9d280bbb3a33b416b1b002b41f7">00045</a> <span class="keywordtype">void</span> <a class="code" href="class_s_e_ptr_vector.html#af33bc9d280bbb3a33b416b1b002b41f7">SEPtrVector::setnewsize</a>(<span class="keywordtype">size_t</span> s)
113 <a name="l00046"></a>00046 {
114 <a name="l00047"></a>00047 <span class="comment">//  d_unref();</span>
115 <a name="l00048"></a>00048 
116 <a name="l00049"></a>00049         <span class="keywordtype">void</span>** tmp = <span class="keyword">new</span> <span class="keywordtype">void</span>*[s];
117 <a name="l00050"></a>00050         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0;
118 <a name="l00051"></a>00051         <span class="keywordflow">while</span> (i &lt; <a class="code" href="class_s_e_ptr_vector.html#afc280e80ebd7b255d03875b911c60f86">size</a>() &amp;&amp; i &lt; s) {
119 <a name="l00052"></a>00052                 tmp[i] = d-&gt;list[i];
120 <a name="l00053"></a>00053                 i++;
121 <a name="l00054"></a>00054         }
122 <a name="l00055"></a>00055 
123 <a name="l00056"></a>00056         <span class="keywordflow">if</span> (d) {
124 <a name="l00057"></a>00057                 <span class="keyword">delete</span>[] d-&gt;list;
125 <a name="l00058"></a>00058                 <span class="keyword">delete</span> d;
126 <a name="l00059"></a>00059         }
127 <a name="l00060"></a>00060 
128 <a name="l00061"></a>00061         d = <span class="keyword">new</span> Data;
129 <a name="l00062"></a>00062         d-&gt;size = s;
130 <a name="l00063"></a>00063         d-&gt;list = tmp;
131 <a name="l00064"></a>00064 
132 <a name="l00065"></a>00065 <span class="comment">//  d_ref();</span>
133 <a name="l00066"></a>00066 }
134 <a name="l00067"></a>00067 
135 <a name="l00068"></a><a class="code" href="class_s_e_ptr_vector.html#afc280e80ebd7b255d03875b911c60f86">00068</a> <span class="keywordtype">size_t</span> <a class="code" href="class_s_e_ptr_vector.html#afc280e80ebd7b255d03875b911c60f86">SEPtrVector::size</a>()<span class="keyword"> const</span>
136 <a name="l00069"></a>00069 <span class="keyword"></span>{
137 <a name="l00070"></a>00070         <span class="keywordflow">if</span> (0 == d)
138 <a name="l00071"></a>00071                 <span class="keywordflow">return</span> 0;
139 <a name="l00072"></a>00072 
140 <a name="l00073"></a>00073         <span class="keywordflow">return</span> d-&gt;size;
141 <a name="l00074"></a>00074 }
142 <a name="l00075"></a>00075 
143 <a name="l00076"></a><a class="code" href="class_s_e_ptr_vector.html#aad7b96d735f62694fab6c176320130f7">00076</a> <span class="keywordtype">void</span>*&amp; <a class="code" href="class_s_e_ptr_vector.html#aad7b96d735f62694fab6c176320130f7">SEPtrVector::operator[]</a>(<span class="keywordtype">size_t</span> n)<span class="keyword"> const</span>
144 <a name="l00077"></a>00077 <span class="keyword"></span>{
145 <a name="l00078"></a>00078         <span class="keyword">static</span> <span class="keywordtype">void</span>* null = 0;
146 <a name="l00079"></a>00079 
147 <a name="l00080"></a>00080         <span class="keywordflow">if</span> ((0 == d) || (n &gt;= <a class="code" href="class_s_e_ptr_vector.html#afc280e80ebd7b255d03875b911c60f86">size</a>()))
148 <a name="l00081"></a>00081                 <span class="keywordflow">return</span> null;
149 <a name="l00082"></a>00082 
150 <a name="l00083"></a>00083         <span class="keywordflow">return</span> d-&gt;list[n];
151 <a name="l00084"></a>00084 }
152 <a name="l00085"></a>00085 
153 <a name="l00086"></a><a class="code" href="class_s_e_ptr_vector.html#ae17116627db1a79066ceb34821b25c57">00086</a> <a class="code" href="class_s_e_ptr_vector.html" title="Vector is an array that is reference counted.">SEPtrVector</a>&amp; <a class="code" href="class_s_e_ptr_vector.html#ae17116627db1a79066ceb34821b25c57">SEPtrVector::operator=</a>(<span class="keyword">const</span> <a class="code" href="class_s_e_ptr_vector.html" title="Vector is an array that is reference counted.">SEPtrVector</a>&amp; pv)
154 <a name="l00087"></a>00087 {
155 <a name="l00088"></a>00088         d_unref();
156 <a name="l00089"></a>00089 
157 <a name="l00090"></a>00090         d = pv.d;
158 <a name="l00091"></a>00091 
159 <a name="l00092"></a>00092         d_ref();
160 <a name="l00093"></a>00093 
161 <a name="l00094"></a>00094         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
162 <a name="l00095"></a>00095 }
163 <a name="l00096"></a>00096 <span class="comment"></span>
164 <a name="l00097"></a>00097 <span class="comment">/** \cond INTERNAL */</span>
165 <a name="l00098"></a>00098 <span class="keywordtype">void</span> SEPtrVector::d_ref()
166 <a name="l00099"></a>00099 {
167 <a name="l00100"></a>00100         <span class="keywordflow">if</span> (0 == d)
168 <a name="l00101"></a>00101                 <span class="keywordflow">return</span>;
169 <a name="l00102"></a>00102 
170 <a name="l00103"></a>00103         d-&gt;ref++;
171 <a name="l00104"></a>00104 }
172 <a name="l00105"></a>00105 
173 <a name="l00106"></a>00106 <span class="keywordtype">void</span> SEPtrVector::d_unref()
174 <a name="l00107"></a>00107 {
175 <a name="l00108"></a>00108         <span class="keywordflow">if</span> (0 == d)
176 <a name="l00109"></a>00109                 <span class="keywordflow">return</span>;
177 <a name="l00110"></a>00110 
178 <a name="l00111"></a>00111         <span class="keywordflow">if</span> (d-&gt;ref &gt; 1)
179 <a name="l00112"></a>00112                 d-&gt;ref--;
180 <a name="l00113"></a>00113         <span class="keywordflow">else</span> {
181 <a name="l00114"></a>00114                 <span class="keyword">delete</span>[] d-&gt;list;
182 <a name="l00115"></a>00115 
183 <a name="l00116"></a>00116                 <span class="keyword">delete</span> d;
184 <a name="l00117"></a>00117 
185 <a name="l00118"></a>00118                 d = 0;
186 <a name="l00119"></a>00119         }
187 <a name="l00120"></a>00120 }<span class="comment"></span>
188 <a name="l00121"></a>00121 <span class="comment">/** \endcond */</span>
189 </pre></div></div>
190
191 <hr/>   
192                 <p><b>(c) Skype Technologies S.A. Confidential/Proprietary</b></p>              
193                 <p>Last updated: 18 Jun 2010</p>                
194                 </BODY>
195 </HTML>