TokenSource.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 _TOKEN_SOURCE_H
00014 #define _TOKEN_SOURCE_H
00015 
00021 #include <support/Autolock.h>
00022 #include <support/Handler.h>
00023 #include <support/IIterable.h>
00024 #include <support/Node.h>
00025 #include <support/Package.h>
00026 
00027 #if _SUPPORTS_NAMESPACE
00028 namespace palmos {
00029 namespace support {
00030 #endif
00031 
00036 
00037 
00064 class BTokenSource : public BnNode, public BnIterable, private BHandler
00065 {
00066 public:
00067                         BTokenSource(const SContext& context, const SValue& args);
00068     virtual             ~BTokenSource();
00069 
00070     virtual void        InitAtom();
00071     virtual SValue      Inspect(const sptr<IBinder>& caller, const SValue &which, uint32_t flags = 0);
00072     
00075     virtual sptr<INode> Attributes() const;
00076     virtual SString MimeType() const;
00077     virtual void SetMimeType(const SString& value);
00078     virtual nsecs_t CreationDate() const;
00079     virtual void SetCreationDate(nsecs_t value);
00080     virtual nsecs_t ModifiedDate() const;
00081     virtual void SetModifiedDate(nsecs_t value);    
00082     virtual status_t Walk(SString* path, uint32_t flags, SValue* node);
00084 
00087     virtual sptr<IIterator> NewIterator(const SValue& args, status_t* error);
00089 
00090     // BHandler
00091     virtual status_t    HandleMessage(const SMessage& msg);
00092 
00093                         // returns the token.  The same as accessing it through
00094                         // the "token" catalog entry.
00095             SValue      GetToken();
00096 
00097 protected:
00098     // Disambiguate.
00099     const SContext& Context() const;
00100     
00101 private:
00102     class Token : public BBinder
00103     {
00104     public:
00105         Token(const sptr<BTokenSource> &source);
00106         virtual ~Token();
00107     private:
00108         sptr<BTokenSource> m_source;
00109     };
00110 
00111     friend class Token;
00112 
00113     void token_done();
00114 
00115     SLocker m_lock;
00116     SValue m_acquiredAction;
00117     SValue m_releasedAction;
00118     wptr<Token> m_token;
00119 };
00120 
00122 #if _SUPPORTS_NAMESPACE
00123 } }
00124 #endif
00125 
00126 #endif // _TOKEN_SOURCE_H