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