Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

Object

00001 /*
00002  * NOTE: "zlib/libpng" style License
00003  *
00004  *                 ----=== s t d n e t ===----
00005  *
00006  * Copyright (c) 2002 Warwick Molloy   w-molloy@users.sf.net
00007  *
00008  * Copyright (c) 2002 Stdnet Community
00009  * HTTP://Sourceforge.net/projects/stdnet
00010  *
00011  * All references to "software" refer to the stdnet.
00012  *
00013  * This software is provided 'as-is', without any express or
00014  * implied warranty. In no event will the authors be held liable
00015  * for any damages arising from the use of this software.
00016  *
00017  * Permission is granted to anyone to use this software for any
00018  * purpose, including commercial applications, and to alter it
00019  * and redistribute it freely, subject to the following
00020  * restrictions:
00021  *
00022  * 1.  The origin of this software must not be misrepresented;
00023  *     you must not claim that you wrote the original software.
00024  *     If you use this software in a product, an acknowledgment
00025  *     in the product documentation would be appreciated but
00026  *     is not required.
00027  *
00028  * 2.  Altered source versions must be plainly marked as such,
00029  *     and must not be misrepresented as being the original
00030  *     software.
00031  *
00032  * 3.  This notice may not be removed or altered from any source
00033  *     distribution.
00034  */
00035 
00036 #ifndef __system_Object__
00037 #define __system_Object__
00038 
00039 #ifndef __system_Reference_Type__
00040 #   error   Must include a reference implementation before this file.
00041 #endif
00042 
00043 #ifndef __platform_Lock_Type__
00044 #   error   Must include a lock implementation before this file.
00045 #endif
00046 
00047 #include <stdnet/system/Abstract>
00048 
00049 namespace stdbase {
00050 
00056     namespace system {
00057 
00058 class String;
00059 
00076 class Object : public Abstract
00077 {
00078 protected:
00083     Object( void );
00084 
00091     virtual ~Object( void );
00092 
00093 public:
00094 
00100     class synchronized
00101     {
00102     private:
00103         friend class Object;
00104 
00105         platform::Lock    * object_lock;
00106         
00111         synchronized( platform::Lock & l)
00112             : object_lock( & l )
00113         {};
00114 
00115     public:
00132         synchronized( const synchronized & s)
00133             : object_lock( s. object_lock )
00134         { object_lock -> seize(); }
00135 
00140         ~synchronized()
00141         { object_lock -> release(); }
00142     };
00143 
00144 protected:
00145     friend class ObjectRef;
00146     
00147     mutable unsigned        count;
00148     mutable platform::Lock  lock;
00149     
00150     //  inc() and dec() used internally by ObjectRef.
00151     virtual void        inc() const;
00152     virtual unsigned    dec() const;
00153 
00154 public:
00159     synchronized        synchronize()
00160     { return synchronized( lock ); }
00161 
00162 public:
00168     virtual bool        equals( ObjectRef object );
00169 
00174     virtual system::reference<String>
00175         toString() const;
00176 
00177     //virtual ClassRef    getClass() = 0;
00178 
00179     /*
00180     void    wait();
00181     bool    wait( unsigned delay);
00182     void    notify();
00183     void    notifyAll();
00184     */
00185 };
00186 
00187     } // -- end namespace system --
00188 
00189     //  Bring the synchronized type into the stdbase space
00190     //  where it can be best used.
00191     //
00192 typedef stdbase::system::Object::synchronized    synchronized;
00193 } //------- end namespace stdbase --
00194 
00195 
00196 #endif  // __system_Object__
00197 

Generated at Tue Aug 13 14:19:39 2002 for stdnet2 by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001