ICommand.h

Go to the documentation of this file.
00001 /*========================================================== */ 
00002 // header file automatically generated by PIDGEN - DO NOT MODIFY
00003 /*========================================================== */ 
00004 
00005 #ifndef APP_ICOMMAND_H
00006 #define APP_ICOMMAND_H
00007 
00008 #include <support/IInterface.h>
00009 #include <support/Binder.h>
00010 #include <support/Context.h>
00011 #include <support/String.h>
00012 
00013 /*
00014  * Copyright (c) 2005 Palmsource, Inc.
00015  * 
00016  * This software is licensed as described in the file LICENSE, which
00017  * you should have received as part of this distribution. The terms
00018  * are also available at http://www.openbinder.org/license.html.
00019  * 
00020  * This software consists of voluntary contributions made by many
00021  * individuals. For the exact contribution history, see the revision
00022  * history and logs, available at http://www.openbinder.org
00023  */
00024 #include <support/IByteStream.h>
00025 
00026 /* ============= Interface Class Declarations =========================== */
00027 
00028 #if _SUPPORTS_NAMESPACE
00029 namespace palmos {
00030 namespace app {
00031 using namespace palmos::support;
00032 #endif /* _SUPPORTS_NAMESPACE */
00033 
00034 class ICommand : public IInterface
00035 {
00036 public:
00037     B_DECLARE_META_INTERFACE(Command)
00038     
00039     
00040     /* ------- Typedefs --------------------- */
00041     typedef SVector<SValue> ArgList;
00042     
00043     /* ------- Properties --------------------- */
00044     
00045     virtual sptr<IByteInput>        ByteInput() const = 0;
00046     virtual void                    SetByteInput(const sptr<IByteInput>& value) = 0;
00047     
00048     virtual sptr<IByteOutput>       ByteOutput() const = 0;
00049     virtual void                    SetByteOutput(const sptr<IByteOutput>& value) = 0;
00050     
00051     virtual sptr<IByteOutput>       ByteError() const = 0;
00052     virtual void                    SetByteError(const sptr<IByteOutput>& value) = 0;
00053     
00054     virtual SValue                  Environment() const = 0;
00055     virtual void                    SetEnvironment(const SValue& value) = 0;
00056     
00057     virtual SString                 Documentation() const = 0;
00058     
00059     /* ------- Methods ------------------------ */
00060     
00061     virtual SValue                  Run(const ArgList& args) = 0;
00062     
00063     virtual sptr<ICommand>          Spawn(const SString& command) const = 0;
00064     
00065     virtual void                    SetProperty(const SValue& key, const SValue& value) = 0;
00066     
00067     virtual SValue                  GetProperty(const SValue& key) const = 0;
00068     
00069     virtual void                    RemoveProperty(const SValue& key) = 0;
00070     
00071     virtual void                    SetFileDescriptors(const SValue& fds) = 0;
00072     
00073     virtual void                    AddCommand(const SString& name, const sptr<ICommand>& command) = 0;
00074     
00075     virtual sptr<ICommand>          GetCommand(const SString& name) const = 0;
00076     
00077     virtual void                    RemoveCommand(const SString& name) = 0;
00078     
00079     /* ------- inline helpers ------------------------- */
00080     status_t LinkCommand(const sptr<IBinder>& to, const SValue& mappings, uint32_t flags = 0)
00081     {
00082         return AsBinder()->Link(to, mappings, flags);
00083     }
00084     status_t UnlinkCommand(const sptr<IBinder>& to, const SValue& mappings, uint32_t flags = 0)
00085     {
00086         return AsBinder()->Unlink(to, mappings, flags);
00087     }
00088 
00089 protected:
00090                                     ICommand() { }
00091     virtual                         ~ICommand();
00092 
00093 private:
00094     /* ------- copy/assignment protection ------------------ */
00095                                     ICommand(const ICommand& o);
00096             ICommand&               operator=(const ICommand& o);
00097 };
00098 
00099 
00100 /* ============= Local Class Declarations =============================== */
00101 
00102 class BnCommand : public ICommand, public BBinder
00103 {
00104 public:
00105     virtual SValue                  Inspect(const sptr<IBinder>& caller, const SValue& which, uint32_t flags = 0);
00106     virtual sptr<IInterface>        InterfaceFor(const SValue& descriptor, uint32_t flags = 0);
00107     
00108     /* ------- Push Properties ---------------- */
00109 public:
00110             void                    PushByteInput(const sptr<IByteInput>& value);
00111             void                    PushByteOutput(const sptr<IByteOutput>& value);
00112             void                    PushByteError(const sptr<IByteOutput>& value);
00113             void                    PushEnvironment(const SValue& value);
00114             void                    PushDocumentation(const SString& value);
00115 
00116 protected:
00117                                     BnCommand();
00118                                     BnCommand(const SContext& context);
00119     virtual                         ~BnCommand();
00120     
00121     virtual sptr<IBinder>           AsBinderImpl();
00122     virtual sptr<const IBinder>     AsBinderImpl() const;
00123     
00124     /* ------- Marshalling Details ------------ */
00125     virtual status_t                HandleEffect(const SValue &, const SValue &, const SValue &, SValue *);
00126     virtual status_t                Transact(uint32_t code, SParcel& data, SParcel* reply, uint32_t flags);
00127 
00128 private:
00129                                     BnCommand(const BnCommand& o);
00130             BnCommand&              operator=(const BnCommand& o);
00131 };
00132 
00133 
00134 #if _SUPPORTS_NAMESPACE
00135 } } // namespace palmos::app
00136 #endif /* _SUPPORTS_NAMESPACE */
00137 
00138 
00139 // namespace palmos::app
00140 
00141 #endif // APP_ICOMMAND_H
00142