DataDirector API
DDD_ClassInvariant.h
Go to the documentation of this file.
1 #ifndef _DDD_CLASS_INVARIANT_H
2 #define _DDD_CLASS_INVARIANT_H
3 
4 /*! \file DDD_ClassInvariant.h
5  \brief This header defines a DDD_DEBUG only macro for facilitating evaluating class invariants in
6  the Data Director Runtime Library.
7 
8  \par Copyright Information
9 
10  Copyright (c) 2012 The DiSTI Corporation.<br>
11  11301 Corporate Blvd; Suite 100<br>
12  Orlando, Florida 32817<br>
13  USA<br>
14  <br>
15  All rights reserved.<br>
16 
17  This Software contains proprietary trade secrets of DiSTI and may not be
18 reproduced, in whole or part, in any form, or by any means of electronic,
19 mechanical, or otherwise, without the written permission of DiSTI. Said
20 permission may be derived through the purchase of applicable DiSTI product
21 licenses which detail the distribution rights of this content and any
22 Derivative Works based on this or other copyrighted DiSTI Software.
23 
24  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
25 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
26 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
27 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
28 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
29 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
30 
31  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
32 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
33 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
34 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
35 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
36 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
37 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
38 EXCEED FIVE DOLLARS (US$5.00).
39 
40  The aforementioned terms and restrictions are governed by the laws of the
41 State of Florida and the United States of America.
42 
43 */
44 
45 #if defined( DDD_DEBUG )
46 
47 /** declare a nested ClassInvariant evaluator class for a class named ClassName */
48 #define DDD_CLASS_INVARIANT_DECLARATION( ClassName ) \
49  class ClassInvariant \
50  { \
51  public: \
52  ClassInvariant( const ClassName &inst ) : \
53  _inst( inst ) \
54  { \
55  _inst.Invariant(); \
56  } \
57  \
58  ~ClassInvariant() \
59  { \
60  _inst.Invariant(); \
61  } \
62  \
63  protected: \
64  const ClassName &_inst; \
65  };
66 
67 /** declare an instance of a ClassInvariant evaluator for a class named ClassName */
68 #define DDD_CLASS_INVARIANT_CHECK( ClassName ) ClassName::ClassInvariant localScopeClassInvariant( *this )
69 
70 /** explicitly call ( non virtual call ) invariant method on the class named ClassName.
71  * Typically used at the end of a constructor to ensure invariant for this class without
72  * checking a subclass invariant through a virtual call to a class that is not constructed
73  * yet. */
74 #define DDD_CLASS_INVARIANT_EVALUATE( ClassName ) ClassName::Invariant()
75 
76 #else // GLS_DEBUG is not defined
77 
78 /** ClassInvariant evaluator class is disabled when GLS_DEBUG is not defined */
79 #define DDD_CLASS_INVARIANT_DECLARATION( ClassName )
80 #define DDD_CLASS_INVARIANT_CHECK( ClassName )
81 #define DDD_CLASS_INVARIANT_EVALUATE( ClassName )
82 
83 #endif // GLS_DEBUG
84 
85 #endif // _GLS_CLASS_INVARIANT_H
86