|
||||
File indexing completed on 2025-01-18 10:04:07
0001 // Created on: 1995-09-01 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1995-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Interface_BitMap_HeaderFile 0018 #define _Interface_BitMap_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_Integer.hxx> 0025 #include <TColStd_HArray1OfInteger.hxx> 0026 #include <TColStd_HSequenceOfAsciiString.hxx> 0027 0028 0029 //! A bit map simply allows to associate a boolean flag to each 0030 //! item of a list, such as a list of entities, etc... numbered 0031 //! between 1 and a positive count nbitems 0032 //! 0033 //! The BitMap class allows to associate several binary flags, 0034 //! each of one is identified by a number from 0 to a count 0035 //! which can remain at zero or be positive : nbflags 0036 //! 0037 //! Flags lists over than numflag=0 are added after creation 0038 //! Each of one can be named, hence the user can identify it 0039 //! either by its flag number or by a name which gives a flag n0 0040 //! (flag n0 0 has no name) 0041 class Interface_BitMap 0042 { 0043 public: 0044 0045 DEFINE_STANDARD_ALLOC 0046 0047 0048 //! Creates a empty BitMap 0049 Standard_EXPORT Interface_BitMap(); 0050 0051 //! Creates a BitMap for <nbitems> items 0052 //! One flag is defined, n0 0 0053 //! <resflags> prepares allocation for <resflags> more flags 0054 //! Flags values start at false 0055 Standard_EXPORT Interface_BitMap(const Standard_Integer nbitems, const Standard_Integer resflags = 0); 0056 0057 //! Initialize empty bit by <nbitems> items 0058 //! One flag is defined, n0 0 0059 //! <resflags> prepares allocation for <resflags> more flags 0060 //! Flags values start at false 0061 Standard_EXPORT void Initialize (const Standard_Integer nbitems, const Standard_Integer resflags = 0); 0062 0063 //! Creates a BitMap from another one 0064 //! if <copied> is True, copies data 0065 //! else, data are not copied, only the header object is 0066 Standard_EXPORT Interface_BitMap(const Interface_BitMap& other, const Standard_Boolean copied = Standard_False); 0067 0068 //! Initialize a BitMap from another one 0069 Standard_EXPORT void Initialize (const Interface_BitMap& other, const Standard_Boolean copied = Standard_False); 0070 0071 //! Reservates for a count of more flags 0072 Standard_EXPORT void Reservate (const Standard_Integer moreflags); 0073 0074 //! Sets for a new count of items, which can be either less or 0075 //! greater than the former one 0076 //! For new items, their flags start at false 0077 Standard_EXPORT void SetLength (const Standard_Integer nbitems); 0078 0079 //! Adds a flag, a name can be attached to it 0080 //! Returns its flag number 0081 //! Makes required reservation 0082 Standard_EXPORT Standard_Integer AddFlag (const Standard_CString name = ""); 0083 0084 //! Adds several flags (<more>) with no name 0085 //! Returns the number of last added flag 0086 Standard_EXPORT Standard_Integer AddSomeFlags (const Standard_Integer more); 0087 0088 //! Removes a flag given its number. 0089 //! Returns True if done, false if num is out of range 0090 Standard_EXPORT Standard_Boolean RemoveFlag (const Standard_Integer num); 0091 0092 //! Sets a name for a flag, given its number 0093 //! name can be empty (to erase the name of a flag) 0094 //! Returns True if done, false if : num is out of range, or 0095 //! name non-empty already set to another flag 0096 Standard_EXPORT Standard_Boolean SetFlagName (const Standard_Integer num, const Standard_CString name); 0097 0098 //! Returns the count of flags (flag 0 not included) 0099 Standard_EXPORT Standard_Integer NbFlags() const; 0100 0101 //! Returns the count of items (i.e. the length of the bitmap) 0102 Standard_EXPORT Standard_Integer Length() const; 0103 0104 //! Returns the name recorded for a flag, or an empty string 0105 Standard_EXPORT Standard_CString FlagName (const Standard_Integer num) const; 0106 0107 //! Returns the number or a flag given its name, or zero 0108 Standard_EXPORT Standard_Integer FlagNumber (const Standard_CString name) const; 0109 0110 //! Returns the value (true/false) of a flag, from : 0111 //! - the number of the item 0112 //! - the flag number, by default 0 0113 Standard_EXPORT Standard_Boolean Value (const Standard_Integer item, const Standard_Integer flag = 0) const; 0114 0115 //! Sets a new value for a flag 0116 Standard_EXPORT void SetValue (const Standard_Integer item, const Standard_Boolean val, const Standard_Integer flag = 0) const; 0117 0118 //! Sets a flag to True 0119 Standard_EXPORT void SetTrue (const Standard_Integer item, const Standard_Integer flag = 0) const; 0120 0121 //! Sets a flag to False 0122 Standard_EXPORT void SetFalse (const Standard_Integer item, const Standard_Integer flag = 0) const; 0123 0124 //! Returns the former value for a flag and sets it to True 0125 //! (before : value returned; after : True) 0126 Standard_EXPORT Standard_Boolean CTrue (const Standard_Integer item, const Standard_Integer flag = 0) const; 0127 0128 //! Returns the former value for a flag and sets it to False 0129 //! (before : value returned; after : False) 0130 Standard_EXPORT Standard_Boolean CFalse (const Standard_Integer item, const Standard_Integer flag = 0) const; 0131 0132 //! Initialises all the values of Flag Number <flag> to a given 0133 //! value <val> 0134 Standard_EXPORT void Init (const Standard_Boolean val, const Standard_Integer flag = 0) const; 0135 0136 //! Clear all field of bit map 0137 Standard_EXPORT void Clear(); 0138 0139 0140 0141 0142 protected: 0143 0144 0145 0146 0147 0148 private: 0149 0150 0151 0152 Standard_Integer thenbitems; 0153 Standard_Integer thenbwords; 0154 Standard_Integer thenbflags; 0155 Handle(TColStd_HArray1OfInteger) theflags; 0156 Handle(TColStd_HSequenceOfAsciiString) thenames; 0157 0158 0159 }; 0160 0161 0162 0163 0164 0165 0166 0167 #endif // _Interface_BitMap_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |