Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8304 was 8271, checked in by bensch, 19 years ago

merge

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
76
77  /**
78   * @brief compares two SignalConnectors.
79   * @param signalConnector the SignalConnector to compare against this one.
80   * @return true if the Connectors are the same.
81   */
82  bool SignalConnector::operator==(const SignalConnector& signalConnector) const
83  {
84    return (this->object == signalConnector.object /* && this->exec == signalConnector.exec */ );
85  }
86
87
88  /**
89   * @brief Executes the SignalConnector.
90   */
91  void SignalConnector::operator()() const
92  {
93    if (this->isValid())
94    {
95      static int count = 0;
96      (*this->exec)(this->object, count, NULL);
97    }
98  }
99
100  /**
101   * @brief Executes the SignalConnector.
102   * @param value0 First Value.
103   */
104  void SignalConnector::operator()(const MultiType& value0) const
105  {
106    if (exec != NULL && object != NULL)
107    {
108      static int count = 1;
109      (*this->exec)(this->object, count, (void*)&value0);
110    }
111  }
112
113  /**
114   * @brief Executes the SignalConnector.
115   * @param value0 First Value
116   * @param value1 Second Value
117   */
118  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1) const
119  {
120    if (exec != NULL && object != NULL)
121    {
122      static int count = 2;
123      MultiType mt[] = { value0, value1 };
124      (*this->exec)(this->object, count, mt);
125    }
126  }
127
128  /**
129   * @brief Executes the SignalConnector.
130   * @param value0 First Value
131   * @param value1 Second Value
132   * @param value2 Third Value
133   */
134  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2) const
135  {
136    if (exec != NULL && object != NULL)
137    {
138      static int count = 3;
139      MultiType mt[] = { value0, value1, value2 };
140      (*this->exec)(this->object, count, mt);
141    }
142  }
143
144  /**
145   * @brief Executes the SignalConnector.
146   * @param value0 First Value
147   * @param value1 Second Value
148   * @param value2 Third Value
149   * @param value3 Fourth Value
150   */
151  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3) const
152  {
153    if (exec != NULL && object != NULL)
154    {
155      static int count = 4;
156      MultiType mt[] = { value0, value1, value2, value3 };
157      (*this->exec)(this->object, count, mt);
158    }
159  }
160
161  /**
162   * @brief Executes the SignalConnector.
163   * @param value0 First Value
164   * @param value1 Second Value
165   * @param value2 Third Value
166   * @param value3 Fourth Value
167   * @param value3 Fifth Value
168   */
169  void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3, const MultiType& value4) const
170  {
171    if (exec != NULL && object != NULL)
172    {
173      static int count = 5;
174      MultiType mt[] = { value0, value1, value2, value3, value4 };
175      (*this->exec)(this->object, count, mt);
176    }
177  }
178}
Note: See TracBrowser for help on using the repository browser.