]> git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/c++/OSBoolean.h
2116f1420cafe62a8d5b38512f7494442cb675e3
[apple/xnu.git] / libkern / libkern / c++ / OSBoolean.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* OSBoolean.cpp created by rsulack on Tue Oct 12 1999 */
26
27 #ifndef _OS_OSBOOLEAN_H
28 #define _OS_OSBOOLEAN_H
29
30 #include <libkern/c++/OSObject.h>
31
32 class OSString;
33
34 /*!
35 @class OSBoolean
36 @abstract Container class for boolean values.
37 */
38 class OSBoolean : public OSObject
39 {
40 OSDeclareDefaultStructors(OSBoolean)
41
42 protected:
43 bool value;
44
45 /*D @function taggedRelease
46 @abstract Override tagged release mechanism.
47 @param when Unused. */
48 virtual void taggedRelease(const void *tag, const int when) const;
49
50 public:
51 static void initialize();
52
53 /*D
54 @function withBoolean
55 @abstract A static constructor function to create and initialize an instance of OSBoolean.
56 @param value A boolean value.
57 @result Returns and instance of OSBoolean, or 0 if an error occurred.
58 */
59 static OSBoolean *withBoolean(bool value);
60
61 /*D
62 @function free
63 @abstract A member function to release all resources used by the OSBoolean instance.
64 @discussion This function should not be called directly, use release() instead.
65 */
66 virtual void free();
67
68 /*D @function taggedRetain
69 @abstract Override tagged retain mechanism. */
70 virtual void taggedRetain(const void *tag) const;
71
72 /*!
73 @function isTrue
74 @abstract A member function to test if the boolean object is true.
75 @result Returns true if the OSBoolean object is true, false otherwise.
76 */
77 virtual bool isTrue() const;
78 /*!
79 @function isFalse
80 @abstract A member function to test if the boolean object is false.
81 @result Returns true if the OSBoolean object is false, false otherwise.
82 */
83 virtual bool isFalse() const;
84
85 /*!
86 @function getValue
87 @abstract Obtains the value of the OSBoolean object as the standard C++ type bool.
88 @result The value of the OSBoolean object.
89 */
90 virtual bool getValue() const;
91
92 /*!
93 @function isEqualTo
94 @abstract A member function to test the equality of two OSBoolean objects.
95 @param boolean An OSBoolean object to be compared against the receiver.
96 @result Returns true if the two objects are equivalent.
97 */
98 virtual bool isEqualTo(const OSBoolean *boolean) const;
99 /*!
100 @function isEqualTo
101 @abstract A member function to test the equality between an arbitrary OSObject derived object and an OSBoolean object.
102 @param obj An OSObject derived object to be compared against the receiver.
103 @result Returns true if the two objects are equivalent.
104 */
105 virtual bool isEqualTo(const OSMetaClassBase *obj) const;
106
107 /*!
108 @function serialize
109 @abstract A member function which archives the receiver.
110 @param s The OSSerialize object.
111 @result Returns true if serialization was successful, false if not.
112 */
113 virtual bool serialize(OSSerialize *s) const;
114
115 OSMetaClassDeclareReservedUnused(OSBoolean, 0);
116 OSMetaClassDeclareReservedUnused(OSBoolean, 1);
117 OSMetaClassDeclareReservedUnused(OSBoolean, 2);
118 OSMetaClassDeclareReservedUnused(OSBoolean, 3);
119 OSMetaClassDeclareReservedUnused(OSBoolean, 4);
120 OSMetaClassDeclareReservedUnused(OSBoolean, 5);
121 OSMetaClassDeclareReservedUnused(OSBoolean, 6);
122 OSMetaClassDeclareReservedUnused(OSBoolean, 7);
123 };
124
125 /*!
126 @defined kOSBooleanTrue
127 @abstract The OSBoolean constant for "true".
128 @discussion The OSBoolean constant for "true". The object does not need to be retained or released. Comparisons of the form (booleanObject == kOSBooleanTrue) are acceptable and would be equivalent to (booleanObject->getValue() == true).
129 */
130 extern OSBoolean * const & kOSBooleanTrue;
131
132 /*!
133 @defined kOSBooleanFalse
134 @abstract The OSBoolean constant for "false".
135 @discussion The OSBoolean constant for "false". The object does not need to be retained or released. Comparisons of the form (booleanObject == kOSBooleanFalse) are acceptable and would be equivalent to (booleanObject->getValue() == false).
136 */
137 extern OSBoolean * const & kOSBooleanFalse;
138
139 #endif /* !_OS_OSBOOLEAN_H */