I have class eventqueue_t which is derived from the abstract class event_storage_t. When I compile the code I get:
make
mpixlcxx -c -O3 brain.cpp
mpixlcxx -c -O3 config.cpp
mpixlcxx -c -O3 connection.cpp
"eventqueue.h", line 17.29: 1540-0408 (S) The base class "event_storage_t" is declared but not defined.
make: *** [connection.o] Error 1
The connection_t class has a event_storage_t pointer. I am surprised see the compiler is referencing "eventqueue.h" when compiling connection.cpp even though eventqueue_t is derived from event_storage_t.
Below you will find (hopefully) all the pertinent code. Please let me know if you can see anything that might be causing the above error.
Note: I could not get the
to work
connection.h
#ifndef _CONNECTION_H_
#define _CONNECTION_H_
#include <vector>
// Forward declarations
class neuron_t;
class event_storage_t;
// Connection
class connection_t
{
public:
// Constructor
connection_t();
void init(unsigned int _delay, int _dest_neuron, short pulse_strength,
event_storage_t *_eventqueue_p);
// Actions
void propagate(short duration);
public:
unsigned int delay;
int dest_neuron;
event_storage_t *eventqueue_p;
private:
short pulse_strength;
};
#endif // _CONNECTION_H_
connection.cpp
#include <iostream>
#include "config.h"
#include "neuron.h"
#include "connection.h"
#include "event_storage.h"
connection_t::connection_t()
{
}
void connection_t::init(unsigned int _delay,
int _dest_neuron, short _pulse_strength,
event_storage_t *_eventqueue_p)
{
delay = _delay;
dest_neuron = _dest_neuron;
eventqueue_p = _eventqueue_p;
pulse_strength = _pulse_strength;
}
void connection_t::propagate(short duration)
{
event_t signal(dest_neuron, pulse_strength, duration);
eventqueue_p->push_event(signal, delay);
}
eventqueue.h
#ifndef _EVENTQUEUE_H_
#define _EVENTQUEUE_H_
#include <vector>
#include <list>
#undef SEEK_SET
#undef SEEK_END
#undef SEEK_CUR
#include <mpi.h>
#include "event_storage.h"
#include "neuron.h"
#define MAX_EVENT_COUNT 100000
// Base event queue class
class eventqueue_t : public event_storage_t
{
protected:
typedef std::vector<event_t> moment_t;
typedef std::vector<moment_t*> events_t;
public:
// Constructor/Destructor
eventqueue_t(unsigned int size);
virtual ~eventqueue_t();
// Pushing events on the queue
void push_event(const event_t &signal, unsigned int delay);
virtual void execute_moment(unsigned long step) = 0;
void update_moment();
unsigned int get_future_events_count();
unsigned int get_current_events_count();
unsigned int get_capacity();
public:
unsigned int queue_size;
protected:
events_t event_queue;
unsigned int current_event_index;
unsigned int current_events_count;
unsigned int future_events_count;
};
#endif // _EVENTQUEUE_H_
eventqueue.cpp
#include <iostream>
#include "eventqueue.h"
#include "simulation.h"
#include "config.h"
using namespace std;
eventqueue_t::eventqueue_t(unsigned int size) : event_storage_t()
{
event_queue.resize(size, NULL);
// Initialize the queue
int i;
for(i = 0; i < size; i++) {
moment_t *moment_p = new moment_t();
// reserve some events to speed things up
moment_p->reserve(config_t::self_p->queue_reserve_size);
event_queue[i] = moment_p;
}
queue_size = size;
current_event_index = 0;
current_events_count = 0;
future_events_count = 0;
}
eventqueue_t::~eventqueue_t()
{
// Go through the moments
for(events_t::iterator i = event_queue.begin(); i != event_queue.end(); i++)
{
// Delete the moment
delete *i;
}
}
void eventqueue_t::push_event(const event_t &signal, unsigned int delay)
{
event_queue[(current_event_index + delay) % queue_size]
->push_back(signal);
future_events_count++;
}
void eventqueue_t::update_moment()
{
current_event_index = (current_event_index + 1) % queue_size;
}
unsigned int eventqueue_t::get_future_events_count()
{
return future_events_count;
}
unsigned int eventqueue_t::get_current_events_count()
{
return current_events_count;
}
unsigned int eventqueue_t::get_capacity()
{
int capacity = 0;
int cycle_index;
for(cycle_index = 0; cycle_index < queue_size; cycle_index++) {
capacity += event_queue[cycle_index]->capacity();
}
return capacity;
}
event_storage.h
#ifndef _EVENT_STORAGE_H_
#define _EVENT_STORAGE_H_
#include "eventqueue.h"
// An event
class event_t
{
public:
event_t();
event_t(int _dest_neuron, short _potential, short _duration);
public:
int dest_neuron;
short potential;
short duration; // values < 0 induce a the dest_neuron to force fire
};
class event_storage_t
{
public:
event_storage_t();
virtual ~event_storage_t();
// Pushing events on the queue
virtual void push_event(const event_t &signal, unsigned int delay) = 0;
// virtual void execute_moment(unsigned long step) = 0;
// virtual void update_moment() = 0;
virtual unsigned int get_future_events_count() = 0;
virtual unsigned int get_current_events_count() = 0;
virtual unsigned int get_capacity() = 0;
private:
unsigned int future_count;
};
#endif // _EVENT_STORAGE_H_
event_storage.cpp
#include <iostream>
#include "event_storage.h"
event_t::event_t()
{
}
event_t::event_t(int _dest_neuron, short _potential, short _duration)
: dest_neuron(_dest_neuron), potential(_potential), duration(_duration)
{
}
event_storage_t::event_storage_t()
{
future_count = 0;
}
event_storage_t::~event_storage_t()
{
}
unsigned int event_storage_t::get_future_events_count()
{
return future_count;
}
makefile
TARGET = brain
OBJS = brain.o config.o connection.o event_storage.o eventqueue.o eventqueue_local.o \
eventqueue_remote.o main.o neuron.o simulation.o EasyBMP.o
CXX = mpixlcxx
CFLAGS = -O3
LDFLAGS =
$(TARGET): $(OBJS) combine
$(CXX) $(OBJS) -o $(TARGET) $(LDFLAGS)
combine: combine.o EasyBMP.o
$(CXX) combine.o EasyBMP.o -o combine
.SUFFIXES:
.SUFFIXES: .o .cpp .h
.cpp.o:
$(CXX) -c $(CFLAGS) $*.cpp
.h.o:
$(CXX) -c $(CFLAGS) $*.cpp
brain.cpp: brain.h config.h simulation.h neuron.h connection.h eventqueue_local.h eventqueue_remote.h
config.cpp: config.h
connection.cpp: connection.h config.h neuron.h event_storage.h
event_storage.cpp: event_storage.h
eventqueue.cpp: eventqueue.h event_storage.h neuron.h simulation.h config.h
eventqueue_local.cpp: eventqueue_local.h eventqueue.h neuron.h simulation.h config.h
eventqueue_remote.cpp: eventqueue_remote.h eventqueue.h config.h
main.cpp: brain.h simulation.h config.h
neuron.cpp: neuron.h connection.h config.h eventqueue.h
simulation.cpp: simulation.h brain.h config.h connection.h EasyBMP.o
brain.o: brain.cpp
config.o: config.cpp
connection.o: connection.cpp
event_storage.o: event_storage.cpp
eventqueue.o: eventqueue.cpp
eventqueue_local.o: eventqueue_local.cpp
eventqueue_remote.o: eventqueue_remote.cpp
main.o: main.cpp
neuron.o: neuron.cpp
simulation.o: simulation.cpp
# combine utility
#combine.cpp:
# third party bmp library
EasyBMP.o: easy_bmp/EasyBMP.cpp
$(CXX) -c $(CFLAGS) easy_bmp/EasyBMP.cpp -o EasyBMP.o
# Cleaning
clean:
rm -f *.o $(TARGET) combine output/* easy_bmp/*.o *~