EMANE  1.2.1
nemstatefullayer.cc
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 #include "nemstatefullayer.h"
35 #include "nemlayerstate.h"
37 
39  NEMLayer * pLayer,
40  EMANE::PlatformServiceProvider *pPlatformService):
41  NEMLayer(id, pPlatformService),
42  pLayer_(pLayer),
43  pState_(NEMLayerStateUninitializedSingleton::instance()){}
44 
46 
48 {
49  pState_->handleInitialize(this,pLayer_.get(),registrar);
50 }
51 
53 {
54  pState_->handleConfigure(this,pLayer_.get(),update);
55 }
56 
58 {
59  pState_->handleStart(this,pLayer_.get());
60 }
61 
63 {
64  pState_->handlePostStart(this,pLayer_.get());
65 }
66 
68 {
69  pState_->handleStop(this,pLayer_.get());
70 }
71 
73  throw()
74 {
75  pState_->handleDestroy(this,pLayer_.get());
76 }
77 
79 {
80  pState_->processConfiguration(this,pLayer_.get(),update);
81 }
82 
84 {
85  pState_->processDownstreamControl(this,pLayer_.get(),msgs);
86 }
87 
89  const ControlMessages & msgs)
90 {
91  pState_->processDownstreamPacket(this,pLayer_.get(),pkt,msgs);
92 }
93 
95  const ControlMessages & msgs)
96 {
97  pState_->processUpstreamPacket(this,pLayer_.get(),pkt,msgs);
98 }
99 
101 {
102  pState_->processUpstreamControl(this,pLayer_.get(),msgs);
103 }
104 
106  const Serialization & serialization)
107 {
108  pState_->processEvent(this,pLayer_.get(),id,serialization);
109 }
110 
112 {
113  pLayer_->setUpstreamTransport(pUpstreamTransport);
114 }
115 
117 {
118  pLayer_->setDownstreamTransport(pDownstreamTransport);
119 }
120 
122 {
123  pState_ = pState;
124 }
125 
127  const TimePoint & expireTime,
128  const TimePoint & scheduleTime,
129  const TimePoint & fireTime,
130  const void * arg)
131 {
132  pState_->processTimedEvent(this, pLayer_.get(),eventId,expireTime,scheduleTime,fireTime,arg);
133 }
134 
std::string Serialization
Definition: serializable.h:42
NEMStatefulLayer(NEMId id, NEMLayer *pLayer, PlatformServiceProvider *pPlatformService)
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
void setDownstreamTransport(DownstreamTransport *pDownstreamTransport) override
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
void changeState(NEMLayerState *pState)
Base class for NEMLayer containers. Builders construct NEMLayer objects to contain derived instances ...
Definition: nemlayer.h:57
void processConfiguration(const ConfigurationUpdate &update) override
Initial state for all NEMStatefulLayers. The only allowable transition is Component::initialize() ...
std::uint16_t EventId
Definition: types.h:53
virtual void handleDestroy(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer)
void setUpstreamTransport(UpstreamTransport *pUpstreamTransport) override
The PlatformServiceProvider interface provides access to emulator services.
void configure(const ConfigurationUpdate &update) override
void processUpstreamControl(const ControlMessages &msgs) override
void processDownstreamControl(const ControlMessages &msgs) override
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
virtual void handlePostStart(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer)
void initialize(Registrar &registrar) override
initialize
virtual void processUpstreamPacket(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, UpstreamPacket &pkt, const ControlMessages &msgs)
void processUpstreamPacket(UpstreamPacket &pkt, const ControlMessages &msgs) override
void processDownstreamPacket(DownstreamPacket &pkt, const ControlMessages &msgs) override
std::uint16_t NEMId
Definition: types.h:52
Encapsulated behavior associated with an NEMLayer depending on the layer&#39;s current context...
Definition: nemlayerstate.h:50
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
UpstreamTransport allows for processing upstream data and control messages. Upstream packets and cont...
virtual void processConfiguration(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, const ConfigurationUpdate &update)
std::size_t TimerEventId
Definition: types.h:54
Clock::time_point TimePoint
Definition: types.h:50
DownstreamTransport allows for processing downstream data and control messages.
void processTimedEvent(TimerEventId eventId, const TimePoint &expireTime, const TimePoint &scheduleTime, const TimePoint &fireTime, const void *arg) override
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)
void processEvent(const EventId &eventId, const Serialization &serialization) override
virtual void handleInitialize(NEMStatefulLayer *pStatefulLayer, NEMLayer *pLayer, Registrar &registrar)