machine.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_MACHINE_H
00033 #define LL_MACHINE_H
00034 
00035 #include "llerror.h"
00036 #include "net.h"
00037 #include "llhost.h"
00038 
00039 typedef enum e_machine_type
00040 {
00041         MT_NULL,
00042         MT_SIMULATOR,
00043         MT_VIEWER,
00044         MT_SPACE_SERVER,
00045         MT_OBJECT_REPOSITORY,
00046         MT_PROXY,
00047         MT_EOF
00048 } EMachineType;
00049 
00050 const U32 ADDRESS_STRING_SIZE = 12;
00051 
00052 class LLMachine
00053 {
00054 public:
00055         LLMachine() 
00056                 : mMachineType(MT_NULL), mControlPort(0) {}     
00057 
00058         LLMachine(EMachineType machine_type, U32 ip, S32 port) 
00059                 : mMachineType(machine_type), mControlPort(0), mHost(ip,port) {}
00060 
00061         LLMachine(EMachineType machine_type, const LLHost &host) 
00062                 : mMachineType(machine_type) {mHost = host; mControlPort = 0;}
00063 
00064         ~LLMachine()    {}
00065 
00066         // get functions
00067         EMachineType    getMachineType()        const { return mMachineType; }
00068         U32                             getMachineIP()          const { return mHost.getAddress(); }
00069         S32                             getMachinePort()        const { return mHost.getPort(); }
00070         const LLHost    &getMachineHost()       const { return mHost; }
00071         // The control port is the listen port of the parent process that
00072         // launched this machine. 0 means none or not known.
00073         const S32               &getControlPort()       const { return mControlPort; }
00074         BOOL                    isValid()                       const { return (mHost.getPort() != 0); }        // TRUE if corresponds to functioning machine
00075 
00076         // set functions
00077         void                    setMachineType(EMachineType machine_type)       { mMachineType = machine_type; }
00078         void                    setMachineIP(U32 ip)                                            { mHost.setAddress(ip); }
00079         void                    setMachineHost(const LLHost &host)                  { mHost = host; }
00080 
00081         void    setMachinePort(S32 port)
00082                         { 
00083                                 if (port < 0) 
00084                                 {
00085                                         llinfos << "Can't assign a negative number to LLMachine::mPort" << llendl;
00086                                         mHost.setPort(0);
00087                                 }
00088                                 else 
00089                                 {
00090                                         mHost.setPort(port); 
00091                                 }
00092                         }
00093 
00094         void    setControlPort( S32 port ) 
00095                         {
00096                                 if (port < 0) 
00097                                 {
00098                                         llinfos << "Can't assign a negative number to LLMachine::mControlPort" << llendl;
00099                                         mControlPort = 0;
00100                                 }
00101                                 else 
00102                                 {
00103                                         mControlPort = port; 
00104                                 }
00105                         }
00106 
00107 
00108         // member variables
00109 
00110 // Someday these should be made private.
00111 // When they are, some of the code that breaks should 
00112 // become member functions of LLMachine -- Leviathan
00113 //private:
00114 
00115         // I fixed the others, somebody should fix these! - djs
00116         EMachineType    mMachineType;
00117 
00118 protected:
00119 
00120         S32                             mControlPort;
00121         LLHost          mHost;
00122 };
00123 
00124 #endif

Generated on Thu Jul 1 06:09:54 2010 for Second Life Viewer by  doxygen 1.4.7