OMNeT++ Simulation Library  6.0.3
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 
24 namespace omnetpp {
25 
26 class cOwnedObject;
27 
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 
116 {
117  private:
118  cRegistrationList *inst = nullptr;
119  const char *tmpname = nullptr;
120  public:
122  cGlobalRegistrationList(const char *name);
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 
omnetpp::cRegistrationList::end
iterator end()
Definition: cregistrationlist.h:66
omnetpp::noncopyable
Utility class, to make it impossible to call the operator= and copy constructor of any class derived ...
Definition: cobject.h:415
omnetpp::cVisitor
Enables traversing the tree of (cObject-rooted) simulation objects.
Definition: cvisitor.h:56
omnetpp::cRegistrationList
Implements a list or table of objects with qualified names.
Definition: cregistrationlist.h:37
omnetpp::cRegistrationList::size
virtual int size() const
Definition: cregistrationlist.h:76
omnetpp::cRegistrationList::begin
iterator begin()
Definition: cregistrationlist.h:61
omnetpp::cNamedObject
Extends cObject with a name string. Also includes a "flags" member, with bits open for use by subclas...
Definition: cnamedobject.h:34
omnetpp::cGlobalRegistrationList
Singleton class, used for registration lists. Instances are supposed to be global variables.
Definition: cregistrationlist.h:115
omnetpp::cOwnedObject
A cObject that keeps track of its owner. It serves as base class for many classes in the OMNeT++ libr...
Definition: cownedobject.h:105