IMemory.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_IMEMORY_H_
00014 #define _SUPPORT_IMEMORY_H_
00015 
00021 #include <support/Binder.h>
00022 #include <support/IInterface.h>
00023 #include <support/Value.h>
00024 
00025 #if _SUPPORTS_NAMESPACE
00026 namespace palmos {
00027 namespace support {
00028 #endif
00029 
00034 
00035 // IMemoryHeap Interface
00037 
00039 
00047 class IMemoryHeap : public IInterface
00048 {
00049 public:
00050     B_DECLARE_META_INTERFACE(MemoryHeap)
00051 
00052     
00053     virtual int32_t             HeapID() const = 0;
00055     virtual void *                  HeapBase() const = 0;
00056 };
00057 
00059 // IMemory Interface
00061 
00063 
00075 class IMemory : public IInterface
00076 {
00077 public:
00078     B_DECLARE_META_INTERFACE(Memory)
00079 
00080     
00081     virtual sptr<IMemoryHeap>   GetMemory(ssize_t *offset = NULL, ssize_t *size = NULL) const = 0;
00082 
00084             void *              Pointer() const;
00085 
00087             void *              FastPointer(const sptr<IBinder>& heap, ssize_t offset) const;
00088 
00090             ssize_t             Size() const;
00091 };
00092 
00094 // IMemoryDealer Interface
00096 
00098 
00110 class IMemoryDealer : public IInterface
00111 {
00112 public:
00113     B_DECLARE_META_INTERFACE(MemoryDealer)
00114 
00115     
00116     virtual sptr<IMemory> Allocate(size_t size, uint32_t properties) = 0;
00117 };
00118 
00121 
00122 
00123 class BnMemoryHeap : public BnInterface<IMemoryHeap>
00124 {
00125 protected:
00126     inline              BnMemoryHeap() : BnInterface<IMemoryHeap>() { }
00127     inline              BnMemoryHeap(const SContext& context) : BnInterface<IMemoryHeap>(context) { }
00128     inline virtual      ~BnMemoryHeap() { }
00129     virtual status_t    HandleEffect(   const SValue &in,
00130                                         const SValue &inBindings,
00131                                         const SValue &outBindings,
00132                                         SValue *out);
00133     virtual status_t    Transact(   uint32_t code,
00134                                     SParcel& data,
00135                                     SParcel* reply = NULL,
00136                                     uint32_t flags = 0);
00137 private:
00138                         BnMemoryHeap(const BnMemoryHeap&);
00139     BnMemoryHeap&       operator=(const BnMemoryHeap&);
00140 
00141 };
00142 
00143 class BnMemory : public BnInterface<IMemory>
00144 {
00145 protected:
00146     inline              BnMemory() : BnInterface<IMemory>() { }
00147     inline              BnMemory(const SContext& context) : BnInterface<IMemory>(context) { }
00148     inline virtual      ~BnMemory() { }
00149     virtual status_t    HandleEffect(   const SValue &in,
00150                                         const SValue &inBindings,
00151                                         const SValue &outBindings,
00152                                         SValue *out);
00153     virtual status_t    Transact(   uint32_t code,
00154                                     SParcel& data,
00155                                     SParcel* reply = NULL,
00156                                     uint32_t flags = 0);
00157 private:
00158                         BnMemory(const BnMemory&);
00159             BnMemory&   operator=(const BnMemory&);
00160 };
00161 
00162 class BnMemoryDealer : public BnInterface<IMemoryDealer>
00163 {
00164 protected:
00165     inline              BnMemoryDealer() : BnInterface<IMemoryDealer>() { }
00166     inline              BnMemoryDealer(const SContext& c) : BnInterface<IMemoryDealer>(c) { }
00167     inline virtual      ~BnMemoryDealer() { }
00168     virtual status_t    HandleEffect(   const SValue &in,
00169                                         const SValue &inBindings,
00170                                         const SValue &outBindings,
00171                                         SValue *out);
00172     virtual status_t    Transact(   uint32_t code,
00173                                     SParcel& data,
00174                                     SParcel* reply = NULL,
00175                                     uint32_t flags = 0);
00176 private:
00177                         BnMemoryDealer(const BnMemoryDealer&);
00178     BnMemoryDealer&     operator=(const BnMemoryDealer&);
00179 };
00180 
00181 
00182 #if _SUPPORTS_NAMESPACE
00183 } } // namespace palmos::support
00184 #endif
00185 
00186 #endif // _SUPPORT_IMEMORY_H_