OpFlex Framework 1.7.0
URI.h
Go to the documentation of this file.
1/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
6/*
7 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
8 *
9 * This program and the accompanying materials are made available under the
10 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
11 * and is available at http://www.eclipse.org/legal/epl-v10.html
12 */
13
14#ifndef MODB_URI_H
15#define MODB_URI_H
16
17#include <boost/any.hpp>
18#include <boost/functional/hash.hpp>
19
20#include <string>
21#include <vector>
22
23#include "opflex/ofcore/OFTypes.h"
24
25namespace opflex {
26namespace modb {
27
34
43class URI {
44public:
48 explicit URI(const OF_SHARED_PTR<const std::string>& uri);
49
53 explicit URI(const std::string& uri);
54
58 URI(const URI& uri);
59
64
68 const std::string& toString() const;
69
74 void getElements(/* out */ std::vector<std::string>& elements) const;
75
79 URI& operator=( const URI& rhs );
80
84 static const URI ROOT;
85
86private:
87 OF_SHARED_PTR<const std::string> uri;
88 size_t hashv;
89
90 friend bool operator==(const URI& lhs, const URI& rhs);
91 friend bool operator!=(const URI& lhs, const URI& rhs);
92 friend bool operator<(const URI& lhs, const URI& rhs);
93 friend size_t hash_value(URI const& uri);
94};
95
99std::ostream & operator<<(std::ostream &os, const URI& uri);
100
104bool operator==(const URI& lhs, const URI& rhs);
108bool operator!=(const URI& lhs, const URI& rhs);
112bool operator<(const URI& lhs, const URI& rhs);
117size_t hash_value(URI const& uri);
118
119/* @} modb */
120/* @} cpp */
121
122} /* namespace modb */
123} /* namespace opflex */
124
125#if __cplusplus > 199711L
126
127namespace std {
132template<> struct hash<opflex::modb::URI> {
136 std::size_t operator()(const opflex::modb::URI& u) const;
137};
138} /* namespace std */
139
140#endif
141
142#endif /* MODB_URI_H */
A URI is used to identify managed objects in the MODB.
Definition URI.h:43
size_t hash_value(MAC const &mac)
Compute a hash value for the MAC, making MAC suitable as a key in a boost::unordered_map.
friend bool operator<(const URI &lhs, const URI &rhs)
Comparison operator for sorting.
std::ostream & operator<<(std::ostream &os, const MAC &mac)
Stream insertion operator.
URI & operator=(const URI &rhs)
Assignment operator.
friend bool operator==(const URI &lhs, const URI &rhs)
Check for URI equality.
bool operator!=(const MAC &lhs, const MAC &rhs)
Check for MAC inequality.
friend bool operator!=(const URI &lhs, const URI &rhs)
Check for URI inequality.
URI(const URI &uri)
Construct a deep copy of the URI using the given URI.
static const URI ROOT
Static root URI.
Definition URI.h:84
const std::string & toString() const
Get the URI represented as a string.
~URI()
Destroy the URI.
URI(const std::string &uri)
Construct a URI using the given string representation.
friend size_t hash_value(URI const &uri)
Compute a hash value for the URI, making URI suitable as a key in a boost::unordered_map.
bool operator<(const URI &lhs, const URI &rhs)
Comparison operator for sorting.
URI(const OF_SHARED_PTR< const std::string > &uri)
Construct a URI using the given string representation.
bool operator==(const MAC &lhs, const MAC &rhs)
Check for MAC equality.
void getElements(std::vector< std::string > &elements) const
Parse the URI and get the unescaped path elements from the URI.