servlib/naming/TCAScheme.h
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 /*
       
     2  *    Copyright 2005-2006 University of Waterloo
       
     3  * 
       
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
       
     5  *    you may not use this file except in compliance with the License.
       
     6  *    You may obtain a copy of the License at
       
     7  * 
       
     8  *        http://www.apache.org/licenses/LICENSE-2.0
       
     9  * 
       
    10  *    Unless required by applicable law or agreed to in writing, software
       
    11  *    distributed under the License is distributed on an "AS IS" BASIS,
       
    12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13  *    See the License for the specific language governing permissions and
       
    14  *    limitations under the License.
       
    15  */
       
    16 
       
    17 #ifndef _TCA_SCHEME_H_
       
    18 #define _TCA_SCHEME_H_
       
    19 
       
    20 #include "Scheme.h"
       
    21 #include <oasys/util/Singleton.h>
       
    22 
       
    23 namespace dtn {
       
    24 
       
    25 
       
    26 /**
       
    27  * This class implements the tca scheme.
       
    28  * SSPs for this scheme take the canonical form:
       
    29  *
       
    30  * <code>
       
    31  * tca://<router identifier (guid)>[/<application tag>]
       
    32  * </code>
       
    33  *
       
    34  * Where "router identifier" is a globally unique identifier.
       
    35  * In practice, this will often be the DNS-style "hostname" string of
       
    36  * an internet host, for the more-or-less static "infrastructure" nodes
       
    37  * that make up the routers and gateways of the TCA network.
       
    38  * For the true TCA mobiles, it may be something quite different, like
       
    39  * the sha1 hash of an email address for example.
       
    40  *
       
    41  * "application tag" is any string of URI-valid characters.
       
    42  *
       
    43  * This implementation also supports limited wildcard matching for
       
    44  * endpoint patterns.
       
    45  */
       
    46 class TCAScheme : public Scheme, public oasys::Singleton<TCAScheme> {
       
    47 public:
       
    48     /**
       
    49      * Validate that the SSP in the given URI is legitimate for
       
    50      * this scheme. If the 'is_pattern' paraemeter is true, then
       
    51      * the ssp is being validated as an EndpointIDPattern.
       
    52      *
       
    53      * @return true if valid
       
    54      */
       
    55     virtual bool validate(const URI& uri, bool is_pattern = false);
       
    56 
       
    57     /**
       
    58      * Match the pattern to the endpoint id in a scheme-specific
       
    59      * manner.
       
    60      */
       
    61     virtual bool match(const EndpointIDPattern& pattern,
       
    62                        const EndpointID& eid);
       
    63 
       
    64     /**
       
    65      * Append the given service tag to the URI in a scheme-specific
       
    66      * manner.
       
    67      *
       
    68      * @return true if this scheme is capable of service tags and the
       
    69      * tag is a legal one, false otherwise.
       
    70      */
       
    71     virtual bool append_service_tag(URI* uri, const char* tag);
       
    72     
       
    73     /**
       
    74      * Check if the given URI is a singleton EID.
       
    75      */
       
    76     virtual singleton_info_t is_singleton(const URI& uri);
       
    77     
       
    78 private:
       
    79     friend class oasys::Singleton<TCAScheme>;
       
    80     TCAScheme() {}
       
    81 };
       
    82     
       
    83 }
       
    84 
       
    85 #endif /* _TCA_SCHEME_H_ */