Added really lame script to update copyright year.
[hub.git] / application / hub / classes / class_BaseHubSystem.php
1 <?php
2 /**
3  * A general hub system class
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.shipsimu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 class BaseHubSystem extends BaseFrameworkSystem {
25         // Exception codes
26         const EXCEPTION_CHUNK_ALREADY_ASSEMBLED       = 0x900;
27         const EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED     = 0x901;
28         const EXCEPTION_INVALID_CONNECTION_TYPE       = 0x902;
29         const EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED    = 0x903;
30         const EXCEPTION_BASE64_ENCODING_NOT_MODULO_4  = 0x904;
31         const EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING = 0x905;
32         const EXCEPTION_REQUEST_NOT_ACCEPTED          = 0x906;
33         const EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED    = 0x907;
34         const EXCEPTION_MULTIPLE_MESSAGE_SENT         = 0x908;
35         const EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED   = 0x909;
36         const EXCEPTION_INVALID_UNL                   = 0x90a;
37         const EXCEPTION_INVALID_PRIVATE_KEY_HASH      = 0x90b;
38
39         // Message status codes
40         const MESSAGE_STATUS_CODE_OKAY = 'OKAY';
41
42         /**
43          * Separator for all bootstrap node entries
44          */
45         const BOOTSTRAP_NODES_SEPARATOR = ';';
46
47         /**
48          * An instance of a node
49          */
50         private $nodeInstance = NULL;
51
52         /**
53          * A network package handler instance
54          */
55         private $packageInstance = NULL;
56
57         /**
58          * A Receivable instance
59          */
60         private $receiverInstance = NULL;
61
62         /**
63          * Listener pool instance
64          */
65         private $listenerPoolInstance = NULL;
66
67         /**
68          * Fragmenter instance
69          */
70         private $fragmenterInstance = NULL;
71
72         /**
73          * Assembler instance
74          */
75         private $assemblerInstance = NULL;
76
77         /**
78          * Info instance
79          */
80         private $infoInstance = NULL;
81
82         /**
83          * Protected constructor
84          *
85          * @param       $className      Name of the class
86          * @return      void
87          */
88         protected function __construct ($className) {
89                 // Call parent constructor
90                 parent::__construct($className);
91         }
92
93         /**
94          * Setter for network package handler instance
95          *
96          * @param       $packageInstance        The network package instance we shall set
97          * @return      void
98          */
99         protected final function setPackageInstance (Deliverable $packageInstance) {
100                 $this->packageInstance = $packageInstance;
101         }
102
103         /**
104          * Getter for network package handler instance
105          *
106          * @return      $packageInstance        The network package handler instance we shall set
107          */
108         protected final function getPackageInstance () {
109                 return $this->packageInstance;
110         }
111
112         /**
113          * Setter for receiver instance
114          *
115          * @param       $receiverInstance       A Receivable instance we shall set
116          * @return      void
117          */
118         protected final function setReceiverInstance (Receivable $receiverInstance) {
119                 $this->receiverInstance = $receiverInstance;
120         }
121
122         /**
123          * Getter for receiver instance
124          *
125          * @return      $receiverInstance       A Receivable instance we shall get
126          */
127         protected final function getReceiverInstance () {
128                 return $this->receiverInstance;
129         }
130
131         /**
132          * Setter for listener pool instance
133          *
134          * @param       $listenerPoolInstance   The new listener pool instance
135          * @return      void
136          */
137         protected final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) {
138                 $this->listenerPoolInstance = $listenerPoolInstance;
139         }
140
141         /**
142          * Getter for listener pool instance
143          *
144          * @return      $listenerPoolInstance   Our current listener pool instance
145          */
146         public final function getListenerPoolInstance () {
147                 return $this->listenerPoolInstance;
148         }
149
150         /**
151          * Setter for fragmenter instance
152          *
153          * @param       $fragmenterInstance             A Fragmentable instance
154          * @return      void
155          */
156         protected final function setFragmenterInstance (Fragmentable $fragmenterInstance) {
157                 $this->fragmenterInstance = $fragmenterInstance;
158         }
159
160         /**
161          * Getter for fragmenter instance
162          *
163          * @return      $fragmenterInstance             A Fragmentable instance
164          */
165         protected final function getFragmenterInstance () {
166                 return $this->fragmenterInstance;
167         }
168
169         /**
170          * Setter for assembler instance
171          *
172          * @param       $assemblerInstance      An instance of an Assembler class
173          * @return      void
174          */
175         protected final function setAssemblerInstance (Assembler $assemblerInstance) {
176                 $this->assemblerInstance = $assemblerInstance;
177         }
178
179         /**
180          * Getter for assembler instance
181          *
182          * @return      $assemblerInstance      An instance of an Assembler class
183          */
184         protected final function getAssemblerInstance () {
185                 return $this->assemblerInstance;
186         }
187
188         /**
189          * Setter for info instance
190          *
191          * @param       $infoInstance   A ShareableInfo instance
192          * @return      void
193          */
194         protected final function setInfoInstance (ShareableInfo $infoInstance) {
195                 $this->infoInstance = $infoInstance;
196         }
197
198         /**
199          * Getter for info instance
200          *
201          * @return      $infoInstance   An instance of a ShareableInfo class
202          */
203         public final function getInfoInstance () {
204                 return $this->infoInstance;
205         }
206
207         /**
208          * Setter for node id
209          *
210          * @param       $nodeId         The new node id
211          * @return      void
212          */
213         protected final function setNodeId ($nodeId) {
214                 // Set it config now
215                 $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId);
216         }
217
218         /**
219          * Getter for node id
220          *
221          * @return      $nodeId         Current node id
222          */
223         public final function getNodeId () {
224                 // Get it from config
225                 return $this->getConfigInstance()->getConfigEntry('node_id');
226         }
227
228         /**
229          * Setter for private key
230          *
231          * @param       $privateKey             The new private key
232          * @return      void
233          */
234         protected final function setPrivateKey ($privateKey) {
235                 // Set it config now
236                 $this->getConfigInstance()->setConfigEntry('private_key', (string) $privateKey);
237         }
238
239         /**
240          * Getter for private key
241          *
242          * @return      $privateKey             Current private key
243          */
244         public final function getPrivateKey () {
245                 // Get it from config
246                 return $this->getConfigInstance()->getConfigEntry('private_key');
247         }
248
249         /**
250          * Setter for private key hash
251          *
252          * @param       $privateKeyHash         The new private key hash
253          * @return      void
254          */
255         protected final function setPrivateKeyHash ($privateKeyHash) {
256                 // Set it config now
257                 $this->getConfigInstance()->setConfigEntry('private_key_hash', (string) $privateKeyHash);
258         }
259
260         /**
261          * Getter for private key hash
262          *
263          * @return      $privateKeyHash         Current private key hash
264          */
265         public final function getPrivateKeyHash () {
266                 // Get it from config
267                 return $this->getConfigInstance()->getConfigEntry('private_key_hash');
268         }
269
270         /**
271          * Setter for session id
272          *
273          * @param       $sessionId      The new session id
274          * @return      void
275          */
276         protected final function setSessionId ($sessionId) {
277                 $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId);
278         }
279
280         /**
281          * Getter for session id
282          *
283          * @return      $sessionId      Current session id
284          */
285         public final function getSessionId () {
286                 return $this->getConfigInstance()->getConfigEntry('session_id');
287         }
288 }
289
290 // [EOF]
291 ?>