GL Studio Safety Critical Embedded C++ Runtime Library
gls_class_invariant.h
Go to the documentation of this file.
1 #ifndef _GLS_CLASS_INVARIANT_H
2 #define _GLS_CLASS_INVARIANT_H
3 
4 /*! \file gls_class_invariant.h
5 \brief This header defines a GLS_DEBUG only macro for facilitating evaluating class invariants in
6  the GL Studio DO-178B Runtime Library.
7 
8 \par Copyright Information
9 Copyright (C) 1999-2012 The DiSTI Corporation<br>
10 Orlando, FL USA<br>
11 All rights reserved.<br>
12 
13  This file is copyrighted software and contains proprietary trade secrets of
14 DiSTI, and embodies substantial creative efforts as well as confidential
15 information, ideas, and expressions.
16 
17  Permission to use, and copy this software and its documentation for any
18 purpose is hereby granted per the Distribution Agreement and/or the Licensing
19 Agreement signed with DiSTI. This permission is granted provided that:
20  1. The above copyright notice appears in all copies.
21  2. That both the copyright notice and this permission notice appear in
22  the supporting documentation.
23  3. That the names DiSTI and GL Studio not be used in advertising or
24  publicity pertaining to distribution of the software without specific,
25  written prior permission of DiSTI.
26 
27  Permission to modify the software is granted, but not the right to
28 distribute the source code whether modified, or non-modified. Modifying the
29 software might invalidate the DO-178B certification package.
30 
31  Permission to distribute binaries produced by compiling source code, or
32 modified source code is granted, provided you:
33  1. Provide your name and address as the primary contact for the support
34  of your modified version.
35  2. Retain our contact information in regard to use of the base software.
36 
37  DiSTI does not provide warranty for this software or guarantee that it
38 satisfies any specification or requirement unless otherwise stated in a
39 specific contractual arrangement between the customer and DiSTI.
40 
41 */
42 
43 #include "gls_include.h"
44 
45 #if defined( GLS_DEBUG )
46 
47 /** declare a nested ClassInvariant evaluator class for a class named ClassName */
48 #define GLS_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  virtual void Invariant( void ) const;
67 
68 /** declare an instance of a ClassInvariant evaluator for a class named ClassName */
69 #define GLS_CLASS_INVARIANT_CHECK( ClassName ) ClassName::ClassInvariant localScopeClassInvariant( *this )
70 
71 /** explicitly call ( non virtual call ) invariant method on the class named ClassName.
72  * Typically used at the end of a constructor to ensure invariant for this class without
73  * checking a subclass invariant through a virtual call to a class that is not constructed
74  * yet. */
75 #define GLS_CLASS_INVARIANT_EVALUATE( ClassName ) ClassName::Invariant()
76 
77 #else // GLS_DEBUG is not defined
78 
79 /** ClassInvariant evaluator class is disabled when GLS_DEBUG is not defined */
80 #define GLS_CLASS_INVARIANT_DECLARATION( ClassName )
81 #define GLS_CLASS_INVARIANT_CHECK( ClassName )
82 #define GLS_CLASS_INVARIANT_EVALUATE( ClassName )
83 
84 #endif // GLS_DEBUG
85 
86 #endif // _GLS_CLASS_INVARIANT_H
This header defines any preprocessor defines needed to configure the GL Studio DO-178B Runtime Librar...