clock.h

Go to the documentation of this file.
00001 //    sampalib.org ESL library and tools
00002 //    Copyright (C) 2007  Thierry Grellier
00003 //
00004 //    This program is free software; you can redistribute it and/or modify
00005 //    it under the terms of the GNU General Public License version 2 as
00006 //    published by the Free Software Foundation.
00007 //
00008 //    This program is distributed in the hope that it will be useful,
00009 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //    GNU General Public License for more details.
00012 //
00013 //    You should have received a copy of the GNU General Public License along
00014 //    with this program; if not, write to the Free Software Foundation, Inc.,
00015 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 //
00017 //    contact: www.sampalib.org
00018 
00019 #ifndef SAMPA_CLOCK_H
00020 #define SAMPA_CLOCK_H
00021 
00022 #include "sampa/core/module.h"
00023 #include "sampa/core/event.h"
00024 #include "sampa/core/time.h"
00025 
00026 namespace Sampa {
00027 
00037   class Clock : public ContainerObject {
00038     SAMPA_PERSISTENT(Clock);
00039   public:
00040     enum Mode { RISE_ONLY, FALL_ONLY, RISE_AND_FALL };
00041     Clock(const Name& name);
00042     EventListener& get_rising_event()           { return e_rising_edge; }
00043     EventListener& get_falling_event()          { return e_falling_edge; }
00044     const Time& get_period() const              { return m_period; }
00045     unsigned long long get_rising_count() const;
00046   protected:
00047     Clock(const Name& name, ActualClock* rising_edge, ActualClock* falling_edge); 
00048     friend class ClockedEvent;
00049     friend class ClockedEventSingle;
00050     friend class Divider;
00051     static void start_at(ActualClock*, const Time&);
00052     ActualEvent* wait_n_rising(int n);    
00053     ActualEvent* wait_n_falling(int n);    
00054     TimeParameter      m_period;
00055     ActualClock*       m_rising_clock;
00056     ActualClock*       m_falling_clock;
00057     EventListener      e_rising_edge; // feed with actualclock
00058     EventListener      e_falling_edge; // feed with actualclock
00059   };
00060 
00061   class Divider : public Clock {
00062     SAMPA_PERSISTENT(Divider);
00063   public:
00064     Divider(const Name& name);
00065     void bind_clock(Clock*);
00066   };
00067 
00068 }
00069 
00070 #endif

Generated on Sat Feb 16 16:23:15 2008 for Sampa by  doxygen 1.5.3