diff options
Diffstat (limited to 'linden/indra/llmessage/machine.h')
-rw-r--r-- | linden/indra/llmessage/machine.h | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/linden/indra/llmessage/machine.h b/linden/indra/llmessage/machine.h new file mode 100644 index 0000000..72caadc --- /dev/null +++ b/linden/indra/llmessage/machine.h | |||
@@ -0,0 +1,120 @@ | |||
1 | /** | ||
2 | * @file machine.h | ||
3 | * @brief LLMachine class header file | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_MACHINE_H | ||
29 | #define LL_MACHINE_H | ||
30 | |||
31 | #include "llerror.h" | ||
32 | #include "net.h" | ||
33 | #include "llhost.h" | ||
34 | |||
35 | typedef enum e_machine_type | ||
36 | { | ||
37 | MT_NULL, | ||
38 | MT_SIMULATOR, | ||
39 | MT_VIEWER, | ||
40 | MT_SPACE_SERVER, | ||
41 | MT_OBJECT_REPOSITORY, | ||
42 | MT_PROXY, | ||
43 | MT_EOF | ||
44 | } EMachineType; | ||
45 | |||
46 | const U32 ADDRESS_STRING_SIZE = 12; | ||
47 | |||
48 | class LLMachine | ||
49 | { | ||
50 | public: | ||
51 | LLMachine() | ||
52 | : mMachineType(MT_NULL), mControlPort(0) {} | ||
53 | |||
54 | LLMachine(EMachineType machine_type, U32 ip, S32 port) | ||
55 | : mMachineType(machine_type), mControlPort(0), mHost(ip,port) {} | ||
56 | |||
57 | LLMachine(EMachineType machine_type, const LLHost &host) | ||
58 | : mMachineType(machine_type) {mHost = host; mControlPort = 0;} | ||
59 | |||
60 | ~LLMachine() {} | ||
61 | |||
62 | // get functions | ||
63 | EMachineType getMachineType() const { return mMachineType; } | ||
64 | const U32 getMachineIP() const { return mHost.getAddress(); } | ||
65 | const S32 getMachinePort() const { return mHost.getPort(); } | ||
66 | const LLHost &getMachineHost() const { return mHost; } | ||
67 | // The control port is the listen port of the parent process that | ||
68 | // launched this machine. 0 means none or not known. | ||
69 | const S32 &getControlPort() const { return mControlPort; } | ||
70 | BOOL isValid() const { return (mHost.getPort() != 0); } // TRUE if corresponds to functioning machine | ||
71 | |||
72 | // set functions | ||
73 | void setMachineType(EMachineType machine_type) { mMachineType = machine_type; } | ||
74 | void setMachineIP(U32 ip) { mHost.setAddress(ip); } | ||
75 | void setMachineHost(const LLHost &host) { mHost = host; } | ||
76 | |||
77 | void setMachinePort(S32 port) | ||
78 | { | ||
79 | if (port < 0) | ||
80 | { | ||
81 | llinfos << "Can't assign a negative number to LLMachine::mPort" << llendl; | ||
82 | mHost.setPort(0); | ||
83 | } | ||
84 | else | ||
85 | { | ||
86 | mHost.setPort(port); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | void setControlPort( S32 port ) | ||
91 | { | ||
92 | if (port < 0) | ||
93 | { | ||
94 | llinfos << "Can't assign a negative number to LLMachine::mControlPort" << llendl; | ||
95 | mControlPort = 0; | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | mControlPort = port; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | |||
104 | // member variables | ||
105 | |||
106 | // Someday these should be made private. | ||
107 | // When they are, some of the code that breaks should | ||
108 | // become member functions of LLMachine -- Leviathan | ||
109 | //private: | ||
110 | |||
111 | // I fixed the others, somebody should fix these! - djs | ||
112 | EMachineType mMachineType; | ||
113 | |||
114 | protected: | ||
115 | |||
116 | S32 mControlPort; | ||
117 | LLHost mHost; | ||
118 | }; | ||
119 | |||
120 | #endif | ||