CommunicatorEvents.h

00001 /**
00002  * @file    SwitchEvents.h
00003  * @brief   Collects events (wosh::Fact extension) related to Switch and Dimmer devices.
00004  *
00005  * @see     wosh::devices::UserAvailabilityChanged [wosh::interfaces::communication::Switch]
00006  * @see     wosh::devices::Dimmer_StateChanged [wosh::interfaces::communication::Dimmer]
00007  ****************************************************************************
00008  * @version 0.8.462 $Id: CommunicatorEvents.h 3775 2011-01-01 16:38:17Z alex $
00009  * @author  Alessandro Polo
00010  ****************************************************************************/
00011 /* Copyright (c) 2007-2011, WOSH - Wide Open Smart Home 
00012  * by Alessandro Polo - OpenSmartHome.com
00013  * All rights reserved.
00014  *
00015  * Redistribution and use in source and binary forms, with or without
00016  * modification, are permitted provided that the following conditions are met:
00017  *     * Redistributions of source code must retain the above copyright
00018  *       notice, this list of conditions and the following disclaimer.
00019  *     * Redistributions in binary form must reproduce the above copyright
00020  *       notice, this list of conditions and the following disclaimer in the
00021  *       documentation and/or other materials provided with the distribution.
00022  *     * Neither the name of the OpenSmartHome.com WOSH nor the
00023  *       names of its contributors may be used to endorse or promote products
00024  *       derived from this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
00027  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00028  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00029  * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
00030  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00031  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00032  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00033  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036  ****************************************************************************/
00037 
00038 #ifndef __WOSH_RMI_Events_SwitchEvents_H__
00039  #define __WOSH_RMI_Events_SwitchEvents_H__
00040 
00041  #include <woshDefs.h>
00042  #include <rmi/IEvent.h>
00043  #include <interfaces/communication/Communicator.h>
00044 
00045 
00046 namespace wosh {
00047  namespace rmi {
00048   namespace events {
00049 
00050 /**
00051  * @class   
00052  * @brief   
00053  *
00054  * @see     wosh::Fact
00055  * @see     wosh::interfaces::communication::Switch
00056  ****************************************************************************
00057  * @version 0.8.462 $Id: CommunicatorEvents.h 3775 2011-01-01 16:38:17Z alex $
00058  * @author  Alessandro Polo
00059  ****************************************************************************/
00060 class UserAvailabilityChanged :     public wosh::rmi::IEvent,
00061                                 public wosh::interfaces::communication::UserAvailabilityChanged
00062  {
00063     WOSH_SERIALIZABLE(wosh::rmi::events::UserAvailabilityChanged)
00064 
00065     public:
00066         /**
00067          * @brief  Empty constructor.
00068          */
00069         UserAvailabilityChanged()
00070             : IEvent(_Communicator_EVENT_AvailabilityChanged) { }
00071 
00072         UserAvailabilityChanged( const std::string& username, wosh::interfaces::communication::USER_AVAILABILITY presence_state,
00073                                         long previous_last_seen = 0 );
00074 
00075         /**
00076          * @brief  Copy constructor.
00077          * @param m [in] the source object to be copied
00078          */
00079         UserAvailabilityChanged( const UserAvailabilityChanged& m )
00080             : IEvent(m) { }
00081         /**
00082          * @brief  Empty destructor.
00083          */
00084         virtual ~UserAvailabilityChanged() { }
00085 
00086     public:
00087         virtual inline std::string getUserName() const      { return getUserName(this); }
00088 
00089         virtual wosh::interfaces::communication::USER_AVAILABILITY getPresenceState() const {
00090             return getPresenceState(this);
00091          }
00092 
00093         virtual inline int64 getPreviousLastSeen() const    { return getPreviousLastSeen(this); }
00094 
00095     public:
00096         static std::string getUserName( const Fact* fact );
00097         static wosh::interfaces::communication::USER_AVAILABILITY getPresenceState( const Fact* fact );
00098         static int64 getPreviousLastSeen( const Fact* fact );
00099 
00100         static UserAvailabilityChanged* fromFact( const Fact* fact );
00101 
00102     public:
00103         /**
00104          * @brief   Get a human friendly description of the event
00105          * @return  string such as "Switch is on"
00106          */
00107         virtual std::string toString() const;
00108 
00109 
00110 }; // class def
00111 //---------------------------------------------------------------------------------------------------------------
00112 
00113 
00114 
00115 class UserInteraction : public wosh::rmi::IEvent,
00116                                         public wosh::interfaces::communication::UserInteraction
00117  {
00118     WOSH_SERIALIZABLE(wosh::rmi::events::UserInteraction)
00119 
00120     public:
00121         /**
00122          * @brief  Empty constructor.
00123          */
00124         UserInteraction()
00125             : IEvent(_Communicator_EVENT_UserInteraction) { }
00126 
00127         UserInteraction( const std::string& username, double availability = -1.0 );
00128 
00129         /**
00130          * @brief  Copy constructor.
00131          * @param m [in] the source object to be copied
00132          */
00133         UserInteraction( const UserInteraction& m )
00134             : IEvent(m) { }
00135         /**
00136          * @brief  Empty destructor.
00137          */
00138         virtual ~UserInteraction() { }
00139 
00140     public:
00141         virtual inline std::string getUserName() const      { return getUserName(this); }
00142         virtual inline double getAvailability()  const      { return getAvailability(this); }
00143 
00144     public:
00145         static std::string getUserName( const Fact* fact );
00146         static double getAvailability( const Fact* fact );
00147 
00148         static UserInteraction* fromFact( const Fact* fact );
00149 
00150     public:
00151         /**
00152          * @brief   Get a human friendly description of the event
00153          * @return  string such as "Switch is on"
00154          */
00155         virtual std::string toString() const;
00156 
00157 
00158 }; // class def
00159 //---------------------------------------------------------------------------------------------------------------
00160 
00161 
00162   }; // namespace events
00163  }; // namespace rmi
00164 }; // namespace wosh
00165 
00166 
00167 #endif //__WOSH_RMI_Events_SwitchEvents_H__

Generated on Tue Feb 8 2011 09:32:48 for WOSH system 0.8.888 [wolf] by Alessandro Polo, using DoxyGen 1.7.2 hosted by WOSH Framework