Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:16:56

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 <NCollection_Array1.hxx>
0026 #include <NCollection_HArray1.hxx>
0027 #include <TCollection_AsciiString.hxx>
0028 #include <NCollection_Sequence.hxx>
0029 #include <NCollection_HSequence.hxx>
0030 
0031 //! A bit map simply allows to associate a boolean flag to each
0032 //! item of a list, such as a list of entities, etc... numbered
0033 //! between 1 and a positive count nbitems
0034 //!
0035 //! The BitMap class allows to associate several binary flags,
0036 //! each of one is identified by a number from 0 to a count
0037 //! which can remain at zero or be positive : nbflags
0038 //!
0039 //! Flags lists over than numflag=0 are added after creation
0040 //! Each of one can be named, hence the user can identify it
0041 //! either by its flag number or by a name which gives a flag n0
0042 //! (flag n0 0 has no name)
0043 class Interface_BitMap
0044 {
0045 public:
0046   DEFINE_STANDARD_ALLOC
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 int nbitems, const int 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 int nbitems, const int 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 bool copied = false);
0067 
0068   //! Initialize a BitMap from another one
0069   Standard_EXPORT void Initialize(const Interface_BitMap& other, const bool copied = false);
0070 
0071   //! Reservates for a count of more flags
0072   Standard_EXPORT void Reservate(const int 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 int 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 int AddFlag(const char* const name = "");
0083 
0084   //! Adds several flags (<more>) with no name
0085   //! Returns the number of last added flag
0086   Standard_EXPORT int AddSomeFlags(const int more);
0087 
0088   //! Removes a flag given its number.
0089   //! Returns True if done, false if num is out of range
0090   Standard_EXPORT bool RemoveFlag(const int 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 bool SetFlagName(const int num, const char* const name);
0097 
0098   //! Returns the count of flags (flag 0 not included)
0099   Standard_EXPORT int NbFlags() const;
0100 
0101   //! Returns the count of items (i.e. the length of the bitmap)
0102   Standard_EXPORT int Length() const;
0103 
0104   //! Returns the name recorded for a flag, or an empty string
0105   Standard_EXPORT const char* FlagName(const int num) const;
0106 
0107   //! Returns the number or a flag given its name, or zero
0108   Standard_EXPORT int FlagNumber(const char* const 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 bool Value(const int item, const int flag = 0) const;
0114 
0115   //! Sets a new value for a flag
0116   Standard_EXPORT void SetValue(const int item, const bool val, const int flag = 0) const;
0117 
0118   //! Sets a flag to True
0119   Standard_EXPORT void SetTrue(const int item, const int flag = 0) const;
0120 
0121   //! Sets a flag to False
0122   Standard_EXPORT void SetFalse(const int item, const int 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 bool CTrue(const int item, const int 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 bool CFalse(const int item, const int 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 bool val, const int flag = 0) const;
0135 
0136   //! Clear all field of bit map
0137   Standard_EXPORT void Clear();
0138 
0139 private:
0140   int                                                         thenbitems;
0141   int                                                         thenbwords;
0142   int                                                         thenbflags;
0143   occ::handle<NCollection_HArray1<int>>                       theflags;
0144   occ::handle<NCollection_HSequence<TCollection_AsciiString>> thenames;
0145 };
0146 
0147 #endif // _Interface_BitMap_HeaderFile