Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 626e7b9df2c26f4a1ac4abc5819592a1 > files > 60

atlascpp-devel-0.6.2-1.fc15.i686.rpm

<!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">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Atlas-C++: BaseObject.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Atlas-C++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">BaseObject.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// This file may be redistributed and modified only under the terms of</span>
<a name="l00002"></a>00002 <span class="comment">// the GNU Lesser General Public License (See COPYING for details).</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright (C) 2000-2004 Stefanus Du Toit, Aloril and Al Riddoch</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="comment">// $Id$</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="preprocessor">#ifndef ATLAS_OBJECTS_BASEOBJECT_H</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span><span class="preprocessor">#define ATLAS_OBJECTS_BASEOBJECT_H</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;Atlas/Message/MEncoder.h&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;Atlas/Message/Element.h&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;Atlas/Bridge.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;Atlas/Exception.h&gt;</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;list&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="keyword">namespace </span>Atlas {
<a name="l00022"></a>00022 
<a name="l00026"></a>00026 <span class="keyword">namespace </span>Objects {
<a name="l00027"></a>00027 
<a name="l00032"></a><a class="code" href="class_atlas_1_1_objects_1_1_no_such_attr_exception.html">00032</a> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_no_such_attr_exception.html" title="An exception indicating the requested attribute does not exist.">NoSuchAttrException</a> : <span class="keyword">public</span> Atlas::<a class="code" href="class_atlas_1_1_exception.html" title="Base class for all exceptions thrown by Atlas-C++.">Exception</a>
<a name="l00033"></a>00033 {
<a name="l00035"></a>00035     std::string m_name;
<a name="l00036"></a>00036   <span class="keyword">public</span>:
<a name="l00037"></a>00037     <a class="code" href="class_atlas_1_1_objects_1_1_no_such_attr_exception.html" title="An exception indicating the requested attribute does not exist.">NoSuchAttrException</a>(<span class="keyword">const</span> std::string&amp; name) :
<a name="l00038"></a>00038              <a class="code" href="class_atlas_1_1_exception.html" title="Base class for all exceptions thrown by Atlas-C++.">Atlas::Exception</a>(<span class="stringliteral">&quot;No such attribute&quot;</span>), m_name(name) {}
<a name="l00039"></a>00039     <span class="keyword">virtual</span> ~<a class="code" href="class_atlas_1_1_objects_1_1_no_such_attr_exception.html" title="An exception indicating the requested attribute does not exist.">NoSuchAttrException</a>() <span class="keywordflow">throw</span> ();
<a name="l00041"></a><a class="code" href="class_atlas_1_1_objects_1_1_no_such_attr_exception.html#a7e6113e46e5040155939cb0d127d175e">00041</a>     <span class="keyword">const</span> std::string &amp; <a class="code" href="class_atlas_1_1_objects_1_1_no_such_attr_exception.html#a7e6113e46e5040155939cb0d127d175e" title="Get the name of the attribute which does not exist.">getName</a>()<span class="keyword"> const </span>{
<a name="l00042"></a>00042         <span class="keywordflow">return</span> m_name;
<a name="l00043"></a>00043     }
<a name="l00044"></a>00044 };
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> BASE_OBJECT_NO = 0;
<a name="l00047"></a>00047 
<a name="l00067"></a><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html">00067</a> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a>
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069 <span class="keyword">public</span>:
<a name="l00074"></a>00074     <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ac54bdb164c9ea1b30d6ffeddd5de5a96" title="Construct a new BaseObjectData from a subclass.">BaseObjectData</a>(<a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a> *defaults);
<a name="l00075"></a>00075 
<a name="l00076"></a>00076     <span class="keyword">virtual</span> ~<a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a>();
<a name="l00077"></a>00077 
<a name="l00079"></a><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#adaada236e5c7657ddf30d6a6d6b16464">00079</a>     <span class="keywordtype">int</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#adaada236e5c7657ddf30d6a6d6b16464" title="Get class number:">getClassNo</a>()<span class="keyword"> const </span>
<a name="l00080"></a>00080 <span class="keyword">    </span>{
<a name="l00081"></a>00081         <span class="keywordflow">return</span> m_class_no;
<a name="l00082"></a>00082     }
<a name="l00083"></a>00083 
<a name="l00084"></a>00084     <span class="keywordtype">int</span> getAttrFlags()<span class="keyword"> const</span>
<a name="l00085"></a>00085 <span class="keyword">    </span>{
<a name="l00086"></a>00086         <span class="keywordflow">return</span> m_attrFlags;
<a name="l00087"></a>00087     }
<a name="l00088"></a>00088 
<a name="l00089"></a>00089     <span class="keyword">virtual</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ac54bdb164c9ea1b30d6ffeddd5de5a96" title="Construct a new BaseObjectData from a subclass.">BaseObjectData</a> * copy() <span class="keyword">const</span> = 0;
<a name="l00090"></a>00090 
<a name="l00092"></a>00092     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ac2eafb7d5824002070a54d6e8642853a" title="Is this instance of some class?">instanceOf</a>(<span class="keywordtype">int</span> classNo) <span class="keyword">const</span>;
<a name="l00093"></a>00093     
<a name="l00095"></a>00095     <span class="keywordtype">bool</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a16c21a105ac0d81d07e45a55544e4403" title="Check whether the attribute &quot;name&quot; exists.">hasAttr</a>(<span class="keyword">const</span> std::string&amp; name) <span class="keyword">const</span>;
<a name="l00097"></a>00097     <span class="keywordtype">bool</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#aadd94d741f4852af92d73e2c95fddca4" title="Check whether the attribute &quot;name&quot; exists.">hasAttrFlag</a>(<span class="keywordtype">int</span> flag) <span class="keyword">const</span>;
<a name="l00100"></a>00100     <span class="keyword">const</span> <a class="code" href="class_atlas_1_1_message_1_1_element.html" title="Multi-type container.">Atlas::Message::Element</a> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a00456bf4bcd85359cf50c61bc2a9d5c2" title="Retrieve the attribute &quot;name&quot;.">getAttr</a>(<span class="keyword">const</span> std::string&amp; name)
<a name="l00101"></a>00101         <span class="keyword">const</span> <span class="keywordflow">throw</span> (NoSuchAttrException);
<a name="l00104"></a>00104     <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ad11a36534b7ae7b44ef849144147a089" title="Retrieve the attribute &quot;name&quot;.">copyAttr</a>(<span class="keyword">const</span> std::string&amp; name,
<a name="l00105"></a>00105                          <a class="code" href="class_atlas_1_1_message_1_1_element.html" title="Multi-type container.">Atlas::Message::Element</a> &amp; attr) <span class="keyword">const</span>;
<a name="l00107"></a>00107     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a91824339c79e4c11aa61eaca8a68f6e1" title="Set the attribute &quot;name&quot; to the value given by &quot;attr&quot;.">setAttr</a>(<span class="keyword">const</span> std::string&amp; name,
<a name="l00108"></a>00108                          <span class="keyword">const</span> <a class="code" href="class_atlas_1_1_message_1_1_element.html" title="Multi-type container.">Atlas::Message::Element</a>&amp; attr);
<a name="l00110"></a>00110     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ad7ae0860ec321b91b8dd9f64dee1548b" title="Remove the attribute &quot;name&quot;.">removeAttr</a>(<span class="keyword">const</span> std::string&amp; name);
<a name="l00112"></a>00112     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#af353b05d3a24f174fbb9cf62762f3bc6" title="Remove the attribute &quot;name&quot;.">removeAttrFlag</a>(<span class="keywordtype">int</span> flag);
<a name="l00113"></a>00113 
<a name="l00116"></a>00116     <span class="keyword">const</span> Atlas::Message::MapType <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a9cbe102be6f4896da587ffca1ad75d70" title="Convert this object to a Object.">asMessage</a>() <span class="keyword">const</span>;
<a name="l00117"></a>00117 
<a name="l00119"></a>00119     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ab77c9376e81eb6355d48e3e0ee1aa2ed" title="Write this object to an existing Element.">addToMessage</a>(Atlas::Message::MapType &amp;) <span class="keyword">const</span>;
<a name="l00120"></a>00120 
<a name="l00122"></a>00122     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a04d389195d94efa10e9ce520fa2d1c85" title="Send the contents of this object to a Bridge.">sendContents</a>(<a class="code" href="class_atlas_1_1_bridge.html" title="Atlas stream bridge.">Atlas::Bridge</a> &amp; b) <span class="keyword">const</span>;
<a name="l00123"></a>00123 
<a name="l00124"></a>00124     <span class="comment">//move to protected once SmartPtr &lt;-&gt; BaseObject order established</span>
<a name="l00125"></a>00125     <span class="keyword">inline</span> <span class="keywordtype">void</span> incRef();
<a name="l00126"></a>00126     <span class="keyword">inline</span> <span class="keywordtype">void</span> decRef();
<a name="l00127"></a>00127 
<a name="l00133"></a><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ad9001800aee4d92a6dc7d1f551b1857d">00133</a>     <span class="keyword">static</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a> *<a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ad9001800aee4d92a6dc7d1f551b1857d" title="Allocate a new instance of this class, using an existing instance if available.">alloc</a>() {assert(0); <span class="keywordflow">return</span> NULL;} <span class="comment">//not callable</span>
<a name="l00138"></a>00138 <span class="comment"></span>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a7b4113a146b80bd1dca8188d64ffdfe9" title="Free an instance of this class, returning it to the memory pool.">free</a>() = 0;
<a name="l00139"></a>00139 
<a name="l00140"></a>00140     <span class="keyword">class </span>const_iterator;
<a name="l00141"></a>00141 
<a name="l00142"></a>00142     <span class="comment">// FIXME should this hold a reference to the object it&#39;s</span>
<a name="l00143"></a>00143     <span class="comment">// iterating over?</span>
<a name="l00144"></a>00144 
<a name="l00159"></a><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html">00159</a>     <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>
<a name="l00160"></a>00160     {
<a name="l00161"></a>00161     <span class="keyword">public</span>:
<a name="l00162"></a>00162         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a>;
<a name="l00163"></a>00163         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>;
<a name="l00164"></a>00164 
<a name="l00165"></a>00165         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>() : m_obj(0), m_val(<span class="stringliteral">&quot;&quot;</span>, *<span class="keyword">this</span>) {}
<a name="l00166"></a>00166         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; I) : m_obj(I.m_obj),
<a name="l00167"></a>00167             m_current_class(I.m_current_class),
<a name="l00168"></a>00168             m_I(I.m_I), m_val(I.m_val.first, *<span class="keyword">this</span>) {}
<a name="l00169"></a>00169         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>(<a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a>&amp; obj, <span class="keywordtype">int</span> current_class);
<a name="l00170"></a>00170 
<a name="l00171"></a>00171         <span class="comment">// default destructor is fine unless we hold a reference to m_obj</span>
<a name="l00172"></a>00172 
<a name="l00173"></a>00173         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; operator=(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; I);
<a name="l00174"></a>00174 
<a name="l00175"></a>00175         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; operator++(); <span class="comment">// preincrement</span>
<a name="l00176"></a>00176 
<a name="l00177"></a>00177         <span class="keyword">inline</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a> operator++(<span class="keywordtype">int</span>); <span class="comment">// postincrement</span>
<a name="l00178"></a>00178 
<a name="l00179"></a>00179         <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; I) <span class="keyword">const</span>;
<a name="l00180"></a>00180 
<a name="l00181"></a>00181         <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; I)<span class="keyword"> const </span>{<span class="keywordflow">return</span> !operator==(I);}
<a name="l00182"></a>00182 
<a name="l00183"></a><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator_1_1_psuedo_element.html">00183</a>         <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator_1_1_psuedo_element.html">PsuedoElement</a>
<a name="l00184"></a>00184         {
<a name="l00185"></a>00185             <span class="keyword">public</span>:
<a name="l00186"></a>00186                 <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator_1_1_psuedo_element.html">PsuedoElement</a>(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; I) : m_I(I) {}
<a name="l00187"></a>00187 
<a name="l00188"></a>00188                 operator Message::Element() <span class="keyword">const</span>;
<a name="l00189"></a>00189                 <span class="comment">// this acts on const PsuedoElement instead of PsuedoElement</span>
<a name="l00190"></a>00190                 <span class="comment">// so that we can assign to attributes refered to by</span>
<a name="l00191"></a>00191                 <span class="comment">// a const iterator&amp; (as opposed to a const_iterator, where</span>
<a name="l00192"></a>00192                 <span class="comment">// we can&#39;t, but that&#39;s done later)</span>
<a name="l00193"></a>00193                 <span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator_1_1_psuedo_element.html">PsuedoElement</a>&amp; operator=(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_message_1_1_element.html" title="Multi-type container.">Message::Element</a>&amp; val) <span class="keyword">const</span>;
<a name="l00194"></a>00194 
<a name="l00195"></a>00195             <span class="keyword">private</span>:
<a name="l00196"></a>00196                 <span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; m_I;
<a name="l00197"></a>00197         };
<a name="l00198"></a>00198 
<a name="l00199"></a>00199         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator_1_1_psuedo_element.html">PsuedoElement</a>;
<a name="l00200"></a>00200 
<a name="l00201"></a>00201         <span class="keyword">typedef</span> std::pair&lt;std::string,PsuedoElement&gt; value_type;
<a name="l00202"></a>00202 
<a name="l00203"></a>00203         <span class="keyword">const</span> value_type&amp; operator*()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_val;}
<a name="l00204"></a>00204         <span class="keyword">const</span> value_type* operator-&gt;()<span class="keyword"> const </span>{<span class="keywordflow">return</span> &amp;m_val;}
<a name="l00205"></a>00205 
<a name="l00206"></a>00206     <span class="keyword">private</span>:
<a name="l00207"></a>00207         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a> *m_obj; <span class="comment">// pointer to object whose args we&#39;re iterating</span>
<a name="l00208"></a>00208         <span class="keywordtype">int</span> m_current_class; <span class="comment">// m_class_no for current class in the iteration</span>
<a name="l00209"></a>00209         Message::MapType::iterator m_I; <span class="comment">// iterator in m_obj-&gt;m_attributes</span>
<a name="l00210"></a>00210         value_type m_val;
<a name="l00211"></a>00211     };
<a name="l00212"></a>00212     <span class="keyword">friend</span> <span class="keyword">class </span>iterator;
<a name="l00213"></a>00213 
<a name="l00214"></a>00214     <span class="comment">// FIXME should this hold a reference to the object it&#39;s</span>
<a name="l00215"></a>00215     <span class="comment">// iterating over?</span>
<a name="l00216"></a><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">00216</a>     <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>
<a name="l00217"></a>00217     {
<a name="l00218"></a>00218     <span class="keyword">public</span>:
<a name="l00219"></a>00219         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a>;
<a name="l00220"></a>00220 
<a name="l00221"></a>00221         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>() : m_obj(0), m_val(<span class="stringliteral">&quot;&quot;</span>, *<span class="keyword">this</span>) {}
<a name="l00222"></a>00222         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>&amp; I) : m_obj(I.m_obj),
<a name="l00223"></a>00223             m_current_class(I.m_current_class),
<a name="l00224"></a>00224             m_I(I.m_I), m_val(I.m_val.first, *<span class="keyword">this</span>) {}
<a name="l00225"></a>00225         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1iterator.html" title="The iterator first iterates over the contents of m_obj-&gt;m_attributes, holding an iterator to the attr...">iterator</a>&amp; I) : m_obj(I.m_obj),
<a name="l00226"></a>00226             m_current_class(I.m_current_class),
<a name="l00227"></a>00227             m_I(I.m_I), m_val(I.m_val.first, *<span class="keyword">this</span>) {}
<a name="l00228"></a>00228         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a>&amp; obj, <span class="keywordtype">int</span> current_class);
<a name="l00229"></a>00229 
<a name="l00230"></a>00230         <span class="comment">// default destructor is fine unless we hold a reference to m_obj</span>
<a name="l00231"></a>00231 
<a name="l00232"></a>00232         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>&amp; operator=(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>&amp; I);
<a name="l00233"></a>00233 
<a name="l00234"></a>00234         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>&amp; operator++(); <span class="comment">// preincrement</span>
<a name="l00235"></a>00235 
<a name="l00236"></a>00236         <span class="keyword">inline</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a> operator++(<span class="keywordtype">int</span>); <span class="comment">// postincrement</span>
<a name="l00237"></a>00237 
<a name="l00238"></a>00238         <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>&amp; I) <span class="keyword">const</span>;
<a name="l00239"></a>00239 
<a name="l00240"></a>00240         <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>&amp; I)<span class="keyword"> const </span>{<span class="keywordflow">return</span> !operator==(I);}
<a name="l00241"></a>00241 
<a name="l00242"></a><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator_1_1_psuedo_element.html">00242</a>         <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator_1_1_psuedo_element.html">PsuedoElement</a>
<a name="l00243"></a>00243         {
<a name="l00244"></a>00244             <span class="keyword">public</span>:
<a name="l00245"></a>00245                 <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator_1_1_psuedo_element.html">PsuedoElement</a>(<span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>&amp; I) : m_I(I) {}
<a name="l00246"></a>00246 
<a name="l00247"></a>00247                 operator Message::Element() <span class="keyword">const</span>;
<a name="l00248"></a>00248 
<a name="l00249"></a>00249             <span class="keyword">private</span>:
<a name="l00250"></a>00250                 <span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator.html">const_iterator</a>&amp; m_I;
<a name="l00251"></a>00251         };
<a name="l00252"></a>00252 
<a name="l00253"></a>00253         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_objects_1_1_base_object_data_1_1const__iterator_1_1_psuedo_element.html">PsuedoElement</a>;
<a name="l00254"></a>00254 
<a name="l00255"></a>00255         <span class="keyword">typedef</span> std::pair&lt;std::string,PsuedoElement&gt; value_type;
<a name="l00256"></a>00256 
<a name="l00257"></a>00257         <span class="keyword">const</span> value_type&amp; operator*()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_val;}
<a name="l00258"></a>00258         <span class="keyword">const</span> value_type* operator-&gt;()<span class="keyword"> const </span>{<span class="keywordflow">return</span> &amp;m_val;}
<a name="l00259"></a>00259 
<a name="l00260"></a>00260     <span class="keyword">private</span>:
<a name="l00261"></a>00261         <span class="keyword">const</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html" title="Atlas base object class.">BaseObjectData</a> *m_obj; <span class="comment">// pointer to object whose args we&#39;re iterating</span>
<a name="l00262"></a>00262         <span class="keywordtype">int</span> m_current_class; <span class="comment">// m_class_no for current class in the iteration</span>
<a name="l00263"></a>00263         Message::MapType::const_iterator m_I; <span class="comment">// const_iterator in m_obj-&gt;m_attributes</span>
<a name="l00264"></a>00264         value_type m_val;
<a name="l00265"></a>00265     };
<a name="l00266"></a>00266 
<a name="l00267"></a>00267     <span class="keyword">friend</span> <span class="keyword">class </span>const_iterator;
<a name="l00268"></a>00268 
<a name="l00269"></a>00269     iterator begin() {<span class="keywordflow">return</span> iterator(*<span class="keyword">this</span>, -1);}
<a name="l00270"></a>00270     iterator end() {<span class="keywordflow">return</span> iterator(*<span class="keyword">this</span>, BASE_OBJECT_NO);}
<a name="l00271"></a>00271     iterator find(<span class="keyword">const</span> std::string&amp;);
<a name="l00272"></a>00272 
<a name="l00273"></a>00273     const_iterator begin()<span class="keyword"> const </span>{<span class="keywordflow">return</span> const_iterator(*<span class="keyword">this</span>, -1);}
<a name="l00274"></a>00274     const_iterator end()<span class="keyword"> const </span>{<span class="keywordflow">return</span> const_iterator(*<span class="keyword">this</span>, BASE_OBJECT_NO);}
<a name="l00275"></a>00275     const_iterator find(<span class="keyword">const</span> std::string&amp;) <span class="keyword">const</span>;
<a name="l00276"></a>00276 
<a name="l00277"></a>00277 <span class="keyword">protected</span>:
<a name="l00278"></a>00278 
<a name="l00280"></a>00280     <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a7564432dfb76c3b454ae55a9360ee572" title="Find the class which contains the attribute &quot;name&quot;.">getAttrClass</a>(<span class="keyword">const</span> std::string&amp; name) <span class="keyword">const</span>;
<a name="l00281"></a>00281 
<a name="l00283"></a>00283     <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a05126d2b6a32d448ea091b58ced9acf2" title="Find the flag for the attribute &quot;name&quot;.">getAttrFlag</a>(<span class="keyword">const</span> std::string&amp; name) <span class="keyword">const</span>;
<a name="l00284"></a>00284 
<a name="l00286"></a>00286     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a6b229e3bd284563c1c7eaa940c5d577c" title="Iterate over the attributes of this instance.">iterate</a>(<span class="keywordtype">int</span>&amp; current_class, std::string&amp; attr) <span class="keyword">const</span>;
<a name="l00287"></a>00287 
<a name="l00288"></a>00288     <span class="keywordtype">int</span> m_class_no; <span class="comment">//each class has different enum</span>
<a name="l00289"></a>00289     <span class="keywordtype">int</span> m_refCount; <span class="comment">//how many instances </span>
<a name="l00290"></a>00290     <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ac54bdb164c9ea1b30d6ffeddd5de5a96" title="Construct a new BaseObjectData from a subclass.">BaseObjectData</a> *m_defaults;
<a name="l00291"></a>00291     <span class="comment">//this will be defined in each subclass separately, so no need here for it</span>
<a name="l00292"></a>00292     <span class="comment">//static BaseObjectData *begin; </span>
<a name="l00293"></a>00293     <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#ac54bdb164c9ea1b30d6ffeddd5de5a96" title="Construct a new BaseObjectData from a subclass.">BaseObjectData</a> *m_next;
<a name="l00294"></a>00294     std::map&lt;std::string, Atlas::Message::Element&gt; m_attributes;
<a name="l00295"></a>00295     <span class="comment">// is attribute in this object or in default object?</span>
<a name="l00296"></a>00296     <span class="keywordtype">int</span> m_attrFlags;
<a name="l00297"></a>00297 };
<a name="l00298"></a>00298 
<a name="l00299"></a>00299 <span class="keywordtype">void</span> BaseObjectData::incRef() {
<a name="l00300"></a>00300     m_refCount++;
<a name="l00301"></a>00301 }
<a name="l00302"></a>00302 
<a name="l00303"></a>00303 <span class="keywordtype">void</span> BaseObjectData::decRef() {
<a name="l00304"></a>00304     <span class="comment">//why zero based refCount? avoids one m_refCount-- ;-)</span>
<a name="l00305"></a>00305     assert( m_refCount &gt;= 0 );
<a name="l00306"></a>00306     <span class="keywordflow">if</span>(!m_refCount) {
<a name="l00307"></a>00307         <a class="code" href="class_atlas_1_1_objects_1_1_base_object_data.html#a7b4113a146b80bd1dca8188d64ffdfe9" title="Free an instance of this class, returning it to the memory pool.">free</a>();
<a name="l00308"></a>00308         <span class="keywordflow">return</span>;
<a name="l00309"></a>00309     }
<a name="l00310"></a>00310     m_refCount--;
<a name="l00311"></a>00311 }
<a name="l00312"></a>00312 
<a name="l00313"></a>00313 BaseObjectData::iterator BaseObjectData::iterator::operator++(<span class="keywordtype">int</span>) <span class="comment">// postincrement</span>
<a name="l00314"></a>00314 {
<a name="l00315"></a>00315     iterator tmp = *<span class="keyword">this</span>;
<a name="l00316"></a>00316     operator++();
<a name="l00317"></a>00317     <span class="keywordflow">return</span> tmp;
<a name="l00318"></a>00318 }
<a name="l00319"></a>00319 
<a name="l00320"></a>00320 BaseObjectData::const_iterator BaseObjectData::const_iterator::operator++(<span class="keywordtype">int</span>) <span class="comment">// postincrement</span>
<a name="l00321"></a>00321 {
<a name="l00322"></a>00322     const_iterator tmp = *<span class="keyword">this</span>;
<a name="l00323"></a>00323     operator++();
<a name="l00324"></a>00324     <span class="keywordflow">return</span> tmp;
<a name="l00325"></a>00325 }
<a name="l00326"></a>00326 
<a name="l00327"></a>00327 
<a name="l00328"></a>00328 } } <span class="comment">// namespace Atlas::Objects</span>
<a name="l00329"></a>00329 
<a name="l00330"></a>00330 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<HR>
<P>Copyright 2000-2004 the respective authors.</P>
<P>This document can be licensed under the terms of the GNU Free Documentation
License or the GNU General Public License and may be freely distributed under
the terms given by one of these licenses.</P>