interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

/home/tetron/hack/vos/libs/vos/vos/listener.hh

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project (http://interreality.org).
00004 
00005     Copyright (C) 2001-2003 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <http://www.interreality.org>
00022 */
00023 #ifndef _LISTENER_HH_
00024 #define _LISTENER_HH_
00025 
00026 /** @file
00027     Defines ChildChangeListener, ParentChangeListener, and TypeChangeListener.
00028 */
00029 
00030 #include <vos/vos/vosdefs.hh>
00031 #include <vos/vutil/listener.hh>
00032 #include <vos/vos/vobject.hh>
00033 #include <vos/vos/vobjectevent.hh>
00034 #include <vos/vutil/taskqueue.hh>
00035 
00036 #include <string>
00037 
00038 namespace VOS
00039 {
00040 /** @class ChildChangeListener listener.hh vos/vos/listener.hh
00041     @ingroup libvos
00042 
00043     Interface to be called when a listened-to object has some change
00044     to its child list.
00045 */
00046 class VOS_API ChildChangeListener
00047 {
00048 public:
00049     /** Destructor */
00050     virtual ~ChildChangeListener() { };
00051 
00052     /** Called when a child has been inserted into the listened-to children list */
00053     virtual void notifyChildInserted(VobjectEvent& e) = 0;
00054 
00055     /** Called when a child has replaced another child in the listened-to children list */
00056     virtual void notifyChildReplaced(VobjectEvent& e) = 0;
00057 
00058     /** Called when a child has been deleted in the listened-to children list */
00059     virtual void notifyChildRemoved(VobjectEvent& e) = 0;
00060 };
00061 
00062 /** @class ParentChangeListener listener.hh vos/vos/listener.hh
00063     @ingroup libvos
00064 
00065     Interface to be called when a listened-to object has some change
00066     to its parent set.
00067 */
00068 class VOS_API ParentChangeListener
00069 {
00070 public:
00071     virtual ~ParentChangeListener() { }
00072 
00073     /** Called when an object has aquired a new parent. */
00074     virtual void notifyParentInserted(VobjectEvent& e) = 0;
00075 
00076     /** Called when an object has lost a parent. */
00077     virtual void notifyParentRemoved(VobjectEvent& e) = 0;
00078 };
00079 
00080 /** @class TypeChangeListener listener.hh vos/vos/listener.hh
00081     @ingroup libvos
00082 
00083     Interface to be called when a listened-to object has some change
00084     to its type set.
00085 */
00086 class VOS_API TypeChangeListener
00087 {
00088 public:
00089     virtual ~TypeChangeListener() { }
00090 
00091     /** Called when an object has gained a type. */
00092     virtual void notifyTypeInserted(VobjectEvent& e) = 0;
00093 
00094     /** Called when an object has lost a type. */
00095     virtual void notifyTypeRemoved(VobjectEvent& e) = 0;
00096 };
00097 
00098 /** @class DoNothingListener listener.hh vos/vos/listener.hh
00099     @ingroup libvos
00100 
00101     Trivial listener implementation that does nothing.  It can be
00102     useful, however, to force the local cache of remote objects to be
00103     kept up to date.  This is because RemoteVobject only keeps the
00104     cache "fresh" so long as there some part of the application is
00105     registered as a listener -- if there are no listeners, then it
00106     tells the remote site to stop pushing updates.
00107 */
00108 
00109 class VOS_API DoNothingListener : public ChildChangeListener,
00110                           public ParentChangeListener,
00111                           public TypeChangeListener
00112 {
00113 public:
00114     static DoNothingListener static_;
00115 
00116     virtual void notifyChildInserted(VobjectEvent& /*e*/) { }
00117     virtual void notifyChildReplaced(VobjectEvent& /*e*/) { }
00118     virtual void notifyChildRemoved(VobjectEvent& /*e*/) { }
00119     virtual void notifyParentInserted(VobjectEvent& /*e*/) { }
00120     virtual void notifyParentRemoved(VobjectEvent& /*e*/) { }
00121     virtual void notifyTypeInserted(VobjectEvent& /*e*/) { }
00122     virtual void notifyTypeRemoved(VobjectEvent& /*e*/) { }
00123 };
00124 }
00125 
00126 #endif