Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl/signal_connector.cc @ 8316

Last change on this file since 8316 was 8316, checked in by bensch, 18 years ago

trunk: fixed most -Wall warnings… but there are still many missing :/

File size: 4.7 KB
RevLine 
[4744]1/*
[1853]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.
[1855]10
11   ### File Specific:
[7779]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[3955]16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
[1853]17
[7779]18#include "signal_connector.h"
[1853]19
[7779]20namespace OrxGui
[3365]21{
[4320]22
[8035]23  /**
24   * @brief creates a clean SignalConnector
25   */
[7855]26  SignalConnector::SignalConnector( )
27  {
28    this->object = NULL;
29    this->exec = NULL;
30  }
31
[8035]32  /**
33   * @brief Creates a SignalConnector out of an ObjectPointer, and an Executor.
34   * @param object the Object the Executor will apply to.
35   * @param executor the Executor that will be executed.
36   * @return a new SignalConnector.
37   */
[7779]38  SignalConnector::SignalConnector(BaseObject* object, const Executor* executor)
[7855]39  {
40    this->object = object;
41    this->exec = executor;
42  };
43
[8035]44  /**
45   * @brief Creates a SignalConnector as a copy of another one.
46   * @param signalConnector The SignalConnector to copy.
47   */
[7855]48  SignalConnector::SignalConnector(const SignalConnector& signalConnector)
49  {
50    this->object = signalConnector.object;
51    this->exec = (signalConnector.exec == NULL) ? NULL : signalConnector.exec->clone();
52  }
53
[8035]54  /**
55   * @brief deletes a SignalConnector.
56   *
57   * frees the stored executor
58   */
[7855]59  SignalConnector::~SignalConnector()
60  {
61    delete exec;
62  }
63
[8035]64  /**
65   * @brief assignes a SignalConnector to the current one
66   * @param signalConnector the SignalConnector to assign to this one
67   * @return A Reference to this SignalConnector.
68   */
[7855]69  SignalConnector& SignalConnector::operator=(const SignalConnector& signalConnector)
70  {
71    delete this->exec;
72    this->object = signalConnector.object;
73    this->exec = (signalConnector.exec == NULL) ? NULL : signalConnector.exec->clone();
[8316]74
75    return *this;
[7855]76  }
77
[8035]78
79  /**
80   * @brief compares two SignalConnectors.
81   * @param signalConnector the SignalConnector to compare against this one.
82   * @return true if the Connectors are the same.
83   */
84  bool SignalConnector::operator==(const SignalConnector& signalConnector) const
[7855]85  {
[8035]86    return (this->object == signalConnector.object /* && this->exec == signalConnector.exec */ );
87  }
88
89
90  /**
91   * @brief Executes the SignalConnector.
92   */
93  void SignalConnector::operator()() const
94  {
95    if (this->isValid())
[8271]96    {
97      static int count = 0;
98      (*this->exec)(this->object, count, NULL);
99    }
[8035]100  }
101
102  /**
103   * @brief Executes the SignalConnector.
104   * @param value0 First Value.
105   */
106  void SignalConnector::operator()(const MultiType& value0) const
107  {
[7855]108    if (exec != NULL && object != NULL)
[8271]109    {
110      static int count = 1;
111      (*this->exec)(this->object, count, (void*)&value0);
112    }
[7855]113  }
114
[8035]115  /**
116   * @brief Executes the SignalConnector.
117   * @param value0 First Value
118   * @param value1 Second Value
119   */
120  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1) const
121  {
122    if (exec != NULL && object != NULL)
123    {
[8271]124      static int count = 2;
[8035]125      MultiType mt[] = { value0, value1 };
[8271]126      (*this->exec)(this->object, count, mt);
[8035]127    }
128  }
129
130  /**
131   * @brief Executes the SignalConnector.
132   * @param value0 First Value
133   * @param value1 Second Value
134   * @param value2 Third Value
135   */
136  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2) const
137  {
138    if (exec != NULL && object != NULL)
139    {
[8271]140      static int count = 3;
[8035]141      MultiType mt[] = { value0, value1, value2 };
[8271]142      (*this->exec)(this->object, count, mt);
[8035]143    }
144  }
145
146  /**
147   * @brief Executes the SignalConnector.
148   * @param value0 First Value
149   * @param value1 Second Value
150   * @param value2 Third Value
151   * @param value3 Fourth Value
152   */
153  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3) const
154  {
155    if (exec != NULL && object != NULL)
156    {
[8271]157      static int count = 4;
[8035]158      MultiType mt[] = { value0, value1, value2, value3 };
[8271]159      (*this->exec)(this->object, count, mt);
[8035]160    }
161  }
162
163  /**
164   * @brief Executes the SignalConnector.
165   * @param value0 First Value
166   * @param value1 Second Value
167   * @param value2 Third Value
168   * @param value3 Fourth Value
169   * @param value3 Fifth Value
170   */
171  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3, const MultiType& value4) const
172  {
173    if (exec != NULL && object != NULL)
174    {
[8271]175      static int count = 5;
[8035]176      MultiType mt[] = { value0, value1, value2, value3, value4 };
[8271]177      (*this->exec)(this->object, count, mt);
[8035]178    }
179  }
[3365]180}
Note: See TracBrowser for help on using the repository browser.