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