[5530] | 1 | /* |
---|
[5520] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Patrick Boenzli |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | |
---|
[5525] | 17 | /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module |
---|
[5530] | 18 | For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput |
---|
[5525] | 19 | */ |
---|
[5530] | 20 | #define DEBUG_MODULE_NETWORK |
---|
[5525] | 21 | |
---|
| 22 | |
---|
[5566] | 23 | #include "network_stream.h" |
---|
| 24 | #include "list.h" |
---|
[5572] | 25 | #include "class_list.h" |
---|
[5566] | 26 | |
---|
[5605] | 27 | #include "debug.h" |
---|
[5566] | 28 | |
---|
[5605] | 29 | |
---|
[5525] | 30 | /* include your own header */ |
---|
[5520] | 31 | #include "network_manager.h" |
---|
| 32 | |
---|
[5530] | 33 | /* include this file, it contains some default definitions */ |
---|
| 34 | #include "netdefs.h" |
---|
| 35 | |
---|
[5525] | 36 | /* using namespace std is default, this needs to be here */ |
---|
[5520] | 37 | using namespace std; |
---|
| 38 | |
---|
| 39 | |
---|
[5525] | 40 | /************************************ |
---|
| 41 | What you will see here are the function definitions from the header file (network_manager.h) with doxygen documentation. Here is an example: |
---|
[5520] | 42 | |
---|
[5530] | 43 | |
---|
| 44 | In file network_manager.h |
---|
| 45 | |
---|
[5525] | 46 | class NetworkManager |
---|
| 47 | { |
---|
| 48 | int doSomeStuff(float argument, float* pointer); |
---|
[5530] | 49 | } |
---|
[5520] | 50 | |
---|
[5525] | 51 | will be implemented in the source file as follows: |
---|
| 52 | |
---|
| 53 | In file network_manager.cc |
---|
| 54 | |
---|
| 55 | / ** |
---|
| 56 | * this is the short description for this function: it just does some stuff |
---|
| 57 | * @param argument: this is the first argument, stuff... |
---|
[5530] | 58 | * @param pointer: this is the pointer to nowhereland |
---|
| 59 | * return: whatever the function returns: for example an index, number, etc. |
---|
| 60 | * / |
---|
[5525] | 61 | int NetworkManager::doSomeStuff(float argument, float* pointer) |
---|
| 62 | { |
---|
[5530] | 63 | // whaterver you want to do |
---|
| 64 | } |
---|
[5525] | 65 | |
---|
[5530] | 66 | |
---|
[5525] | 67 | if you want to make automake compile your files: you will want to add the file names to the local Makefile.am |
---|
[5530] | 68 | |
---|
[5525] | 69 | ************************************/ |
---|
| 70 | |
---|
[5530] | 71 | |
---|
[5605] | 72 | |
---|
[5520] | 73 | /** |
---|
| 74 | * standard constructor |
---|
| 75 | */ |
---|
| 76 | NetworkManager::NetworkManager() |
---|
[5566] | 77 | { |
---|
[5572] | 78 | /* set the class id for the base object */ |
---|
[5575] | 79 | this->setClassID(CL_NETWORK_MANAGER, "NetworkManager"); |
---|
[5578] | 80 | |
---|
[5572] | 81 | /* initialize the references */ |
---|
| 82 | this->netStreamList = NULL; |
---|
| 83 | this->syncList = NULL; |
---|
[5605] | 84 | |
---|
| 85 | PRINTF(0)("NetworkManager created\n"); |
---|
[5566] | 86 | } |
---|
[5520] | 87 | |
---|
| 88 | |
---|
| 89 | /** |
---|
| 90 | * standard deconstructor |
---|
| 91 | */ |
---|
| 92 | NetworkManager::~NetworkManager() |
---|
| 93 | {} |
---|
| 94 | |
---|
[5522] | 95 | |
---|
| 96 | /** |
---|
| 97 | * initializes the network manager |
---|
| 98 | */ |
---|
| 99 | void NetworkManager::initialize() |
---|
[5572] | 100 | { |
---|
| 101 | /* get the synchronizeable list from the class list */ |
---|
[5575] | 102 | this->netStreamList = ClassList::getList(CL_SYNCHRONIZEABLE); |
---|
[5605] | 103 | PRINTF(0)("NetworkManager initzalized\n"); |
---|
[5572] | 104 | } |
---|
[5522] | 105 | |
---|
[5530] | 106 | |
---|
[5522] | 107 | /** |
---|
| 108 | * shutsdown the network manager |
---|
| 109 | */ |
---|
| 110 | void NetworkManager::shutdown() |
---|
[5578] | 111 | { |
---|
[5522] | 112 | |
---|
[5578] | 113 | } |
---|
[5522] | 114 | |
---|
[5578] | 115 | |
---|
[5522] | 116 | /** |
---|
| 117 | * creates a connection from one object to a host |
---|
| 118 | * @param address: the address of the destination host |
---|
| 119 | * @param synchronizeable: reference to the sync object |
---|
| 120 | */ |
---|
[5572] | 121 | NetworkStream& NetworkManager::establishConnection(/* address, port, object reference*/) |
---|
| 122 | { |
---|
[5609] | 123 | PRINTF(0)("Establish connection...\n"); |
---|
[5578] | 124 | /* creating a new network stream, it will register itself automaticaly to the class list */ |
---|
[5572] | 125 | NetworkStream* netStream = new NetworkStream(); |
---|
| 126 | } |
---|
[5522] | 127 | |
---|
| 128 | |
---|
| 129 | /** |
---|
| 130 | * teardown a connection |
---|
| 131 | */ |
---|
| 132 | void NetworkManager::shutdownConnection() |
---|
[5605] | 133 | { |
---|
| 134 | PRINTF(0)("Shutdown connection\n"); |
---|
| 135 | } |
---|
[5522] | 136 | |
---|
[5530] | 137 | |
---|
[5522] | 138 | |
---|
| 139 | /** |
---|
| 140 | * sync the network |
---|
| 141 | */ |
---|
| 142 | void NetworkManager::synchronize() |
---|
[5578] | 143 | { |
---|
[5605] | 144 | PRINTF(0)("NetworkManager synchronizes\n"); |
---|
[5578] | 145 | if (this->netStreamList != NULL || (this->netStreamList = ClassList::getList(CL_NETWORK_STREAM)) != NULL) |
---|
| 146 | { |
---|
| 147 | |
---|
| 148 | } |
---|
[5522] | 149 | |
---|
[5578] | 150 | } |
---|
[5522] | 151 | |
---|
[5578] | 152 | |
---|