Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/gui/gl/signal_connector.cc @ 9357

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

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

File size: 4.7 KB
Line 
1/*
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: Benjamin Grauer
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
17
18#include "signal_connector.h"
19
20namespace OrxGui
21{
22
23  /**
24   * @brief creates a clean SignalConnector
25   */
26  SignalConnector::SignalConnector( )
27  {
28    this->object = NULL;
29    this->exec = NULL;
30  }
31
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   */
38  SignalConnector::SignalConnector(BaseObject* object, const Executor* executor)
39  {
40    this->object = object;
41    this->exec = executor;
42  };
43
44  /**
45   * @brief Creates a SignalConnector as a copy of another one.
46   * @param signalConnector The SignalConnector to copy.
47   */
48  SignalConnector::SignalConnector(const SignalConnector& signalConnector)
49  {
50    this->object = signalConnector.object;
51    this->exec = (signalConnector.exec == NULL) ? NULL : signalConnector.exec->clone();
52  }
53
54  /**
55   * @brief deletes a SignalConnector.
56   *
57   * frees the stored executor
58   */
59  SignalConnector::~SignalConnector()
60  {
61    delete exec;
62  }
63
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   */
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();
74
75    return *this;
76  }
77
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
85  {
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())
96    {
97      static int count = 0;
98      (*this->exec)(this->object, count, NULL);
99    }
100  }
101
102  /**
103   * @brief Executes the SignalConnector.
104   * @param value0 First Value.
105   */
106  void SignalConnector::operator()(const MultiType& value0) const
107  {
108    if (exec != NULL && object != NULL)
109    {
110      static int count = 1;
111      (*this->exec)(this->object, count, (void*)&value0);
112    }
113  }
114
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    {
124      static int count = 2;
125      MultiType mt[] = { value0, value1 };
126      (*this->exec)(this->object, count, mt);
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    {
140      static int count = 3;
141      MultiType mt[] = { value0, value1, value2 };
142      (*this->exec)(this->object, count, mt);
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    {
157      static int count = 4;
158      MultiType mt[] = { value0, value1, value2, value3 };
159      (*this->exec)(this->object, count, mt);
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    {
175      static int count = 5;
176      MultiType mt[] = { value0, value1, value2, value3, value4 };
177      (*this->exec)(this->object, count, mt);
178    }
179  }
180}
Note: See TracBrowser for help on using the repository browser.