Simbody  3.4 (development)
EventReporter.h
Go to the documentation of this file.
00001 #ifndef SimTK_SimTKCOMMON_EVENT_REPORTER_H_
00002 #define SimTK_SimTKCOMMON_EVENT_REPORTER_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                       Simbody(tm): SimTKcommon                             *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK biosimulation toolkit originating from           *
00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00010  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody.  *
00011  *                                                                            *
00012  * Portions copyright (c) 2007-12 Stanford University and the Authors.        *
00013  * Authors: Peter Eastman                                                     *
00014  * Contributors:                                                              *
00015  *                                                                            *
00016  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
00017  * not use this file except in compliance with the License. You may obtain a  *
00018  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
00019  *                                                                            *
00020  * Unless required by applicable law or agreed to in writing, software        *
00021  * distributed under the License is distributed on an "AS IS" BASIS,          *
00022  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
00023  * See the License for the specific language governing permissions and        *
00024  * limitations under the License.                                             *
00025  * -------------------------------------------------------------------------- */
00026 
00027 #include "SimTKcommon/basics.h"
00028 #include "SimTKcommon/Simmatrix.h"
00029 #include "SimTKcommon/internal/State.h"
00030 #include "SimTKcommon/internal/System.h"
00031 
00032 namespace SimTK {
00033 
00053 class SimTK_SimTKCOMMON_EXPORT EventReporter {
00054 public:
00055     virtual ~EventReporter();
00056     
00062     virtual void handleEvent(const State& state) const = 0;
00063 };
00064 
00072 class SimTK_SimTKCOMMON_EXPORT ScheduledEventReporter : public EventReporter {
00073 public:
00074     virtual ~ScheduledEventReporter();
00075     
00084     virtual Real getNextEventTime(const State& state, bool includeCurrentTime) const = 0;
00085 };
00086 
00096 class SimTK_SimTKCOMMON_EXPORT TriggeredEventReporter : public EventReporter {
00097 public:
00098     class TriggeredEventReporterImpl;
00099     TriggeredEventReporter(const TriggeredEventReporter& clone);
00100     TriggeredEventReporter& operator=(const TriggeredEventReporter& clone);
00101     virtual ~TriggeredEventReporter();
00102     
00109     TriggeredEventReporter(Stage requiredStage);
00110     
00115     virtual Real getValue(const State&) const = 0;
00116     
00121     EventTriggerInfo& getTriggerInfo();
00122     
00127     Stage getRequiredStage() const;
00128 private:
00129     TriggeredEventReporterImpl* impl;
00130 };
00131 
00138 class SimTK_SimTKCOMMON_EXPORT PeriodicEventReporter : public ScheduledEventReporter {
00139 public:
00140     class PeriodicEventReporterImpl;
00141     ~PeriodicEventReporter();
00142     Real getNextEventTime(const State& state, bool includeCurrentTime) const;
00143     
00150     PeriodicEventReporter(Real eventInterval);
00151     
00156     Real getEventInterval() const;
00157     
00162     void setEventInterval(Real eventInterval);
00163 private:
00164     PeriodicEventReporterImpl* impl;
00165 };
00166 
00167 } // namespace SimTK
00168 
00169 #endif // SimTK_SimTKCOMMON_EVENT_REPORTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines