OMNeT++ API 6.1
Discrete Event Simulation Library
cmatchexpression.h
1 //==========================================================================
2 // CMATCHEXPRESSION.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 2006-2017 OpenSim Ltd.
10 
11  This file is distributed WITHOUT ANY WARRANTY. See the file
12  `license' for details on this and other legal matters.
13 *--------------------------------------------------------------*/
14 
15 
16 #ifndef __OMNETPP_CMATCHEXPRESSION_H
17 #define __OMNETPP_CMATCHEXPRESSION_H
18 
19 #include <string>
20 #include "simkerneldefs.h"
21 #include "cobject.h" // noncopyable
22 
23 namespace omnetpp {
24 
25 namespace common { class MatchExpression; };
26 
27 
55 class SIM_API cMatchExpression : public noncopyable
56 {
57  public:
62  class SIM_API Matchable
63  {
64  public:
69  virtual const char *getAsString() const = 0;
70 
76  virtual const char *getAsString(const char *attribute) const = 0;
77 
81  virtual ~Matchable() {}
82  };
83 
84  private:
85  omnetpp::common::MatchExpression *impl;
86 
87  public:
92 
96  cMatchExpression(const char *pattern, bool dottedpath, bool fullstring, bool casesensitive);
97 
101  cMatchExpression(cMatchExpression&& other) : impl(other.impl) {other.impl = nullptr;}
102 
106  ~cMatchExpression();
107 
113  void setPattern(const char *pattern, bool dottedpath, bool fullstring, bool casesensitive);
114 
119  bool matches(const Matchable *object) const;
120 };
121 
122 
128 {
129  private:
130  std::string str;
131  public:
132  cMatchableString(const char *s) {str = s;}
133  virtual const char *getAsString() const override {return str.c_str();}
134  virtual const char *getAsString(const char *attribute) const override {return nullptr;}
135 };
136 
137 } // namespace omnetpp
138 
139 
140 #endif
141 
142 
omnetpp::cMatchExpression::Matchable
Objects to be matched must implement this interface.
Definition: cmatchexpression.h:62
omnetpp::noncopyable
Utility class, to make it impossible to call the operator= and copy constructor of any class derived ...
Definition: cobject.h:415
omnetpp::cMatchExpression::Matchable::~Matchable
virtual ~Matchable()
Definition: cmatchexpression.h:81
omnetpp::cMatchableString::getAsString
virtual const char * getAsString(const char *attribute) const override
Definition: cmatchexpression.h:134
omnetpp::cMatchableString
Wrapper to make a string matchable with cMatchExpression.
Definition: cmatchexpression.h:127
omnetpp::cMatchExpression
Decides whether an object matches an expression.
Definition: cmatchexpression.h:55
omnetpp::cMatchableString::getAsString
virtual const char * getAsString() const override
Definition: cmatchexpression.h:133
omnetpp::cMatchExpression::cMatchExpression
cMatchExpression(cMatchExpression &&other)
Definition: cmatchexpression.h:101