Selector.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _SUPPORT_SELECTOR_H
00014 #define _SUPPORT_SELECTOR_H
00015 
00021 #include <support/ISelector.h>
00022 #include <support/Locker.h>
00023 #include <support/KeyedVector.h>
00024 
00025 /*  @addtogroup CoreSupportBinder
00026     @{
00027 */
00028 
00030 #if _SUPPORTS_NAMESPACE
00031 namespace palmos {
00032 namespace support {
00033 #endif
00034 
00035 class BSelector : public BnSelector
00036 {
00037 public:
00038                     BSelector();
00039                     BSelector(const SContext& context);
00040                     BSelector(const SContext& context, const SValue &initialValue);
00041     virtual         ~BSelector();
00042     
00043     virtual SValue  Value() const;
00044     virtual void    SetValue(const SValue &value);
00045 
00046     virtual status_t Register(const SValue &key, const sptr<IBinder> &binder,
00047                                 const SValue &property, uint32_t flags = 0);
00048     virtual status_t Unregister(const SValue &key, const sptr<IBinder> &binder,
00049                                 const SValue &property, uint32_t flags = 0);
00050 
00051 private:
00052     struct Registration {
00053         sptr<IBinder> binder;
00054         SValue property;
00055         uint32_t flags;
00056     };
00057 
00058     static void send_to_binders(const SVector<Registration> &regs, bool value);
00059 
00060     mutable SLocker m_lock;
00061     SValue m_value;
00062     SKeyedVector<SValue, SVector<Registration> > m_regs;
00063 };
00064 
00066 #if _SUPPORTS_NAMESPACE
00067 } } // palmos::support;
00068 #endif
00069 
00070 #endif // _SUPPORT_SELECTOR_H