cregistrationlist.h Source File

API: cregistrationlist.h Source File
API
cregistrationlist.h
1//==========================================================================
2// CREGISTRATIONLIST.H - part of
3// OMNeT++/OMNEST
4// Discrete System Simulation in C++
5//
6//==========================================================================
7
8/*--------------------------------------------------------------*
9 Copyright (C) 1992-2017 Andras Varga
10 Copyright (C) 2006-2017 OpenSim Ltd.
11
12 This file is distributed WITHOUT ANY WARRANTY. See the file
13 `license' for details on this and other legal matters.
14*--------------------------------------------------------------*/
15
16#ifndef __OMNETPP_CREGISTRATIONLIST_H
17#define __OMNETPP_CREGISTRATIONLIST_H
18
19#include <vector>
20#include <map>
21#include "simkerneldefs.h"
22#include "cnamedobject.h"
23
24namespace omnetpp {
25
26class cOwnedObject;
27
37class SIM_API cRegistrationList : public cNamedObject, noncopyable
38{
39 private:
40 typedef std::map<std::string, cOwnedObject*> StringObjectMap;
41 std::vector<cOwnedObject *> vec; // for fast iteration
42 StringObjectMap nameMap; // for lookup by getName()
43 StringObjectMap fullnameMap; // for lookup by getFullName()
44
45 public:
46 typedef std::vector<cOwnedObject *>::iterator iterator;
47
48 cRegistrationList(const char *name) : cNamedObject(name, false) {}
49 virtual ~cRegistrationList();
50
53 virtual std::string str() const override;
54 virtual void forEachChild(cVisitor *v) override;
56
57
61 iterator begin() {return vec.begin();}
62
66 iterator end() {return vec.end();}
67
71 virtual void add(cOwnedObject *obj);
72
76 virtual int size() const {return vec.size();}
77
81 virtual cOwnedObject *get(int i) const;
82
87 virtual cOwnedObject *find(const char *name) const;
88
93 virtual cOwnedObject *lookup(const char *qualifiedName) const;
94
99 virtual cOwnedObject *lookup(const char *qualifiedName, const char *contextNamespace, bool fallbackToOmnetpp=false);
100
105 virtual void sort();
106
107};
108
115class SIM_API cGlobalRegistrationList
116{
117 private:
118 cRegistrationList *inst = nullptr;
119 const char *tmpname = nullptr;
120 public:
121 cGlobalRegistrationList() {}
122 cGlobalRegistrationList(const char *name);
123 ~cGlobalRegistrationList();
124 cRegistrationList *getInstance();
125 void clear();
126
127 cRegistrationList::iterator begin() {return getInstance()->begin();}
128 cRegistrationList::iterator end() {return getInstance()->end();}
129};
130
131
132} // namespace omnetpp
133
134
135#endif
136
cNamedObject()
Definition cnamedobject.h:57
A cObject that keeps track of its owner. It serves as base class for many classes in the OMNeT++ libr...
Definition cownedobject.h:106
Implements a list or table of objects with qualified names.
Definition cregistrationlist.h:38
virtual cOwnedObject * find(const char *name) const
virtual int size() const
Definition cregistrationlist.h:76
virtual void add(cOwnedObject *obj)
virtual cOwnedObject * lookup(const char *qualifiedName, const char *contextNamespace, bool fallbackToOmnetpp=false)
virtual cOwnedObject * lookup(const char *qualifiedName) const
virtual void forEachChild(cVisitor *v) override
iterator end()
Definition cregistrationlist.h:66
virtual std::string str() const override
iterator begin()
Definition cregistrationlist.h:61
virtual cOwnedObject * get(int i) const
Enables traversing the tree of (cObject-rooted) simulation objects.
Definition cvisitor.h:57