]>
Commit | Line | Data |
---|---|---|
bac41a7b A |
1 | /* |
2 | * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. | |
3 | * | |
4 | * The contents of this file constitute Original Code as defined in and are | |
5 | * subject to the Apple Public Source License Version 1.2 (the 'License'). | |
6 | * You may not use this file except in compliance with the License. Please obtain | |
7 | * a copy of the License at http://www.apple.com/publicsource and read it before | |
8 | * using this file. | |
9 | * | |
10 | * This Original Code and all software distributed under the License are | |
11 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS | |
12 | * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT | |
13 | * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | |
14 | * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the | |
15 | * specific language governing rights and limitations under the License. | |
16 | */ | |
17 | ||
18 | ||
19 | // | |
20 | // hosts - value-semantics host identifier class | |
21 | // | |
22 | // @@@ use vector instead of set to preserve resolver-generated order? | |
23 | // @@@ preliminary implementation: at the very least, there'll be more subclasses (deferred, etc.) | |
24 | // | |
25 | #ifndef _H_HOSTS | |
26 | #define _H_HOSTS | |
27 | ||
28 | #include "ip++.h" | |
29 | #include <Security/refcount.h> | |
30 | #include <set> | |
31 | ||
32 | ||
33 | namespace Security { | |
34 | namespace IPPlusPlus { | |
35 | ||
36 | ||
37 | // | |
38 | // Host identities | |
39 | // | |
40 | class Host { | |
41 | public: | |
42 | Host(const char *form); | |
43 | Host() { } | |
44 | ||
45 | // equality is defined strongly: same host specification | |
46 | bool operator == (const Host &other) const; | |
47 | bool operator != (const Host &other) const { return !(*this == other); } | |
48 | bool operator < (const Host &other) const; // for STL sorting | |
49 | ||
50 | // inclusion (<=) is defined semi-weakly: greater subsumes smaller, same access specs | |
51 | bool operator <= (const Host &other) const; | |
52 | bool operator >= (const Host &other) const { return other <= *this; } | |
53 | ||
54 | string name() const { return mSpec->name(); } | |
55 | set<IPAddress> addresses() const { return mSpec->addresses(); } | |
56 | ||
57 | public: | |
58 | class Spec : public RefCount { | |
59 | public: | |
60 | virtual ~Spec() { } | |
61 | ||
62 | virtual set<IPAddress> addresses() const = 0; | |
63 | virtual string name() const = 0; | |
64 | ||
65 | private: | |
66 | }; | |
67 | ||
68 | private: | |
69 | RefPointer<Spec> mSpec; | |
70 | }; | |
71 | ||
72 | } // end namespace IPPlusPlus | |
73 | } // end namespace Security | |
74 | ||
75 | ||
76 | #endif _H_HOSTS |