Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

relation.h

Go to the documentation of this file.
00001 /* -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
00002 /*********************************************************************
00003  *
00004  * Filename : relation.h (base)
00005  *
00006  * Definition of partial order relations between sets or other.
00007  *
00008  * This file is a part of the UPPAAL toolkit.
00009  * Copyright (c) 1995 - 2003, Uppsala University and Aalborg University.
00010  * All right reserved.
00011  *
00012  * $Id: relation.h,v 1.2 2005/04/22 15:20:10 adavid Exp $
00013  *
00014  *********************************************************************/
00015 
00016 #ifndef INCLUDE_BASE_RELATION_H
00017 #define INCLUDE_BASE_RELATION_H
00018 
00019 /** Partial order relations between two sets:
00020  * the values depend on "exactness" of relations.
00021  */
00022 typedef enum
00023 {                       /*   EXACT relation   | NON EXACT relation */
00024                         /*--------------------|--------------------*/
00025     base_DIFFERENT = 0, /**< incomparable     | not (set1 <= set2) */
00026     base_SUPERSET = 1,  /**< set1 > set2      | not used           */
00027     base_GREATER = 1,   /**< same as superset |                    */
00028     base_SUBSET = 2,    /**< set1 < set2      | set1 <= set2       */
00029     base_LESS = 2,      /**< same as subset   |                    */
00030     base_EQUAL = 3      /**< set1 == set2     | not used           */
00031 }
00032 relation_t;
00033 
00034 /* Note: testing <=, ie, relation == base_EQUAL || relation == base_SUBSET
00035  * is equivalent to testing (relation & base_SUBSET). The same applies to
00036  * >=. It is also a good practice to use parenthesis since '&' has a low
00037  * precedence.
00038  */
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 /** @return the symmetric relation (useful when
00045  * swapping arguments for a relation):
00046  * different -> different
00047  * superset -> subset
00048  * subset -> superset
00049  * equal -> equal
00050  * Implementation: invert the superset and subset bits.
00051  * @param rel: relation to invert.
00052  */
00053 static inline
00054 relation_t base_symRelation(relation_t rel)
00055 {
00056     return (relation_t) (((rel >> 1) | (rel << 1)) & 3);
00057 }
00058 
00059 /** Convertion from subset to superset */
00060 static inline
00061 relation_t base_sub2super(relation_t rel)
00062 {
00063     return (relation_t) (rel >> 1);
00064 }
00065 
00066 /** Conversion from superset to subset */
00067 static inline
00068 relation_t base_super2sub(relation_t rel)
00069 {
00070     return (relation_t) ((rel & 1) << 1);
00071 }
00072 
00073 #ifdef __cplusplus
00074 }
00075 #endif
00076 
00077 #endif // INCLUDE_BASE_RELATION_H
00078 

Generated on Fri Jun 30 00:02:30 2006 for Module base by  doxygen 1.4.2