rtt_rosclock_sim_clock_activity_manager.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2013, Johannes Meyer, TU Darmstadt
00005  *  Copyright (c) 2013, Intermodalics BVBA
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/or other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of TU Darmstadt and Intermodalics BVBA
00019  *     nor the names of its contributors may be
00020  *     used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  *  Copyright (c) 2014, Jonathan Bohren, The Johns Hopkins University
00037  *  - Generalized for multiple time sources
00038  *  - Integrated with rtt_rosclock package
00039  *********************************************************************/
00040 
00041 #ifndef __RTT_ROSCLOCK_RTT_ROSCLOCK_SIM_CLOCK_ACTIVITY_MANAGER_H
00042 #define __RTT_ROSCLOCK_RTT_ROSCLOCK_SIM_CLOCK_ACTIVITY_MANAGER_H
00043 
00044 #include <rtt/base/ActivityInterface.hpp>
00045 
00046 #include <rtt/os/TimeService.hpp>
00047 #include <rtt/os/Mutex.hpp>
00048 
00049 #include <list>
00050 
00051 namespace rtt_rosclock {
00052 
00053   class SimClockActivity;
00054 
00063   class SimClockActivityManager 
00064   {
00065   public:
00067     static boost::shared_ptr<SimClockActivityManager> Instance();
00068 
00070     static boost::shared_ptr<SimClockActivityManager> GetInstance();
00071 
00072     ~SimClockActivityManager();
00073 
00074     RTT::Seconds getSimulationPeriod() const;
00075     void setSimulationPeriod(RTT::Seconds s);
00076 
00078     void update();
00079 
00080   protected:
00082     SimClockActivityManager();
00084     SimClockActivityManager(SimClockActivityManager const&);
00085     void operator=(SimClockActivityManager const&);
00086 
00087   private:
00089     friend class SimClockActivity;
00090 
00092     void add(SimClockActivity *activity);
00094     void remove(SimClockActivity *activity);
00095 
00096   private:
00097 
00099     static boost::weak_ptr<SimClockActivityManager> singleton;
00100 
00102     RTT::os::Mutex modify_activities_mutex_;
00103 
00105     std::list<SimClockActivity *> activities_;
00106 
00108     RTT::Seconds simulation_period_;
00109   };
00110 
00111 }
00112 
00113 #endif // ifndef __RTT_ROSCLOCK_RTT_ROSCLOCK_SIM_CLOCK_ACTIVITY_MANAGER_H


rtt_rosclock
Author(s):
autogenerated on Wed Sep 16 2015 06:59:15