Last active
July 1, 2022 16:57
-
-
Save diegopso/4323f11341f069a23798ef9662b297b3 to your computer and use it in GitHub Desktop.
Static variable in module sample Omnet++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "SessionManager.h" | |
using namespace sdicn; | |
Define_Module(sdicn::SessionManager); | |
int SessionManager::binderCounter = 0; | |
vector<SessionManager::SessionBinding> SessionManager::bindings = vector<SessionBinding>(); | |
void SessionManager::initialize() | |
{ | |
if (binderCounter == 0) { | |
bindings = vector<SessionBinding>(); | |
} | |
++binderCounter; | |
} | |
SessionManager::~SessionManager() | |
{ | |
--binderCounter; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <tuple> | |
using namespace std; | |
#include <omnetpp.h> | |
using namespace omnetpp; | |
namespace sdicn { | |
class SessionManager : public cSimpleModule { | |
protected: | |
typedef tuple<string, unsigned, int> SessionBinding; // serviceName, consumerIp, bsIndex | |
static int binderCounter; | |
static vector<SessionBinding> bindings; | |
virtual void initialize() override; | |
virtual ~SessionManager(); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment