IBR-DTNSuite  0.12
EID.h
Go to the documentation of this file.
1 /*
2  * EID.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef EID_H_
23 #define EID_H_
24 
25 #include <string>
26 #include <ibrcommon/Exceptions.h>
27 #include <ibrdtn/data/Number.h>
28 #include <map>
29 
30 namespace dtn
31 {
32  namespace data
33  {
34  class EID
35  {
36  public:
37  enum Scheme {
41  };
42 
46  static Scheme resolveScheme(const std::string &s);
47 
51  static const std::string getSchemeName(const Scheme s);
52 
56  static Number getApplicationNumber(const std::string &app);
57 
58  EID();
59  EID(const std::string &scheme, const std::string &ssp);
60  EID(const std::string &value);
61 
67  EID(const dtn::data::Number &node, const dtn::data::Number &application);
68 
69  virtual ~EID();
70 
71  bool operator==(const EID &other) const;
72 
73  bool operator==(const std::string &other) const;
74 
75  bool operator!=(const EID &other) const;
76 
77  bool sameHost(const std::string &other) const;
78  bool sameHost(const EID &other) const;
79 
80  bool operator<(const EID &other) const;
81  bool operator>(const EID &other) const;
82 
83  std::string getString() const;
84 
85  void setApplication(const dtn::data::Number &app) throw ();
86  void setApplication(const std::string &app) throw ();
87  std::string getApplication() const throw ();
88 
89  bool isApplication(const dtn::data::Number &app) const throw ();
90  bool isApplication(const std::string &app) const throw ();
91 
92  std::string getHost() const throw ();
93  const std::string getScheme() const;
94  const std::string getSSP() const;
95 
96  std::string getDelimiter() const;
97 
102  EID getNode() const throw ();
103 
104  bool hasApplication() const;
105 
110  bool isCompressable() const;
111 
116  bool isNone() const;
117 
123  typedef std::pair<Number, Number> Compressed;
124  Compressed getCompressed() const;
125 
126  private:
130  EID(const Scheme scheme_type, const std::string &scheme, const std::string &ssp, const std::string &application);
131 
135  static void extractCBHE(const std::string &ssp, Number &node, Number &app);
136 
140  static void extractDTN(const std::string &ssp, std::string &node, std::string &application);
141 
142  // abstract values
143  Scheme _scheme_type;
144  std::string _scheme;
145  std::string _ssp;
146 
147  // DTN scheme
148  // the ssp carries the node part
149  std::string _application;
150 
151  // CBHE scheme
152  Number _cbhe_node;
153  Number _cbhe_application;
154 
155  // well-known CBHE numbers
156  typedef std::map<std::string, Number> cbhe_map;
157  static cbhe_map& getApplicationMap();
158  };
159  }
160 }
161 
162 #endif /* EID_H_ */