00001 #ifndef _LAYER_H 00002 #define _LAYER_H 00003 00004 #include "Neuron.h" 00005 #include "Link.h" 00006 00007 #include <vector> 00008 00009 namespace annie 00010 { 00015 class Layer 00016 { 00017 protected: 00019 int _label; 00020 00025 uint _size; 00026 00028 std::vector<Neuron *> _neurons; 00029 00030 public: 00035 static const int MAX_LAYER_SIZE; 00036 00038 Layer(int label); 00039 00041 virtual ~Layer(); 00042 00044 virtual int getLabel() const; 00045 00047 virtual uint getSize() const; 00048 00050 uint size() const { return getSize(); } 00051 00054 virtual void addNeuron(Neuron *nrn); 00055 00060 virtual Neuron& getNeuron(uint i); 00061 virtual const Neuron& getNeuron(uint i) const; 00062 00063 Neuron& operator[](uint i) { return getNeuron(i); } 00064 const Neuron& operator[](uint i) const { return getNeuron(i); } 00065 00067 virtual Vector getActivation(); 00068 00070 virtual Vector getOutput(); 00071 00073 virtual const char *getClassName(); 00074 }; 00075 00078 template <class T> 00079 class TLayer : public Layer { 00080 public: 00081 TLayer(int label) : Layer(label) {} 00082 T& operator[](uint i) { return (T &) getNeuron(i); } 00083 const T& operator[](uint i) const { return (const T &) getNeuron(i); } 00084 }; 00085 00086 }; //namespace annie 00087 #endif // define _LAYER_H 00088