FlagUser Class Reference

FlagUser Class Reference

#include <mncommon.h>

Class Description

See also
Class MNMesh.

Description:
This is a handy class to subclass off of when you're designing a class with flags. It contains one private data member, a DWORD, with the flag info. It then implements a bunch of handy flag-related functions. All methods of this class are implemented by the system.
Data Members:
private:

DWORD FlagUserFlags;

Stores the flags.
+ Inheritance diagram for FlagUser:

Public Member Functions

 FlagUser ()
 
void SetFlag (DWORD fl, bool val=TRUE)
 
void ClearFlag (DWORD fl)
 
bool GetFlag (DWORD fl) const
 
void ClearAllFlags ()
 
void CopyFlags (DWORD fl)
 
void CopyFlags (const FlagUser &fu)
 
void CopyFlags (const FlagUser *fu)
 
void CopyFlags (DWORD fl, DWORD mask)
 
void CopyFlags (const FlagUser &fu, DWORD mask)
 
void CopyFlags (const FlagUser *fu, DWORD mask)
 
void OrFlags (const FlagUser &fu)
 
void OrFlags (const FlagUser *fu)
 
void AndFlags (const FlagUser &fu)
 
void AndFlags (const FlagUser *fu)
 
bool FlagMatch (DWORD fmask, DWORD fl) const
 
bool FlagMatch (DWORD fmask, const FlagUser &fu) const
 
bool FlagMatch (DWORD fmask, const FlagUser *fu) const
 
DWORD ExportFlags () const
 
void ImportFlags (DWORD fl)
 
IOResult WriteFlags (ISave *isave, ULONG *nb) const
 
IOResult ReadFlags (ILoad *iload, ULONG *nb)
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Constructor & Destructor Documentation

FlagUser ( )
inline
Remarks
Constructor. Sets FlagUserFlags to 0, clearing all flag bits.
42 { FlagUserFlags=0; }

Member Function Documentation

void SetFlag ( DWORD  fl,
bool  val = TRUE 
)
inline
Remarks
Sets flags. Each bit that is set in fl is assigned the value val.
45 { if (val) FlagUserFlags |= fl; else FlagUserFlags -= (FlagUserFlags & fl); }
void ClearFlag ( DWORD  fl)
inline
Remarks
Clears flags. Each bit that is set in fl is cleared.
47 { FlagUserFlags -= (FlagUserFlags & fl); }
bool GetFlag ( DWORD  fl) const
inline
Remarks
Checks if flags are set.
Returns
TRUE if any of the bits set in fl are set in this FlagUser. FALSE if none of them are.
51 { return (FlagUserFlags & fl) ? 1 : 0; }
void ClearAllFlags ( )
inline
Remarks
Sets FlagUserFlags to 0, clearing all flag bits.
53 { FlagUserFlags = 0; }
void CopyFlags ( DWORD  fl)
inline
Remarks
Copies all flag bits over from fl.
56 { FlagUserFlags = fl; }
void CopyFlags ( const FlagUser fu)
inline
Remarks
Copies all flag bits over from fu.
58 { FlagUserFlags = fu.FlagUserFlags; }
void CopyFlags ( const FlagUser fu)
inline
Remarks
Copies all flag bits over from *fu.
60 { FlagUserFlags = fu->FlagUserFlags; }
void CopyFlags ( DWORD  fl,
DWORD  mask 
)
inline
Remarks
Copies from fl only those bits set in mask.
63 { FlagUserFlags |= (fl & mask); }
void CopyFlags ( const FlagUser fu,
DWORD  mask 
)
inline
Remarks
Copies from fu only those bits set in mask.
65 { FlagUserFlags |= (fu.FlagUserFlags & mask); }
void CopyFlags ( const FlagUser fu,
DWORD  mask 
)
inline
Remarks
Copies from *fu only those bits set in mask.
67 { FlagUserFlags |= (fu->FlagUserFlags & mask); }
void OrFlags ( const FlagUser fu)
inline
Remarks
Sets all flags that are set in fu.
70 { FlagUserFlags |= fu.FlagUserFlags; }
void OrFlags ( const FlagUser fu)
inline
Remarks
Sets all flags that are set in *fu.
72 { FlagUserFlags |= fu->FlagUserFlags; }
void AndFlags ( const FlagUser fu)
inline
Remarks
Clears all flags that are clear in fu.
75 { FlagUserFlags &= fu.FlagUserFlags; }
void AndFlags ( const FlagUser fu)
inline
Remarks
Clears all flags that are clear in *fu.
77 { FlagUserFlags &= fu->FlagUserFlags; }
bool FlagMatch ( DWORD  fmask,
DWORD  fl 
) const
inline
Remarks
Checks whether all the bits that are set in fmask are the same in this FlagUser and in fl.
81  {
82  return ((FlagUserFlags & fmask) == (fl & fmask));
83  }
bool FlagMatch ( DWORD  fmask,
const FlagUser fu 
) const
inline
Remarks
Checks whether all the bits that are set in fmask are the same in this FlagUser and in fu.
86  {
87  return ((FlagUserFlags & fmask) == (fu.FlagUserFlags & fmask));
88  }
bool FlagMatch ( DWORD  fmask,
const FlagUser fu 
) const
inline
Remarks
Checks whether all the bits that are set in fmask are the same in this FlagUser and in *fu.
91  {
92  return ((FlagUserFlags & fmask) == (fu->FlagUserFlags & fmask));
93  }
DWORD ExportFlags ( ) const
inline
Remarks
Returns a DWORD equal to FlagUserFlags.
96 { return FlagUserFlags; }
void ImportFlags ( DWORD  fl)
inline
Remarks
Sets FlagUserFlags equal to fl. Same as CopyFlags (fl), but it's included for "linguistic completeness".
99 { FlagUserFlags = fl; }
IOResult WriteFlags ( ISave isave,
ULONG *  nb 
) const
inline
101  {
102  return isave->Write(&FlagUserFlags, sizeof(DWORD), nb);
103  }
IOResult Write(const char *buf, ULONG nbytes, ULONG *nwrit)
Definition: ioapi.h:230
IOResult ReadFlags ( ILoad iload,
ULONG *  nb 
)
inline
104  {
105  return iload->Read (&FlagUserFlags, sizeof(DWORD), nb);
106  }
IOResult Read(const char *buf, ULONG nbytes, ULONG *nwrit)
Definition: ioapi.h:517