Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5647 in orxonox.OLD for branches/network


Ignore:
Timestamp:
Nov 20, 2005, 12:25:50 AM (19 years ago)
Author:
patrick
Message:

network: modiefied the unit test to enable diffrent modes, extended the NetworkStream constructors interface and NetworkManager interface

Location:
branches/network/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/collision_detection/lin_alg.h

    r5493 r5647  
    55    compute the eigenpairs (eigenvalues and eigenvectors) of a real symmetric matrix "A" by the Jacobi method
    66 */
     7
     8
     9/**
     10 *  function that calculates the eigenvectors from a given symmertical 3x3 Matrix
     11 * @arg A: Matrix
     12 * @arg D: Eigenvectors
     13 */
     14void eigenVectors(float** matrix, float **vectors)
     15{
     16  /* map variables to other names, so they can be processed more easely */
     17  float a = matrix[0][0];
     18  float b = matrix[0][1];
     19  float c = matrix[0][2];
     20  float d = matrix[1][1];
     21  float e = matrix[1][2];
     22  float f = matrix[2][2];
     23 
     24  /* first eigenvector */
     25  vectors[0][0] = -1/c * (f - /*Root*/ (c*c*d - 2*b*c + a*e*e + b*b*f - a*d*f -
     26                  b*b - c*c + a*d - e*e + a*f ));
     27}
    728
    829
  • branches/network/src/lib/network/network_manager.cc

    r5609 r5647  
    3131#include "network_manager.h"
    3232
    33 /* include this file, it contains some default definitions */
    34 #include "netdefs.h"
    3533
    3634/* using namespace std is default, this needs to be here */
     
    116114/**
    117115 *  creates a connection from one object to a host
     116 * @param hostName: the name of the destination host
     117 * @param synchronizeable: reference to the sync object
     118 */
     119NetworkStream& establishConnection(const char& hostName, const Synchronizeable& sync)
     120{}
     121
     122
     123/**
     124 *  creates a connection from one object to a host
    118125 * @param address: the address of the destination host
    119126 * @param synchronizeable: reference to the sync object
    120127 */
    121 NetworkStream& NetworkManager::establishConnection(/* address, port, object reference*/)
     128NetworkStream& NetworkManager::establishConnection(const IPaddress& address, const Synchronizeable& sync)
    122129{
    123130  PRINTF(0)("Establish connection...\n");
    124131  /* creating a new network stream, it will register itself automaticaly to the class list */
    125   NetworkStream* netStream = new NetworkStream();
     132//  NetworkStream* netStream = new NetworkStream();
    126133}
    127134
  • branches/network/src/lib/network/network_manager.h

    r5575 r5647  
    99#define _NETWORK_MANAGER
    1010
     11/* include this file, it contains some default definitions */
     12#include "netdefs.h"
    1113
    1214/* include base_object.h since all classes are derived from this one */
    1315#include "base_object.h"
     16
    1417
    1518/* forward declarations for the header file (include the header via #include "bla.h" in the source file) */
     
    3033  void shutdown();
    3134 
    32   NetworkStream& establishConnection(/* address, port, object reference*/);
     35  NetworkStream& establishConnection(const IPaddress& address, const Synchronizeable& sync);
     36  NetworkStream& establishConnection(const char& hostName, const Synchronizeable& sync);
    3337  void shutdownConnection();
    3438 
  • branches/network/src/lib/network/network_stream.cc

    r5615 r5647  
    2121
    2222
     23#include "base_object.h"
     24//#include "network_protocol.h"
     25#include "network_socket.h"
     26#include "connection_monitor.h"
     27#include "synchronizeable.h"
     28#include "list.h"
     29
     30
    2331/* include your own header */
    2432#include "network_stream.h"
     
    2836
    2937
     38NetworkStream::NetworkStream(DataStream& inStream, DataStream& outStream)
     39  : DataStream(inStream, outStream)
     40{
     41  this->init();
     42}
     43
     44NetworkStream::NetworkStream(Synchronizeable& sync, NetworkSocket& socket)
     45  : DataStream(sync, socket)
     46{
     47  this->init();
     48}
     49
     50NetworkStream::NetworkStream(DataStream& inStream, NetworkSocket& socket)
     51  : DataStream(inStream, socket)
     52{
     53  this->init();
     54}
     55
     56NetworkStream::NetworkStream(Synchronizeable& sync, DataStream& outStream)
     57  : DataStream(sync, outStream)
     58{
     59  this->init();
     60}
     61
    3062NetworkStream::NetworkStream()
     63{
     64  this->init();
     65  /* initialize the references */
     66  this->networkSocket = new NetworkSocket();
     67  this->synchronizeables = new Synchronizeable();
     68  this->connectionMonitor = new ConnectionMonitor();
     69}
     70
     71
     72void NetworkStream::init()
    3173{
    3274  /* set the class id for the base object */
    3375  this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
     76}
    3477
    35   /* initialize the references */
    36   this->networkSockets = new NetworkSocket();
    37   this->synchronizeables = new Synchronizeable();
    38   this->connectionMonitor = new ConnectionMonitor();
    39 
    40  
    41 
    42 }
    4378
    4479NetworkStream::~NetworkStream()
  • branches/network/src/lib/network/network_stream.h

    r5610 r5647  
    77#define _NETWORK_STREAM
    88
    9 #include "base_object.h"
    109#include "data_stream.h"
    11 //#include "network_protocol.h"
    12 #include "network_socket.h"
    13 #include "connection_monitor.h"
    14 #include "synchronizeable.h"
    15 #include "list.h"
    1610
     11class Synchronizeable;
     12class NetworkSocket;
     13class ConnectionMonitor;
    1714
    1815class NetworkStream : public virtual DataStream
     
    2118public:
    2219  NetworkStream();
     20  NetworkStream(DataStream& inStream, DataStream& outStream);
     21  NetworkStream(Synchronizeable& sync, NetworkSocket& socket);
     22  NetworkStream(DataStream& inStream, NetworkSocket& socket);
     23  NetworkStream(Synchronizeable& sync, DataStream& outStream);
     24 
    2325  ~NetworkStream();
    24    virtual void processData();
     26   
     27  void init();
     28 
     29  virtual void processData();
    2530
    2631private:
  • branches/network/src/subprojects/network/network_unit_test.cc

    r5630 r5647  
    88#include "network_manager.h"
    99#include "network_socket.h"
     10#include "synchronizeable.h"
    1011
    1112int verbose = 4;
    1213
    1314
     15/* outputs the help */
    1416int startHelp(int argc, char** argv)
    1517{
     
    1719  printf(" --help:           this output\n");
    1820  printf(" --sockettest      test network_socket\n");
     21  printf(" --frameworktest   test the network module\n");
    1922  printf("\n");
    2023}
    2124
     25
     26/* test SDL network socket */
    2227int testSocket(int argc, char** argv)
    2328{
     
    107112}
    108113
     114
     115int testFramework(int argc, char** argv)
     116{
     117  printf("=================\n");
     118  printf("TestFramework\n");
     119  printf("=================\n");
     120 
     121  IPaddress ip;
     122  //SDLNet_ResolveHost(&ip, "127.0.0.1", 9999);
     123  SDLNet_ResolveHost(&ip, "localhost", 9999);
     124  Synchronizeable sync;
     125 
     126  /* create the network manager */
     127  NetworkManager* nm = new NetworkManager();
     128
     129  /* initialize the network manager */
     130  nm->initialize();
     131
     132  /* esatblish a connection */
     133  nm->establishConnection(ip, sync);
     134 
     135  /* delete the network manager again */
     136  delete nm;
     137 
     138  return 0;
     139}
     140
     141
    109142/**
    110143 *
     
    119152  for(i = 1; i < argc; ++i)
    120153  {
    121     if(! strcmp( "--help", argv[i]) || !strcmp("-h", argv[i])) return startHelp(argc, argv);
    122154    //else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) showGui = true;
    123     else if (! strcmp( "--sockettest", argv[i]) || !strcmp("-s", argv[i])) return testSocket(argc, argv);
     155    if (! strcmp( "--sockettest", argv[i]) || !strcmp("-s", argv[i])) return testSocket(argc, argv);
     156    else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-s", argv[i])) return testFramework(argc, argv);
    124157  }
    125158
    126   /* create the network manager */
    127   NetworkManager* nm = new NetworkManager();
    128 
    129   /* initialize the network manager */
    130   nm->initialize();
    131 
    132   /* esatblish a connection */
    133   nm->establishConnection();
    134 
    135   //ClassList::debug(3, 0);
    136 
     159  startHelp(argc, argv);
     160 
    137161  return 0;
    138162}
Note: See TracChangeset for help on using the changeset viewer.