Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Context.h

Go to the documentation of this file.
00001 // /******************************************************************************\
00002 // *
00003 // * File:          Context.h
00004 // * Creation date: June 22, 2001 11:59
00005 // * Author:        ClassBuilder
00006 // *                XXXX
00007 // * Purpose:       Declaration of class 'SqContext'
00008 // *
00009 // * Modifications: @INSERT_MODIFICATIONS(* )
00010 // *
00011 // *
00012 // \******************************************************************************/
00013 #ifndef _CONTEXT_H
00014 #define _CONTEXT_H
00015 
00016 //@START_USER1
00021 /* --------------------------------------------------------------
00022 Copyright (C) 2001 LifeLine Networks BV <soap2corba@lifeline.nl>
00023 
00024 This program is free software; you can redistribute it and/or
00025 modify it under the terms of the GNU General Public License
00026 as published by the Free Software Foundation; either
00027 version 2 of the License, or (at your option) any later
00028 version.
00029 
00030 This program is distributed in the hope that it will be useful,
00031 but WITHOUT ANY WARRANTY; without even the implied warranty of
00032 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00033 GNU General Public License for more details.
00034 
00035 You should have received a copy of the GNU General Public License
00036 along with this program; if not, write to the Free Software
00037 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00038 -------------------------------------------------------------- */
00039 //@END_USER1
00040 
00041 
00045 class SqContext
00046 {
00047     // RELATION_UNIQUEVALUETREE_OWNED_ACTIVE(SqContext, Context, SqObjectReference, ObjectReference)
00048 private:
00049     SqObjectReference * _firstObjectReference;
00050     int _countObjectReference;
00051 
00052 protected:
00053 
00054 public:
00055     void AddObjectReference(SqObjectReference* item);
00056     void RemoveObjectReference(SqObjectReference* item);
00057     void DeleteAllObjectReference();
00058     void ReplaceObjectReference(SqObjectReference* item, SqObjectReference* newItem);
00059     SqObjectReference* GetFirstObjectReference() const;
00060     SqObjectReference* GetLastObjectReference() const;
00061     SqObjectReference* GetNextObjectReference(SqObjectReference* pos) const;
00062     SqObjectReference* GetPrevObjectReference(SqObjectReference* pos) const;
00063     int GetObjectReferenceCount() const;
00064     
00065     class  ObjectReferenceIterator
00066     {
00067     private:
00068         SqObjectReference* _refObjectReference;
00069         SqObjectReference* _prevObjectReference;
00070         SqObjectReference* _nextObjectReference;
00071         const SqContext* _iterContext;
00072         
00073         ObjectReferenceIterator* _prev;
00074         ObjectReferenceIterator* _next;
00075         
00076         int (SqObjectReference::*_method)() const;
00077         
00078         static ObjectReferenceIterator* _first;
00079         static ObjectReferenceIterator* _last;
00080         
00081     public:
00082         ObjectReferenceIterator(const SqContext* iterContext,
00083                          int (SqObjectReference::*method)() const = 0,
00084                          SqObjectReference* refObjectReference = 0);
00085         ObjectReferenceIterator(const SqContext& iterContext,
00086                          int (SqObjectReference::*method)() const = 0,
00087                          SqObjectReference* refObjectReference = 0);
00088         ObjectReferenceIterator(const ObjectReferenceIterator& iterator,
00089                          int (SqObjectReference::*method)() const = 0);
00090         ~ObjectReferenceIterator();
00091         
00092         ObjectReferenceIterator& operator= (const ObjectReferenceIterator& iterator)
00093         {
00094             _iterContext = iterator._iterContext;
00095             _refObjectReference = iterator._refObjectReference;
00096             _prevObjectReference = iterator._prevObjectReference;
00097             _nextObjectReference = iterator._nextObjectReference;
00098             _method = iterator._method;
00099             return *this;
00100         }
00101         SqObjectReference* operator++ ()
00102         {
00103             _nextObjectReference = _iterContext->GetNextObjectReference(_nextObjectReference);
00104             if (_method != 0)
00105             {
00106                 while (_nextObjectReference && !(_nextObjectReference->*_method)())
00107                     _nextObjectReference = _iterContext->GetNextObjectReference(_nextObjectReference);
00108             }
00109             _refObjectReference = _prevObjectReference = _nextObjectReference;
00110             return _refObjectReference;
00111         }
00112         SqObjectReference* operator-- ()
00113         {
00114             _prevObjectReference = _iterContext->GetPrevObjectReference(_prevObjectReference);
00115             if (_method != 0)
00116             {
00117                 while (_prevObjectReference && !(_prevObjectReference->*_method)())
00118                     _prevObjectReference = _iterContext->GetPrevObjectReference(_prevObjectReference);
00119             }
00120             _refObjectReference = _nextObjectReference = _prevObjectReference;
00121             return _refObjectReference;
00122         }
00123         operator SqObjectReference*() { return _refObjectReference; }
00124         SqObjectReference* operator-> () { return _refObjectReference; }
00125         SqObjectReference* Get() { return _refObjectReference; }
00126         void Reset() { _refObjectReference = _prevObjectReference = _nextObjectReference = (SqObjectReference*)0; }
00127         
00128         int IsLast() { return (_iterContext->GetLastObjectReference() == _refObjectReference); }
00129         int IsFirst() { return (_iterContext->GetFirstObjectReference() == _refObjectReference); }
00130         
00131         static void Check(SqObjectReference* itemObjectReference);
00132         static void Check(SqObjectReference* itemObjectReference, SqObjectReference* newItemObjectReference);
00133     };
00134     // RELATION_UNIQUEVALUETREE_OWNED_PASSIVE(SqContextManager, ContextManager, SqContext, Context)
00135     
00136 public:
00137     SqContextManager * _refContextManager;
00138     SqContext * _parentContextManager;
00139     SqContext * _leftContextManager;
00140     SqContext * _rightContextManager;
00141 
00142 public:
00143     SqContextManager* GetContextManager() const { return _refContextManager; };
00144 
00145 //@START_USER2
00146 friend class SqContextManager;
00147 //@END_USER2
00148 
00149 // Members
00150 private:
00151     unsigned long m_key;
00152     unsigned short m_timeout;
00153     CString m_UserData;
00154     time_t m_lastAct;
00155     unsigned long m_ObjSeq;
00156     CString m_contextKey;
00157 
00158 protected:
00159 
00160 public:
00161 
00162 // Methods
00163 private:
00164     void ConstructorInclude(SqContextManager* pContextManager);
00165     void DestructorInclude();
00166 
00167 protected:
00168     SqContext(SqContextManager* pContextManager, unsigned long key,
00169               unsigned short timeout);
00170 
00171 public:
00172     virtual ~SqContext();
00173     unsigned long getNextObjSeq();
00174     unsigned short timeoutRemaining(const time_t* pNow = NULL);
00175     const CString& GetContextKey() const;
00176     void SetContextKey(const CString& rContextKey);
00177     unsigned long GetKey() const;
00178     void SetKey(unsigned long key);
00179     time_t GetLastAct() const;
00180     void SetLastAct(time_t lastAct);
00181     unsigned short GetTimeout() const;
00182     void SetTimeout(unsigned short timeout);
00183     const CString& GetUserData() const;
00184     void SetUserData(const CString& rUserData);
00185     SqObjectReference* FindObjectReference(unsigned long ObjSeq);
00186 };
00187 
00188 #endif
00189 
00190 
00191 #ifdef CB_INLINES
00192 #ifndef _CONTEXT_H_INLINES
00193 #define _CONTEXT_H_INLINES
00194 
00198 inline const CString& SqContext::GetContextKey() const
00199 {//@CODE_852
00200     return m_contextKey;
00201 }//@CODE_852
00202 
00203 
00204 
00208 inline void SqContext::SetContextKey(const CString& rContextKey)
00209 {//@CODE_853
00210     m_contextKey = rContextKey;
00211 }//@CODE_853
00212 
00213 
00214 
00218 inline unsigned long SqContext::GetKey() const
00219 {//@CODE_714
00220     return m_key;
00221 }//@CODE_714
00222 
00223 
00224 
00228 inline time_t SqContext::GetLastAct() const
00229 {//@CODE_763
00230     return m_lastAct;
00231 }//@CODE_763
00232 
00233 
00234 
00238 inline void SqContext::SetLastAct(time_t lastAct)
00239 {//@CODE_764
00240     m_lastAct = lastAct;
00241 }//@CODE_764
00242 
00243 
00244 
00248 inline unsigned short SqContext::GetTimeout() const
00249 {//@CODE_746
00250     return m_timeout;
00251 }//@CODE_746
00252 
00253 
00254 
00258 inline void SqContext::SetTimeout(unsigned short timeout)
00259 {//@CODE_747
00260     m_timeout = timeout;
00261 }//@CODE_747
00262 
00263 
00264 
00268 inline const CString& SqContext::GetUserData() const
00269 {//@CODE_750
00270     return m_UserData;
00271 }//@CODE_750
00272 
00273 
00274 
00278 inline void SqContext::SetUserData(const CString& rUserData)
00279 {//@CODE_751
00280     m_UserData = rUserData;
00281 }//@CODE_751
00282 
00283 
00284 
00285 //@START_USER3
00286 //@END_USER3
00287 
00288 #endif
00289 #endif
00290 

This documentation is part of the "SOAP to CORBA bridge" project
Copyright © 2000 by Lifeline Networks bv.
All rights are reserved.