src/simulator/scheduler-factory.h
changeset 2577 5b41cb5c3fcf
parent 2576 793375cbbed6
child 2578 685b62ddfbd8
equal deleted inserted replaced
2576:793375cbbed6 2577:5b41cb5c3fcf
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2006 INRIA
       
     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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
       
    19  */
       
    20 #ifndef SCHEDULER_FACTORY_H
       
    21 #define SCHEDULER_FACTORY_H
       
    22 
       
    23 #include <list>
       
    24 
       
    25 namespace ns3 {
       
    26 
       
    27 class Scheduler;
       
    28 class StringEnumDefaultValue;
       
    29 
       
    30 /**
       
    31  * \brief a base class to create event schedulers
       
    32  *
       
    33  * If you want to make the core simulation engine use a new
       
    34  * event scheduler without editing the code of the simulator,
       
    35  * you need to create a subclass of this base class and implement
       
    36  * the ns3::SchedulerFactory::realCreate method.
       
    37  */
       
    38 class SchedulerFactory {
       
    39 public:
       
    40   virtual ~SchedulerFactory ();
       
    41   /**
       
    42    * \returns a newly-created scheduler.
       
    43    */
       
    44   Scheduler *Create (void) const;
       
    45   /**
       
    46    * \returns a newly-created scheduler.
       
    47    *
       
    48    * Return a "default" scheduler.
       
    49    */
       
    50   static Scheduler *CreateDefault (void);
       
    51   /**
       
    52    * \param name of scheduler to create.
       
    53    * \returns a newly-created scheduler.
       
    54    *
       
    55    * Create a scheduler registered under the specified name.
       
    56    */
       
    57   static Scheduler *Create (const std::string &name);
       
    58 protected:
       
    59   static void Add (const SchedulerFactory *factory,
       
    60                    const std::string &name);  
       
    61   static void AddDefault (const SchedulerFactory *factory,
       
    62                           const std::string &name);  
       
    63 private:
       
    64   typedef std::list<std::pair<const SchedulerFactory *, std::string> > List;
       
    65   static SchedulerFactory::List *GetList (void);
       
    66   static StringEnumDefaultValue *GetDefault (void);
       
    67   /**
       
    68    * \returns a newly-created scheduler. The caller takes 
       
    69    *      ownership of the returned pointer.
       
    70    *
       
    71    * This method must be implemented by subclasses.
       
    72    */
       
    73   virtual Scheduler *DoCreate (void) const = 0;
       
    74 };
       
    75 
       
    76 }; // namespace ns3
       
    77 
       
    78 #endif /* SCHEDULER_FACTORY_H */