GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

GATLocation.h

Go to the documentation of this file.
00001 /** @file GATLocation.h
00002  * Header file for the GATLocation class.
00003  * 
00004  * An instance of this class represents the location of an abstract 
00005  * or physical resource. The location of an abstract or physical 
00006  * resource is represented by a URI as defined by the standards
00007  * <ul>
00008  *   <li>RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax</li>
00009  *   <li> RFC 2732: Format for Literal IPv6 Addresses in URLs.</li>
00010  * </ul>
00011  * One should refer to these standards to determine the allowed forms
00012  * for URIs. This class provides a means to create a GATLocation 
00013  * instance from a "URI in String form," operations for 
00014  * accessing the various components  of the contained URI, and various
00015  * other utility operations.
00016  * 
00017  * @date $Date: 2004/03/24 19:30:58 $
00018  * 
00019  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATLocation.h,v 1.19 2004/03/24 19:30:58 hartmutkaiser Exp $
00020  *
00021  *  Copyright (C) Kelly Davis
00022  *  This file is part of the GAT Engine.
00023  *  Contributed by Kelly Davis <kdavis@aei.mpg.de>.
00024  *
00025  *  Copyright (C) Tom Goodale
00026  *  This file is part of the GAT Engine.
00027  *  Contributed by Tom Goodale <goodale@aei.mpg.de>.
00028  *
00029  *  Use, modification and distribution is subject to the Gridlab Software
00030  *  License. (See accompanying file GLlicense.txt or copy at
00031  *  http://www.gridlab.org/GLlicense.txt)
00032  */
00033 
00034 #ifndef _GATLOCATION_H_
00035 #define _GATLOCATION_H_ 1
00036 
00037 #include "GATType.h"
00038 #include "GATObject.h"
00039 
00040 #ifdef __cplusplus
00041 extern "C" 
00042 {
00043 #endif
00044 
00045 /* Declare the converters to/from GATObject */
00046 GATOBJECT_DECLARE_CONVERTERS(GATLocation);
00047 
00048 /**
00049  * Constructs a GATLocation instance by parsing the given String as a URI.
00050  * <p>
00051  * This constructor parses the given String exactly as specified by the
00052  * grammar in RFC 2396, Appendix A, except IPv6 addresses are permitted
00053  * for the host component. An IPv6 address must be enclosed in square
00054  * brackets (`[' and `]') as specified by RFC 2732. The IPv6 address
00055  * itself must parse according to RFC 2373. IPv6 addresses are further
00056  * constrained to describe no more than sixteen bytes of address
00057  * information, a constraint implicit in RFC 2373 but not expressible in
00058  * the grammar.
00059  *
00060  * @param url URI for the Location.
00061  * @return A new GATLocation
00062  */
00063 GATLocation GATLocation_Create(const char *uri);
00064 
00065 /**
00066  * Destroys this GATLocation object
00067  *
00068  * @param this The GATLocation to destroy
00069  */
00070 void GATLocation_Destroy(GATLocation *loc);
00071 
00072 /**
00073  * Tests this GATLocation for equality with the passed GATLocations.
00074  * <p>
00075  * For two GATLocations to be considered equal requires that either both
00076  * are opaque or both are hierarchical. Their schemes must either both
00077  * be undefined or else be equal without regard to case, and similarly
00078  * for their fragments.
00079  * <p>
00080  * For two opaque GATLocations to be considered equal, their
00081  * scheme-specific parts must be equal.
00082  * <p>
00083  * For two hierarchical GATLocations to be considered equal, their paths
00084  * must be equal and their queries must either both be undefined or else
00085  * be equal.  Their authorities must either both be undefined, or both
00086  * be registry-based, or both be server-based.  If their authorities are
00087  * defined and are registry-based, then they must be equal.  If their
00088  * authorities are defined and are server-based, then their hosts must
00089  * be equal without regard to case, their port numbers must be equal,
00090  * and their user-information components must be equal.
00091  * <p>
00092  * When testing the user-information, path, query, fragment, authority,
00093  * or scheme-specific parts of two GATLocations for equality, the raw forms
00094  * rather than the encoded forms of these components are compared and
00095  * the hexadecimal digits of escaped octets are compared without regard
00096  * to case.
00097  *
00098  * @param this The first GATLocation
00099  * @param that The second GATLocation
00100  * @return 1 upon equality 0 otherwise
00101  */
00102 int GATLocation_Equals(GATLocation_const lhs, GATLocation_const rhs, 
00103   GATBool *isequal);
00104 
00105 /** GATResult GATLocation_GetInterface(GATLocation_const file, GATInterface iftype, void const **ifp)
00106  *  @brief Get an interface supported by a GATObject
00107  *
00108  *  The function GATLocation_GetInterface allows to get a pointer to an 
00109  *  additional interface supported by this GATLocation.
00110  *
00111  *  @param object The object to be asked for the new interface.
00112  *  @param iftype The interface the object is to be asked for.
00113  *  @param ifp The pointer, through which the result is to be returned.
00114  *
00115  *  @return An error type.
00116  */
00117 GATResult  
00118   GATLocation_GetInterface(GATLocation_const object, 
00119     GATInterface iftype, void const **ifp);
00120 
00121 /**
00122  * Returns the decoded authority component of this GATLocation.
00123  * <p>
00124  * A sequence of escaped octets is decoded by replacing it with the
00125  * sequence of characters that it represents in the UTF-8 character set.
00126  * UTF-8 contains US-ASCII, hence decoding has the effect of de-quoting
00127  * any quoted US-ASCII characters as well as that of decoding any encoded
00128  * non-US-ASCII characters.  If a decoding error occurs when decoding the
00129  * escaped octets then the erroneous octets are replaced by
00130  * `\uFFFD', the Unicode replacement character.
00131  * <p>
00132  * The String returned by this operation is equal to that returned by the
00133  * GetRawAuthority operation except that all sequences of escaped octets are
00134  * decoded.
00135  *
00136  * @param this The GATLocation to query
00137  * @retrun Decoded authority component of this GATLocation, or null if 
00138  * authority is undefined
00139  */
00140 char *GATLocation_GetAuthority(GATLocation_const loc);
00141 
00142 /**
00143  * Returns the raw authority component of this GATLocation.
00144  * <p>
00145  * The authority component of a GATLocation, if defined, only contains the
00146  * commercial-at character (`@') and characters in the unreserved, punct,
00147  * escaped, and other categories.  If the authority is server-based then
00148  * it is further constrained to have valid user-information, host, and
00149  * port components.
00150  *
00151  * @param this The GATLocation to query
00152  * @return Raw authority component of this GATLocation, or null if authority 
00153  * is undefined.
00154  */
00155 char *GATLocation_GetRawAuthority(GATLocation_const loc);
00156 
00157 /**
00158  * Returns the decoded fragment component of this GATLocation.
00159  * <p>
00160  * A sequence of escaped octets is decoded by replacing it with the
00161  * sequence of characters that it represents in the UTF-8 character set.
00162  * UTF-8 contains US-ASCII, hence decoding has the effect of de-quoting
00163  * any quoted US-ASCII characters as well as that of decoding any encoded
00164  * non-US-ASCII characters.  If a decoding error occurs when decoding the
00165  * escaped octets then the erroneous octets are replaced by
00166  * `\uFFFD', the Unicode replacement character.
00167  * <p>
00168  * The String returned by this operation is equal to that returned by the
00169  * GetRawFragment operation except that all sequences of escaped octets are
00170  * decoded.
00171  *
00172  * @param this The GATLocation to query
00173  * @return The decoded fragment component of this GATLocation, 
00174  * or null if fragment is undefined.
00175  */
00176 char *GATLocation_GetFragment(GATLocation_const loc);
00177 
00178 /**
00179  * Returns the raw fragment component of this GATLocation.
00180  * <p>
00181  * The fragment component of a GATLocation, if defined, only contains legal
00182  * URI characters.
00183  *
00184  * @param this The GATLocation to query
00185  * @return Raw fragment component of this GATLocation, or null if fragment is 
00186  * undefined
00187  */
00188 char *GATLocation_GetRawFragment(GATLocation_const loc);
00189 
00190 /** 
00191  * Returns the host component of this GATLocation.
00192  * <p>
00193  * The host component of a GATLocation, if defined, will have one of the  
00194  * following forms: 
00195  * <ul>
00196  *  <li>A domain name consisting of one or more labels    separated by 
00197  * period characters (`.'), optionally followed by a period character.  
00198  * Each label consists of alphanum characters as well as hyphen characters 
00199  * (`-'), though hyphens never    occur as the first or last characters 
00200  * in a label. The last, or only, label in a domain name begins with an 
00201  * alpha character.</li>
00202  * <li>A dotted-quad IPv4 address of the form digit+.digit+.digit+.digit+, 
00203  * where no digit sequence is longer than three characters and no sequence 
00204  * has a value larger than 255.</li>
00205  * <li>An IPv6 address enclosed in square brackets (`[' and `]') and 
00206  * consisting of hexadecimal digits, colon characters (`:'), and possibly 
00207  * an embedded IPv4 address. The full syntax of IPv6 addresses is specified 
00208  * in RFC 2373: IPv6 Addressing Architecture.</li>
00209  * </ul>
00210  * <p>
00211  * The host component of a GATLocation cannot contain escaped octets,
00212  * hence this operation does not perform any decoding.
00213  *
00214  * @param this The GATLocation to query
00215  * @retrun Host component of this GATLocation, or null if host is undefined.
00216  */
00217 char *GATLocation_GetHost(GATLocation_const loc);
00218 
00219 /**
00220  * Returns the decoded path component of this GATLocation.
00221  * <p>
00222  * A sequence of escaped octets is decoded by replacing it with the
00223  * sequence of characters that it represents in the UTF-8 character set.
00224  * UTF-8 contains US-ASCII, hence decoding has the effect of de-quoting
00225  * any quoted US-ASCII characters as well as that of decoding any
00226  * encoded non-US-ASCII characters.  If a decoding error occurs when
00227  * decoding the escaped octets then the erroneous octets are replaced by
00228  * `\uFFFD', the Unicode replacement character.
00229  * <p>
00230  * The String returned by this operation is equal to that returned by the
00231  * GetRawPath operation except that all sequences of escaped octets are
00232  * decoded.
00233  *
00234  * @param this The GATLocation to query
00235  * @return Decoded path component of this GATLocation, or null if path is 
00236  * undefined.
00237  */
00238 char *GATLocation_GetPath(GATLocation_const loc);
00239 
00240 /**
00241  * Returns the raw path component of this GATLocation.
00242  * <p>
00243  * The path component of a URI, if defined, only contains the slash
00244  * character (`/'), the commercial-at character (`@'), and characters in
00245  * the unreserved, punct, escaped, and other categories.
00246  *
00247  * @param this The GATLocation to query
00248  * @return Raw path component of this GATLocation, or null if path is 
00249  * undefined.
00250  */
00251 char *GATLocation_GetRawPath(GATLocation_const loc);
00252  
00253 /**
00254  * Returns the port number of this GATLocation.
00255  * <p>
00256  * The port component of a URI, if defined, is a non-negative  integer.
00257  *
00258  * @param this The GATLocation to query
00259  * @return Port component of this URI, or -1 if the port is undefined.
00260  */
00261 int GATLocation_GetPort(GATLocation_const loc);
00262 
00263 /**
00264  * Returns the decoded query component of this GATLocation.
00265  * <p>
00266  * A sequence of escaped octets is decoded by replacing it with the
00267  * sequence of characters that it represents in the UTF-8 character set.
00268  * UTF-8 contains US-ASCII, hence decoding has the effect of de-quoting
00269  * any quoted US-ASCII characters as well as that of decoding any
00270  * encoded non-US-ASCII characters.  If a decoding error occurs when
00271  * decoding the escaped octets then the erroneous octets are replaced by
00272  * `\uFFFD', the Unicode replacement character.
00273  * <p> 
00274  * The String returned by this operation is equal to that returned by the
00275  * GetRawQuery operation except that all sequences of escaped octets are
00276  * decoded.
00277  *
00278  * @param this The GATLocation to query
00279  * @return Decoded query component of this GATLocation, or null if query 
00280  * is undefined.
00281  */
00282 char *GATLocation_GetQuery(GATLocation_const loc);
00283 
00284 /**
00285  * Returns the raw query component of this GATLocation.
00286  * <p>
00287  * The query component of a URI, if defined, only contains legal URI 
00288  * characters.
00289  *
00290  * @param this The GATLocation to query
00291  * @return Raw query component of this GATLocation, or null if query is 
00292  * undefined.
00293  */
00294 char *GATLocation_GetRawQuery(GATLocation_const loc);
00295 
00296 /**
00297  * Returns the scheme component of this GATLocation.
00298  * <p>
00299  * The scheme component of a URI, if defined, only contains characters
00300  * in the alphanum category and in the String "-.+".  A scheme always
00301  * starts with an alpha character.
00302  * <p>   
00303  * The scheme component of a URI cannot contain escaped octets, hence
00304  * this operation does not perform any decoding.
00305  *
00306  * @param this The GATLocation to query
00307  * @return Scheme component of this GATLocation, or null if scheme is 
00308  * undefined. 
00309  */
00310 char *GATLocation_GetScheme(GATLocation_const loc);
00311 
00312 /**
00313  * Returns the decoded scheme-specific part of this GATLocation.
00314  * <p>
00315  * A sequence of escaped octets is decoded by replacing it with the
00316  * sequence of characters that it represents in the UTF-8 character set.
00317  * UTF-8 contains US-ASCII, hence decoding has the effect of de-quoting
00318  * any quoted US-ASCII characters as well as that of decoding any
00319  * encoded non-US-ASCII characters.  If a decoding error occurs when
00320  * decoding the escaped octets then the erroneous octets are replaced by
00321  * `\uFFFD', the Unicode replacement character. 
00322  * <p>
00323  * The String returned by this operation is equal to that returned by the
00324  * GetRawSchemeSpecificPart operation except that all sequences of escaped
00325  * octets are decoded
00326  *
00327  * @param this The GATLocation to query
00328  * @return Decoded scheme-specific component of this GATLocation (never null)
00329  */
00330 char *GATLocation_GetSchemeSpecificPart(GATLocation_const loc);
00331 
00332 /**
00333  * Returns the raw scheme-specific part of this GATLocation. The
00334  * scheme-specific part is never undefined, though it may be empty.
00335  * <p>
00336  * The scheme-specific part of a URI only contains legal URI characters.
00337  *
00338  * @param this The GATLocation to query
00339  * @return Raw scheme-specific component of this GATLocation (never null).
00340  */
00341 char *GATLocation_GetRawSchemeSpecificPart(GATLocation_const loc);
00342 
00343 /**
00344  * Returns the decoded user-information component of this GATLocation.
00345  * <p>
00346  * A sequence of escaped octets is decoded by replacing it with the
00347  * sequence of characters that it represents in the UTF-8 character set.
00348  * UTF-8 contains US-ASCII, hence decoding has the effect of de-quoting
00349  * any quoted US-ASCII characters as well as that of decoding any
00350  * encoded non-US-ASCII characters.  If a decoding error occurs when
00351  * decoding the escaped octets then the erroneous octets are replaced by
00352  * `\uFFFD', the Unicode replacement character.
00353  * <p> 
00354  * The String returned by this operation is equal to that returned by the
00355  * GetRawUserInfo operation except that all sequences of escaped octets are
00356  * decoded.
00357  *
00358  * @param this The GATLocation to query
00359  * @return Decoded user-information component of this GATLocation, or null 
00360  * if it is undefined.
00361  */
00362 char *GATLocation_GetUserInfo(GATLocation_const loc);
00363 
00364 /**
00365  * Returns the raw user-information component of this GATLocation.
00366  * <p>
00367  * The user-information component of a URI, if defined, only contains
00368  * characters in the unreserved, punct, escaped, and other categories.
00369  *
00370  * @param this The GATLocation to query
00371  * @return Raw user-information component of this GATLocation, or null 
00372  * if it is undefined.
00373  */
00374 char *GATLocation_GetRawUserInfo(GATLocation_const loc);
00375 
00376 /**
00377  * Returns the content of this GATLocation as a String.
00378  * <p>
00379  * A String equivalent to the input string given to the GATLocation
00380  *  constructor, or to the String computed from the originally-given
00381  *  components, as appropriate, is returned.
00382  *
00383  * @param this The GATLocation to query
00384  * @return The string form of this GATLocation
00385  */
00386 char *GATLocation_ToString(GATLocation_const loc);
00387 
00388 /**
00389  *  Returns a deep clone of this GATLocation.
00390  *
00391  * @param this The GATLocation to query
00392  * @return A clone of this GATLocation.
00393  */
00394 int GATLocation_Clone(GATLocation_const loc, GATLocation *new_location);
00395 
00396 /** 
00397  *  Returns the type of the GATLocation
00398  *
00399  *  The function @c GATLocation_GetType always returns GATType_GATLocation. 
00400  *
00401  *  @param object The object to inspect
00402  *
00403  *  @return returns always @c #GATType_GATLocation.
00404  */
00405 GATType GATLocation_GetType(GATLocation_const location);
00406 
00407 
00408 /* GATAdvertiseable API */
00409 #define GATLOCATION_VERSION1    0x0100
00410 #define GATLOCATION_LASTVERSION GATLOCATION_VERSION1
00411 #define GATLOCATION_MINOR_MASK  0x00ff
00412 
00413 /** GATResult  GATLocation_Serialise(GATLocation file, GATObject stream, GATBool clear_dirty)
00414  *  @brief Serialise a GATLocation object
00415  *
00416  *  The function GATLocation_Serialise serialises the given GATLocation object 
00417  *  into the given stream. 
00418  *
00419  *  @param object The GATLocation object to serialise.
00420  *  @param stream The stream interface to use for the serialisation.
00421  *  @param clear_dirty If the clear_dirty parameter is set to GATTrue, the 
00422  *        internal dirty flag of this object is to be reset (no used here)
00423  *
00424  *  @return An error code.
00425  */
00426 GATResult  
00427   GATLocation_Serialise(GATLocation object, GATObject stream, 
00428     GATBool clear_dirty);
00429 
00430 /** GATLocation GATLocation_DeSerialise(GATContext context, GATObject stream, GATBool clear_dirty)
00431  *  @brief De-serialise a GATLocation object
00432  *
00433  *  The function GATLocation_DeSerialise de-serialises a streamed GATLocation   
00434  *  object from the given stream  It constructs a new instance of the 
00435  *  de-serialised object.
00436  *
00437  *  @param context The GAT context to be used for object construction.
00438  *  @param stream The stream interface to use for the serialisation.
00439  *  @param result The pointer to a variable, which receives the status code of
00440  *        the operation.
00441  *
00442  *  @return The newly constructed GATLocation object.
00443  */
00444 GATLocation 
00445   GATLocation_DeSerialise(GATContext context, GATObject stream, 
00446     GATResult *result);
00447 
00448 /** GATLocation_GetIsDirty
00449  *  
00450  *  The function GATLocation_GetIsDirty retrieves the status of the dirty flag 
00451  *  of this GATLocation object.
00452  *
00453  *  @param object The GATLocation object to inspect for its dirty status.
00454  *  @param isdirty The pointer to a variable, which receives the dirty status.
00455  *
00456  *  @return An error code.
00457  */
00458 GATResult  
00459   GATLocation_GetIsDirty(GATLocation_const object, GATBool *isdirty);
00460 
00461 #ifdef __cplusplus
00462 }
00463 #endif
00464 
00465 #endif /* _GATLOCATION_H_ */