OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2012,2014 University of Zagreb |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 * Author: Vedran Miletić <rivanvx@gmail.com> |
| 19 */ |
| 20 |
| 21 #ifndef FAILURE_REPAIR_MODEL_H |
| 22 #define FAILURE_REPAIR_MODEL_H |
| 23 |
| 24 #include <ns3/event-id.h> |
| 25 #include <ns3/nstime.h> |
| 26 #include <ns3/pointer.h> |
| 27 #include <ns3/object.h> |
| 28 #include <ns3/traced-callback.h> |
| 29 |
| 30 #include <map> |
| 31 #include <stdint.h> |
| 32 |
| 33 namespace ns3 |
| 34 { |
| 35 |
| 36 class RandomVariableStream; |
| 37 |
| 38 /** |
| 39 * \ingroup startstop |
| 40 * \brief Started and stopped state changer |
| 41 * |
| 42 * Started and stopped state changer can be bound to an object and used to |
| 43 * automate the object state changes from started to stopped and back. |
| 44 * Started and stopped state durations are provided by RandomVariableStream |
| 45 * objects configured through attribute system. Started and stopped state |
| 46 * changer also requires user to set at least one among StateChangingTime and |
| 47 * NumberOfStateChanges attributes; default values for both are zero. |
| 48 */ |
| 49 class FailureRepairModel : public Object |
| 50 { |
| 51 public: |
| 52 static TypeId GetTypeId (void); |
| 53 FailureRepairModel (); |
| 54 virtual ~FailureRepairModel (); |
| 55 ·· |
| 56 void AssociateObject (Ptr<Object> obj, Callback<void> startCallback, Callback<
void> stopCallback); |
| 57 ·· |
| 58 /** |
| 59 * Assign a fixed random variable stream number to the random variables |
| 60 * used by this model. Return the number of streams (possibly zero) that |
| 61 * have been assigned. |
| 62 * |
| 63 * \param stream first stream index to use |
| 64 * \return the number of stream indices assigned by this model |
| 65 */ |
| 66 int64_t AssignStreams (int64_t stream); |
| 67 |
| 68 /** |
| 69 * FIXME |
| 70 */ |
| 71 uint32_t GetNStateChangesDone () const; |
| 72 |
| 73 protected: |
| 74 virtual void DoInitialize (void); |
| 75 /** |
| 76 * \brief Dispose StartedStoppedStateChanger |
| 77 *· |
| 78 * Note that this disposes attached StartedStoppedTimeTracker as well |
| 79 */ |
| 80 virtual void DoDispose (void); |
| 81 ·· |
| 82 /** |
| 83 * \brief Start attached object |
| 84 * |
| 85 * Execute Object::Start on attached Object and schedule the execution of |
| 86 * stop event |
| 87 */ |
| 88 void StartAttachedObject (); |
| 89 |
| 90 /** |
| 91 * \brief Stop attached object |
| 92 * |
| 93 * Execute Object::Stop on attached Object and schedule the execution of |
| 94 * start event |
| 95 */ |
| 96 void StopAttachedObject (); |
| 97 |
| 98 private: |
| 99 Time::Unit m_timeUnit; |
| 100 ·· |
| 101 uint32_t m_nStateChanges; |
| 102 uint32_t m_nStateChangesDone; |
| 103 Time m_stateChangingTime; |
| 104 ·· |
| 105 Ptr<RandomVariableStream> m_workingStateDuration; |
| 106 Ptr<RandomVariableStream> m_failedStateDuration; |
| 107 |
| 108 EventId m_startObjectEvent; |
| 109 EventId m_stopObjectEvent; |
| 110 ·· |
| 111 Callback<void> m_startCallback; |
| 112 Callback<void> m_stopCallback; |
| 113 }; |
| 114 |
| 115 } // namespace ns3 |
| 116 |
| 117 #endif /* FAILURE_REPAIR_MODEL_H */ |
| 118 |
OLD | NEW |