EMANE  1.2.1
nemlayerstate.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 - Adjacent Link LLC, Bridgewater, New Jersey
3  * Copyright (c) 2008 - DRS CenGen, LLC, Columbia, Maryland
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of DRS CenGen, LLC nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef EMANENEMLAYERSTATE_HEADER_
35 #define EMANENEMLAYERSTATE_HEADER_
36 
37 #include "emane/nemlayer.h"
38 
39 namespace EMANE
40 {
41  class NEMStatefulLayer;
42  class NEMLayer;
43 
51  {
52  public:
53  virtual ~NEMLayerState() = 0;
54 
66  virtual void handleInitialize(NEMStatefulLayer * pStatefulLayer,
67  NEMLayer * pLayer,
68  Registrar & registrar);
69 
82  virtual void handleConfigure(NEMStatefulLayer * pStatefulLayer,
83  NEMLayer * pLayer,
84  const ConfigurationUpdate & update);
85 
96  virtual void handleStart(NEMStatefulLayer * pStatefulLayer,
97  NEMLayer * pLayer);
98 
99 
108  virtual void handlePostStart(NEMStatefulLayer * pStatefulLayer,
109  NEMLayer * pLayer);
110 
121  virtual void handleStop(NEMStatefulLayer * pStatefulLayer,
122  NEMLayer * pLayer);
123 
132  virtual void handleDestroy(NEMStatefulLayer * pStatefulLayer,
133  NEMLayer * pLayer)
134  throw();
135 
136 
146  virtual void processConfiguration(NEMStatefulLayer * pStatefulLayer,
147  NEMLayer * pLayer,
148  const ConfigurationUpdate & update);
149 
150 
160  virtual void processDownstreamControl(NEMStatefulLayer * pStatefulLayer,
161  NEMLayer * pLayer,
162  const ControlMessages & msgs);
163 
174  virtual void processDownstreamPacket(NEMStatefulLayer * pStatefulLayer,
175  NEMLayer * pLayer,
176  DownstreamPacket & pkt,
177  const ControlMessages & msgs);
178 
189  virtual void processUpstreamPacket(NEMStatefulLayer * pStatefulLayer,
190  NEMLayer * pLayer,
191  UpstreamPacket & pkt,
192  const ControlMessages & msgs);
193 
203  virtual void processUpstreamControl(NEMStatefulLayer * pStatefulLayer,
204  NEMLayer * pLayer,
205  const ControlMessages & msgs);
206 
217  virtual void processEvent(NEMStatefulLayer * pStatefulLayer,
218  NEMLayer * pLayer,
219  const EventId & id,
220  const Serialization & serialization);
221 
222 
236  virtual void processTimedEvent(NEMStatefulLayer * pStatefulLayer,
237  NEMLayer * pLayer,
238  TimerEventId eventId,
239  const TimePoint & expireTime,
240  const TimePoint & scheduleTime,
241  const TimePoint & fireTime,
242  const void * arg);
243 
249  std::string getStateName() const;
250 
251  protected:
252  const char * pzStateName_;
253 
254  NEMLayerState(const char * pzStateName);
255 
256  void changeState(NEMStatefulLayer * pStatefulLayer,NEMLayerState * pState);
257  };
258 }
259 
260 #endif //EMANENEMLAYERSTATE_HEADER_
std::string Serialization
Definition: serializable.h:42
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
virtual void processEvent(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, const EventId &id, const Serialization &serialization)
virtual void processTimedEvent(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, TimerEventId eventId, const TimePoint &expireTime, const TimePoint &scheduleTime, const TimePoint &fireTime, const void *arg)
The Registrar interface provides access to all of the emulator registrars.
Definition: registrar.h:50
virtual void handleStop(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer)
virtual void processDownstreamControl(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, const ControlMessages &msgs)
virtual void handleConfigure(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, const ConfigurationUpdate &update)
std::list< const ControlMessage * > ControlMessages
NEMLayerState(const char *pzStateName)
void changeState(NEMStatefulLayer *pStatefulLayer, NEMLayerState *pState)
Base class for NEMLayer containers. Builders construct NEMLayer objects to contain derived instances ...
Definition: nemlayer.h:57
std::uint16_t EventId
Definition: types.h:53
virtual void handleDestroy(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer)
std::string getStateName() const
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
virtual void handlePostStart(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer)
virtual void processUpstreamPacket(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, UpstreamPacket &pkt, const ControlMessages &msgs)
const char * pzStateName_
Encapsulated behavior associated with an NEMLayer depending on the layer&#39;s current context...
Definition: nemlayerstate.h:50
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
virtual void processConfiguration(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, const ConfigurationUpdate &update)
std::size_t TimerEventId
Definition: types.h:54
A layer stack that enforces component state transition rules. The stateful layer is not a fully funct...
Clock::time_point TimePoint
Definition: types.h:50
virtual ~NEMLayerState()=0
virtual void processDownstreamPacket(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, DownstreamPacket &pkt, const ControlMessages &msgs)
virtual void processUpstreamControl(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, const ControlMessages &msgs)
virtual void handleStart(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer)
Definition: agent.h:43
virtual void handleInitialize(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, Registrar &registrar)