Main Page   Alphabetical List   Compound List   File List   Compound Members  

PalmApp.hpp

00001 
00002 //......................................................................................
00003 //  This is a part of AI Library [Arthur's Interfaces Library].                        .
00004 //  Copyright © 1989-2001 Arthur Amshukov                                              .
00005 //......................................................................................
00006 //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND         .
00007 //  DO NOT REMOVE MY NAME AND THIS NOTICE FROM THE SOURCE                              .
00008 //......................................................................................
00010 #ifndef __PALM_APP_H__
00011 #define __PALM_APP_H__
00012 
00013 #ifdef __PALM_OS__
00014 
00015 #pragma once
00016 
00017 __BEGIN_NAMESPACE__
00018 
00055 
00073 
00074 // class PalmApp
00075 // ----- -------
00076 class __DECLSPEC__ PalmApp
00077 {
00078     public:
00079 
00080     enum EConst
00081     {
00082         eTimeout = 100  // msecs
00083     };
00084 
00085     enum EErrorCode
00086     {
00087         eOk = 0,
00088         eUnknownCode = appErrorClass|0x0001,
00089         eInitInstanceCode,
00090         eExitInstanceCode,
00091         eResetCode,
00092         eLaunchCodeCode,
00093         eNoGlobalVarsCode
00094     };
00095 
00096     private:
00097      uint16             LaunchCode;
00098      uint16             Flags;
00099      uint32             ExitCode;
00100      const void*        CommandPBP;
00101      EventType          CurrEvent;
00102      volatile int32     Timeout;
00103     private:
00104      bool               IsIdleEvent();
00105      void               Run();
00106      bool               RetriveEvent();
00107     protected:
00109 
00136      virtual void       InitInstance();
00138 
00143      virtual void       ExitInstance();
00144 
00145      virtual bool       Idle(int32);
00146 
00148      virtual bool       PretranslateI();
00149      
00151      virtual bool       PretranslateII();
00152      
00154      virtual bool       AppHandleEvent();
00155     public:
00157                         PalmApp();
00158 
00160      virtual           ~PalmApp();
00161 
00162      // Accessor function
00163      uint16             GetLaunchCode()             const;
00164      void               SetLaunchCode(uint16);
00165 
00166      uint16             GetFlags()                  const;
00167      void               SetFlags(uint16);
00168 
00169      uint32             GetExitCode()               const;
00170      void               SetExitCode(uint32);
00171 
00172      const void*        GetCommandPBP()             const;
00173      void               SetCommandPBP(const void*);
00174 
00175      const EventType&   GetCurrEvent()              const;
00176 
00177      int32              GetTimeout()                const;
00178      void               SetTimeout(int32);
00179 
00180      // api
00181      static void        Quit();
00182 
00183      // entry point
00184      uint32             PilotMain(uint16, void*, uint16);
00185     
00186     public:
00187 
00191     class __DECLSPEC__ XPalmApp : public PalmError
00192     {
00193         public:
00194 
00195         enum EErrors
00196         {
00197             // appErrorClass+'appl'
00198         };
00199 
00200         protected:
00201          virtual void LoadErrorDescriptions();
00202     };
00203 
00204     friend class XPalmApp;
00205 };
00207 
00208 #undef BEGIN_ENTRY_POINT
00209 #undef C_STUB
00210 #undef DEFAULT_C_STUB
00211 #undef END_ENTRY_POINT
00212 
00213 extern "C" uint32 PilotMainCStub(uint16, void*, uint16);
00214 
00215 #define BEGIN_ENTRY_POINT(_app)                                                             \
00216 extern "C"                                                                                  \
00217 uint32 PilotMain(uint16 _command, void* _command_pbp, uint16 _flags)                        \
00218 {                                                                                           \
00219     try                                                                                     \
00220     {                                                                                       \
00221         if(!(_flags & sysAppLaunchFlagNewGlobals) && !(_flags & sysAppLaunchFlagSubCall))   \
00222         {                                                                                   \
00223 
00224 #define C_STUB(_handler)                                                                    \
00225             return _handler(_command, _command_pbp, _flags);                                \
00226         }                                                                                   \
00227 
00228 #define DEFAULT_C_STUB()                                                                    \
00229             return PilotMainCStub(_command, _command_pbp, _flags);                          \
00230         }                                                                                   \
00231 
00232 #define END_ENTRY_POINT(_app)                                                               \
00233         std::auto_ptr<_app> app(new _app());                                                \
00234         return app->PilotMain(_command, _command_pbp, _flags);                              \
00235     }                                                                                       \
00236     catch(...)                                                                              \
00237     {                                                                                       \
00238         NON_FATAL_ERROR("The Application unexpectedly terminated");                         \
00239         return uint32(-1);                                                                          \
00240     }                                                                                       \
00241 }                                                                                           \
00242 
00243 __END_NAMESPACE__
00244 
00245 #endif // __PALM_OS__
00246 #endif // __PALM_APP_H__

Generated on Tue Jan 22 22:13:23 2002 for AIL by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001