PySimObjectStub.h

Go to the documentation of this file.
00001 #ifndef PySimObjectStub_H_
00002 #define PySimObjectStub_H_
00003 
00004 #include "pcsim_hash.h"
00005 
00006 #include <utility>
00007 using   std::pair;
00008 using std::make_pair;
00009 
00010 #include <boost/format.hpp>
00011 using boost::format;
00012 
00013 #include "SimObject.h"
00014 #include "SpikeSender.h"
00015 #include "PCSIMException.h"
00016 
00017 class PySimObjectStub : public SimObject, public MultipleOutputSpikeSender
00018 {
00019     SIMOBJECT( PySimObjectStub , AdvancePhase::One )
00020 
00021 public:
00022     typedef hash_map< size_t, SimObject::PortType, PCSIM::hash<size_t> > port_list_t;
00023 
00024     PySimObjectStub() :
00025             n_analog_input_ports(0),
00026             n_analog_output_ports(0),
00027             n_spiking_input_ports(0),
00028             n_spiking_output_ports(0)
00029     {
00030         
00031     }
00032     ;
00033 
00034     virtual ~PySimObjectStub()
00035     {}
00036     ;
00037 
00038     virtual void defineOutputPort(port_t p, SimObject::PortType port_type)
00039     {
00040         pair< port_list_t::iterator, bool > r = output_ports.insert(make_pair(p, port_type));
00041         r.first->second = port_type;
00042         if (r.second) {
00043             if (port_type == spiking) {
00044                 n_spiking_output_ports ++;
00045                 defineSpikeOutputPort(p);
00046             } else if (port_type == analog)
00047                 n_analog_output_ports ++;
00048         }
00049     }
00050 
00051     virtual void defineInputPort(port_t p, SimObject::PortType port_type)
00052     {
00053         pair< port_list_t::iterator, bool > r = input_ports.insert(make_pair(p, port_type));
00054         r.first->second = port_type;
00055         if (r.second) {
00056             if (port_type == spiking)
00057                 n_spiking_input_ports ++;
00058             else if (port_type == analog)
00059                 n_analog_input_ports ++;
00060         }
00061     }
00062 
00063     virtual int nSpikeInputPorts() const
00064     {
00065         return n_spiking_input_ports;
00066     };
00067 
00068     virtual int nSpikeOutputPorts() const
00069     {
00070         return n_spiking_output_ports;
00071     };
00072 
00073     virtual int nAnalogInputPorts() const
00074     {
00075         return n_analog_input_ports;
00076     };
00077 
00078     virtual int nAnalogOutputPorts() const
00079     {
00080         return n_analog_output_ports;
00081     };
00082 
00083     virtual SimObject::PortType outputPortType(port_t p) const
00084     {
00085         port_list_t::const_iterator it;
00086         if ((it = output_ports.find(p)) != output_ports.end())
00087             return it->second;
00088         else
00089             return undefined;
00090     };
00091 
00092     virtual SimObject::PortType inputPortType(port_t p) const
00093     {
00094         port_list_t::const_iterator it;
00095         if ((it = input_ports.find(p)) != input_ports.end())
00096             return it->second;
00097         else
00098             return undefined;
00099     };
00100 
00102     virtual int reset( double dt )
00103     {
00104         return 0;
00105     };
00106 
00108 
00111     virtual int advance( AdvanceInfo const& )
00112     {
00113         return 0;
00114     };
00115 
00118 
00125     virtual int spikeHit( spikeport_t port, SpikeEvent const& spike )
00126     {
00127         return 0;
00128     };
00129 
00130     //@
00131 
00132     //
00134 
00135 
00137     virtual int init(InitializeInfo *ii)
00138     {
00139         return 0;
00140     };
00141 
00143     virtual int check(void)
00144     {
00145         return 0;
00146     };
00147 
00149     /* \param dt The simulation time step with in seconds.
00150     */
00151     virtual int adjust( double dt )
00152     {
00153         return 0;
00154     };
00155     
00157     /* This function should return the amount of delay for incoming spike
00158     * messages which the SimObject wants to be handled by the global spike
00159     * exchange mechanism.
00160     */
00161     virtual double getManagedDelay() const
00162     {
00163         return 0;
00164     }
00165 
00167 
00168     //
00170 
00171 
00173     virtual double getAnalogOutput(analog_port_id_t port = 0) const
00174     {
00175         return 0;
00176     };
00177 
00179     virtual void setAnalogInput(double value, analog_port_id_t port = 0)
00180     {
00181         NOOP
00182     };
00183     
00184     virtual bool owned_by_net()
00185     {
00186       return false;     
00187     }
00188     
00190 
00191     void setSpike(port_t p, AdvanceInfo &ai )
00192     {
00193         getSpikePort(p)->setSpike( ai );
00194     };
00195 
00196 protected:
00197 
00198     port_list_t output_ports;
00199     port_list_t input_ports;
00200 
00201     int n_analog_input_ports;
00202     int n_analog_output_ports;
00203     int n_spiking_input_ports;
00204     int n_spiking_output_ports;
00205 
00206 };
00207 
00208 #endif /*PySimObjectStub_H_*/

Generated on Wed Jul 9 16:34:39 2008 for PCSIM by  doxygen 1.5.5