Browse files

Added pure virtual function definitions and error handler to make com…

…mandline compile not complain
  • Loading branch information...
1 parent 423d260 commit 1f42cb15f9d869c3b6a761ed47f7cdddbb482de4 @lokling committed Dec 1, 2010
Showing with 10 additions and 6 deletions.
  1. +4 −0 AeroQuad.h
  2. +3 −3 Motors.h
  3. +3 −3 Receiver.h
View
4 AeroQuad.h
@@ -367,4 +367,8 @@ float findMode(float *data, int arraySize); // defined in Sensors.pde
int findMode(int *data, int arraySize); // defined in Sensors.pde
#endif
+// Error handling of virtual functions of Receiver and Motors base classes
+extern "C" void __cxa_pure_virtual() { Serial.print("ERROR: Virtual function called! "); }
+
+
View
6 Motors.h
@@ -64,9 +64,9 @@ class Motors {
};
// The following function calls must be defined in any new subclasses
- virtual void initialize(void);
- virtual void write (void);
- virtual void commandAllMotors(int motorCommand);
+ virtual void initialize(void) = 0;
+ virtual void write (void) = 0;
+ virtual void commandAllMotors(int motorCommand) = 0;
//Any number of optional methods can be configured as needed by the SubSystem to expose functionality externally
void pulseMotors(byte quantity) {
View
6 Receiver.h
@@ -33,7 +33,7 @@ class Receiver {
float bTransmitter[6];
unsigned long currentTime, previousTime;
- Receiver(void) {
+ Receiver(void) {
transmitterCommand[ROLL] = 1500;
transmitterCommand[PITCH] = 1500;
transmitterCommand[YAW] = 1500;
@@ -50,8 +50,8 @@ class Receiver {
// ******************************************************************
// The following function calls must be defined in any new subclasses
// ******************************************************************
- virtual void initialize(void);
- virtual void read(void);
+ virtual void initialize(void) = 0;
+ virtual void read(void) = 0;
// **************************************************************
// The following functions are common between all Gyro subclasses

0 comments on commit 1f42cb1

Please sign in to comment.