src/common/f-variable-tracer.h
changeset 345 47b41507a45a
parent 344 b547ec7dbbc1
child 348 1802fde7996c
equal deleted inserted replaced
344:b547ec7dbbc1 345:47b41507a45a
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2006 INRIA
       
     4  * All rights reserved.
       
     5  *
       
     6  * This program is free software; you can redistribute it and/or modify
       
     7  * it under the terms of the GNU General Public License version 2 as
       
     8  * published by the Free Software Foundation;
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program; if not, write to the Free Software
       
    17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    18  *
       
    19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
       
    20  */
       
    21 
       
    22 #ifndef F_VARIABLE_TRACER_H
       
    23 #define F_VARIABLE_TRACER_H
       
    24 
       
    25 #include "ns3/callback.h"
       
    26 #include <stdint.h>
       
    27 
       
    28 namespace ns3 {
       
    29 
       
    30 class FVariableTracerBase {
       
    31 public:
       
    32   typedef Callback<void,double, double> ChangeNotifyCallback;
       
    33 
       
    34   FVariableTracerBase () {}
       
    35   FVariableTracerBase (FVariableTracerBase const &o) {}
       
    36   FVariableTracerBase &operator = (FVariableTracerBase const &o) {
       
    37       return *this;
       
    38   }
       
    39 
       
    40   ~FVariableTracerBase () {}
       
    41 
       
    42   void setCallback(ChangeNotifyCallback callback) {
       
    43       m_callback = callback;
       
    44   }
       
    45 protected:
       
    46   void notify (double oldVal, double newVal) {
       
    47       if (oldVal != newVal && !m_callback.IsNull ()) 
       
    48         {
       
    49           m_callback (oldVal, newVal);
       
    50         }
       
    51   }
       
    52 private:
       
    53   ChangeNotifyCallback m_callback;
       
    54 };
       
    55 
       
    56 
       
    57 }; // namespace ns3
       
    58 
       
    59 #endif /* F_VARIABLE_TRACER_H */