IBR-DTNSuite  0.10
DiscoveryService.cpp
Go to the documentation of this file.
1 /*
2  * DiscoveryService.cpp
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 #include "net/DiscoveryService.h"
23 #include "ibrdtn/data/SDNV.h"
25 #include <string>
26 
27 using namespace dtn::data;
28 
29 namespace dtn
30 {
31  namespace net
32  {
33  DiscoveryService::DiscoveryService()
34  {
35  }
36 
37  DiscoveryService::DiscoveryService(std::string name, std::string parameters)
38  : _service_name(name), _service_parameters(parameters)
39  {
40  }
41 
43  {
44  }
45 
47  {
50 
51  return name.getLength() + parameters.getLength();
52  }
53 
54  const std::string& DiscoveryService::getName() const
55  {
56  return _service_name;
57  }
58 
59  const std::string& DiscoveryService::getParameters() const
60  {
61  return _service_parameters;
62  }
63 
64  std::ostream &operator<<(std::ostream &stream, const DiscoveryService &service)
65  {
66  BundleString name(service._service_name);
67  BundleString parameters(service._service_parameters);
68 
69  stream << name << parameters;
70 
71  return stream;
72  }
73 
74  std::istream &operator>>(std::istream &stream, DiscoveryService &service)
75  {
76  BundleString name;
77  BundleString parameters;
78 
79  stream >> name >> parameters;
80 
81  service._service_name = (std::string)name;
82  service._service_parameters = (std::string)parameters;
83 
84  return stream;
85  }
86  }
87 }