IBR-DTNSuite  0.10
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 
29 using namespace std;
30 
31 namespace dtn
32 {
33  namespace data
34  {
35  class EID
36  {
37  public:
38  static const std::string DEFAULT_SCHEME;
39  static const std::string CBHE_SCHEME;
40 
41  EID();
42  EID(const std::string &scheme, const std::string &ssp);
43  EID(const std::string &value);
44 
50  EID(const dtn::data::Number &node, const dtn::data::Number &application);
51 
52  virtual ~EID();
53 
54  EID& operator=(const EID &other);
55 
56  bool operator==(const EID &other) const;
57 
58  bool operator==(const std::string &other) const;
59 
60  bool operator!=(const EID &other) const;
61 
62  EID operator+(const std::string &suffix) const;
63 
64  friend EID operator+(const EID &left, const std::string &right)
65  {
66  return EID(left.getString() + right);
67  }
68 
69  EID add(const std::string &other) const {
70  return EID(this->getString() + other);
71  }
72 
73  bool sameHost(const std::string &other) const;
74  bool sameHost(const EID &other) const;
75 
76  bool operator<(const EID &other) const;
77  bool operator>(const EID &other) const;
78 
79  std::string getString() const;
80  std::string getApplication() const throw ();
81  std::string getHost() const throw ();
82  const std::string& getScheme() const;
83  const std::string& getSSP() const;
84 
85  std::string getDelimiter() const;
86 
91  EID getNode() const throw ();
92 
93  bool hasApplication() const;
94 
99  bool isCompressable() const;
100 
105  bool isNone() const;
106 
112  typedef std::pair<Number, Number> Compressed;
113  Compressed getCompressed() const;
114 
115  private:
116  std::string _scheme;
117  std::string _ssp;
118  };
119  }
120 }
121 
122 #endif /* EID_H_ */