00001 #ifndef ArrayInputNeuron_H_
00002 #define ArrayInputNeuron_H_
00003
00004 #include "EvSimObject.h"
00005 #include "EvSimObjectTypeUtils.h"
00006 #include "SharedArray.h"
00007 #include "DirectEventSender.h"
00008
00009 #include <vector>
00010 using std::vector;
00011
00012 class ArrayInputNeuron : public EvSimObject, public DirectEventSender
00013 {
00014
00015 EV_SIM_OBJECT( ArrayInputNeuron )
00016
00017 public:
00018
00019 ArrayInputNeuron(const std::vector<double> &input_events = vector<Time>()) :
00020 input_events(new vector<Time>(input_events)) {
00021 checkValidInputEvents(*this->input_events);
00022 }
00023
00024 ArrayInputNeuron(const EventTimesVector & input_events) :
00025 input_events(input_events) {
00026 if (input_events != 0) {
00027 checkValidInputEvents(*input_events);
00028 }
00029 }
00030
00031 virtual ~ArrayInputNeuron() {};
00032
00033 virtual void eventHit(SimContext & sim_info, Time time, port_id_t port);
00034
00035 virtual void updateState(SimContext &sim_info, Time time, update_id_t upd_id) {};
00036
00037 void setInputEvents(const EventTimesVector &input_events) {
00038 checkValidInputEvents(*input_events);
00039 this->input_events = input_events;
00040 }
00041
00042 void setInputEvents(const std::vector<Time> &input_events) {
00043 checkValidInputEvents(input_events);
00044 this->input_events = EventTimesVector(new vector<Time>(input_events));
00045 }
00046
00047 const EventTimesVector &getEventArray2() const {
00048 return input_events;
00049 }
00050
00051 const std::vector<double> &getEventArray() const {
00052 return *input_events;
00053 }
00054
00055 virtual unsigned numOutputPorts() const
00056 {
00057 return 1;
00058 };
00059
00060 virtual PortType getOutputPortType(port_id_t p) const
00061 {
00062 if (p == 0)
00063 return eventPortDirect;
00064 return portUndefined;
00065 };
00066
00067 virtual void reset(SimContext &sim_ctxt);
00068
00069 virtual void postAddedInNetwork(EvSimNetwork &net, EvSimObject::ID self);
00070
00071 protected:
00072 void checkValidInputEvents(const vector<Time> &inp_events);
00073
00074 EventTimesVector input_events;
00075
00076 unsigned curr_event_idx;
00077 };
00078
00079
00080
00081 #endif