00001 /*_############################################################################ 00002 _## 00003 _## mib_avl_map.h 00004 _## 00005 _## 00006 _## AGENT++ API Version 3.5.30 00007 _## ----------------------------------------------- 00008 _## Copyright (C) 2000-2009 Frank Fock, Jochen Katz 00009 _## 00010 _## LICENSE AGREEMENT 00011 _## 00012 _## WHEREAS, Frank Fock and Jochen Katz are the owners of valuable 00013 _## intellectual property rights relating to the AGENT++ API and wish to 00014 _## license AGENT++ subject to the terms and conditions set forth below; 00015 _## and 00016 _## 00017 _## WHEREAS, you ("Licensee") acknowledge that Frank Fock and Jochen Katz 00018 _## have the right to grant licenses to the intellectual property rights 00019 _## relating to AGENT++, and that you desire to obtain a license to use 00020 _## AGENT++ subject to the terms and conditions set forth below; 00021 _## 00022 _## Frank Fock and Jochen Katz grants Licensee a non-exclusive, 00023 _## non-transferable, royalty-free license to use AGENT++ and related 00024 _## materials without charge provided the Licensee adheres to all of the 00025 _## terms and conditions of this Agreement. 00026 _## 00027 _## By downloading, using, or copying AGENT++ or any portion thereof, 00028 _## Licensee agrees to abide by the intellectual property laws and all 00029 _## other applicable laws of Germany, and to all of the terms and 00030 _## conditions of this Agreement, and agrees to take all necessary steps 00031 _## to ensure that the terms and conditions of this Agreement are not 00032 _## violated by any person or entity under the Licensee's control or in 00033 _## the Licensee's service. 00034 _## 00035 _## Licensee shall maintain the copyright and trademark notices on the 00036 _## materials within or otherwise related to AGENT++, and not alter, 00037 _## erase, deface or overprint any such notice. 00038 _## 00039 _## Except as specifically provided in this Agreement, Licensee is 00040 _## expressly prohibited from copying, merging, selling, leasing, 00041 _## assigning, or transferring in any manner, AGENT++ or any portion 00042 _## thereof. 00043 _## 00044 _## Licensee may copy materials within or otherwise related to AGENT++ 00045 _## that bear the author's copyright only as required for backup purposes 00046 _## or for use solely by the Licensee. 00047 _## 00048 _## Licensee may not distribute in any form of electronic or printed 00049 _## communication the materials within or otherwise related to AGENT++ 00050 _## that bear the author's copyright, including but not limited to the 00051 _## source code, documentation, help files, examples, and benchmarks, 00052 _## without prior written consent from the authors. Send any requests for 00053 _## limited distribution rights to fock@agentpp.com. 00054 _## 00055 _## Licensee hereby grants a royalty-free license to any and all 00056 _## derivatives based upon this software code base, that may be used 00057 _## as a SNMP agent development environment or a SNMP agent development 00058 _## tool. 00059 _## 00060 _## Licensee may modify the sources of AGENT++ for the Licensee's own 00061 _## purposes. Thus, Licensee may not distribute modified sources of 00062 _## AGENT++ without prior written consent from the authors. 00063 _## 00064 _## The Licensee may distribute binaries derived from or contained within 00065 _## AGENT++ provided that: 00066 _## 00067 _## 1) The Binaries are not integrated, bundled, combined, or otherwise 00068 _## associated with a SNMP agent development environment or SNMP agent 00069 _## development tool; and 00070 _## 00071 _## 2) The Binaries are not a documented part of any distribution material. 00072 _## 00073 _## 00074 _## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00075 _## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00076 _## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00077 _## IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00078 _## INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00079 _## (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00080 _## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00081 _## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00082 _## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00083 _## IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00084 _## POSSIBILITY OF SUCH DAMAGE. 00085 _## 00086 _## 00087 _## Stuttgart, Germany, Fri May 29 22:36:02 CEST 2009 00088 _## 00089 _##########################################################################*/ 00090 // This may look like C code, but it is really -*- C++ -*- 00091 /* 00092 Copyright (C) 1988 Free Software Foundation 00093 written by Doug Lea (dl@rocky.oswego.edu) 00094 00095 This file is part of the GNU C++ Library. This library is free 00096 software; you can redistribute it and/or modify it under the terms of 00097 the GNU Library General Public License as published by the Free 00098 Software Foundation; either version 2 of the License, or (at your 00099 option) any later version. This library is distributed in the hope 00100 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00101 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00102 PURPOSE. See the GNU Library General Public License for more details. 00103 You should have received a copy of the GNU Library General Public 00104 License along with this library; if not, write to the Free Software 00105 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00106 */ 00107 00108 00109 #ifndef _OidxPtrMibEntryPtrAVLMap_h 00110 #ifdef __GNUG__ 00111 #pragma interface 00112 #endif 00113 #define _OidxPtrMibEntryPtrAVLMap_h 1 00114 00115 #include <agent_pp/agent++.h> 00116 #include <agent_pp/mib_map.h> 00117 00118 #ifdef AGENTPP_NAMESPACE 00119 namespace Agentpp { 00120 #endif 00121 00122 00123 struct OidxPtrMibEntryPtrAVLNode 00124 { 00125 OidxPtrMibEntryPtrAVLNode* lt; 00126 OidxPtrMibEntryPtrAVLNode* rt; 00127 OidxPtr item; 00128 MibEntryPtr cont; 00129 char stat; 00130 OidxPtrMibEntryPtrAVLNode(OidxPtr h, MibEntryPtr c, 00131 OidxPtrMibEntryPtrAVLNode* l=0, OidxPtrMibEntryPtrAVLNode* r=0); 00132 ~OidxPtrMibEntryPtrAVLNode() {}; 00133 }; 00134 00135 inline OidxPtrMibEntryPtrAVLNode::OidxPtrMibEntryPtrAVLNode(OidxPtr h, MibEntryPtr c, 00136 OidxPtrMibEntryPtrAVLNode* l, OidxPtrMibEntryPtrAVLNode* r) 00137 :lt(l), rt(r), item(h), cont(c), stat(0) {} 00138 00139 typedef OidxPtrMibEntryPtrAVLNode* OidxPtrMibEntryPtrAVLNodePtr; 00140 00141 00142 class AGENTPP_DECL OidxPtrMibEntryPtrAVLMap : public OidxPtrMibEntryPtrMap 00143 { 00144 protected: 00145 OidxPtrMibEntryPtrAVLNode* root; 00146 00147 OidxPtrMibEntryPtrAVLNode* leftmost(); 00148 OidxPtrMibEntryPtrAVLNode* rightmost(); 00149 OidxPtrMibEntryPtrAVLNode* pred(OidxPtrMibEntryPtrAVLNode* t); 00150 OidxPtrMibEntryPtrAVLNode* succ(OidxPtrMibEntryPtrAVLNode* t); 00151 void _kill(OidxPtrMibEntryPtrAVLNode* t); 00152 void _add(OidxPtrMibEntryPtrAVLNode*& t); 00153 void _del(OidxPtrMibEntryPtrAVLNode* p, OidxPtrMibEntryPtrAVLNode*& t); 00154 00155 public: 00156 OidxPtrMibEntryPtrAVLMap(MibEntryPtr deflt); 00157 OidxPtrMibEntryPtrAVLMap(OidxPtrMibEntryPtrAVLMap& a); 00158 inline ~OidxPtrMibEntryPtrAVLMap(); 00159 00160 MibEntryPtr& operator [] (OidxPtr key); 00161 00162 void del(OidxPtr key); 00163 00164 inline Pix first(); 00165 inline void next(Pix& i); 00166 inline OidxPtr& key(Pix i); 00167 inline MibEntryPtr& contents(Pix i); 00168 00169 Pix seek(OidxPtr key); 00170 Pix seek_inexact(OidxPtr key); 00171 inline int contains(OidxPtr key_); 00172 00173 inline void clear(); 00174 00175 Pix last(); 00176 void prev(Pix& i); 00177 00178 int OK(); 00179 }; 00180 00181 inline OidxPtrMibEntryPtrAVLMap::~OidxPtrMibEntryPtrAVLMap() 00182 { 00183 _kill(root); 00184 } 00185 00186 inline OidxPtrMibEntryPtrAVLMap::OidxPtrMibEntryPtrAVLMap(MibEntryPtr deflt) :OidxPtrMibEntryPtrMap(deflt) 00187 { 00188 root = 0; 00189 } 00190 00191 inline Pix OidxPtrMibEntryPtrAVLMap::first() 00192 { 00193 return Pix(leftmost()); 00194 } 00195 00196 inline Pix OidxPtrMibEntryPtrAVLMap::last() 00197 { 00198 return Pix(rightmost()); 00199 } 00200 00201 inline void OidxPtrMibEntryPtrAVLMap::next(Pix& i) 00202 { 00203 if (i != 0) i = Pix(succ((OidxPtrMibEntryPtrAVLNode*)i)); 00204 } 00205 00206 inline void OidxPtrMibEntryPtrAVLMap::prev(Pix& i) 00207 { 00208 if (i != 0) i = Pix(pred((OidxPtrMibEntryPtrAVLNode*)i)); 00209 } 00210 00211 inline OidxPtr& OidxPtrMibEntryPtrAVLMap::key(Pix i) 00212 { 00213 if (i == 0) error("null Pix"); 00214 return ((OidxPtrMibEntryPtrAVLNode*)i)->item; 00215 } 00216 00217 inline MibEntryPtr& OidxPtrMibEntryPtrAVLMap::contents(Pix i) 00218 { 00219 if (i == 0) error("null Pix"); 00220 return ((OidxPtrMibEntryPtrAVLNode*)i)->cont; 00221 } 00222 00223 inline void OidxPtrMibEntryPtrAVLMap::clear() 00224 { 00225 _kill(root); 00226 count = 0; 00227 root = 0; 00228 } 00229 00230 inline int OidxPtrMibEntryPtrAVLMap::contains(OidxPtr key_) 00231 { 00232 return seek(key_) != 0; 00233 } 00234 00235 #ifdef AGENTPP_NAMESPACE 00236 } 00237 #endif 00238 00239 #endif