OpenQuizz
Une application de gestion des contenus pédagogiques
SlidingWindowMapBuffer Class Reference
Inheritance diagram for SlidingWindowMapBuffer:
Collaboration diagram for SlidingWindowMapBuffer:

Public Member Functions

def __init__ (self, cursor=None, offset=0, size=sys.maxsize, flags=0)
 
def __del__ (self)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_value, traceback)
 
def __len__ (self)
 
def __getitem__ (self, i)
 
def __getslice__ (self, i, j)
 
def begin_access (self, cursor=None, offset=0, size=sys.maxsize, flags=0)
 
def end_access (self)
 
def cursor (self)
 

Detailed Description

A buffer like object which allows direct byte-wise object and slicing into
memory of a mapped file. The mapping is controlled by the provided cursor.

The buffer is relative, that is if you map an offset, index 0 will map to the
first byte at the offset you used during initialization or begin_access

**Note:** Although this type effectively hides the fact that there are mapped windows
underneath, it can unfortunately not be used in any non-pure python method which
needs a buffer or string

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  cursor = None,
  offset = 0,
  size = sys.maxsize,
  flags = 0 
)
Initalize the instance to operate on the given cursor.
:param cursor: if not None, the associated cursor to the file you want to access
    If None, you have call begin_access before using the buffer and provide a cursor
:param offset: absolute offset in bytes
:param size: the total size of the mapping. Defaults to the maximum possible size
    From that point on, the __len__ of the buffer will be the given size or the file size.
    If the size is larger than the mappable area, you can only access the actually available
    area, although the length of the buffer is reported to be your given size.
    Hence it is in your own interest to provide a proper size !
:param flags: Additional flags to be passed to os.open
:raise ValueError: if the buffer could not achieve a valid state

◆ __del__()

def __del__ (   self)

Member Function Documentation

◆ __enter__()

def __enter__ (   self)

◆ __exit__()

def __exit__ (   self,
  exc_type,
  exc_value,
  traceback 
)

◆ __getitem__()

def __getitem__ (   self,
  i 
)

◆ __getslice__()

def __getslice__ (   self,
  i,
  j 
)

◆ __len__()

def __len__ (   self)

◆ begin_access()

def begin_access (   self,
  cursor = None,
  offset = 0,
  size = sys.maxsize,
  flags = 0 
)
Call this before the first use of this instance. The method was already
called by the constructor in case sufficient information was provided.

For more information no the parameters, see the __init__ method
:param path: if cursor is None the existing one will be used.
:return: True if the buffer can be used

◆ cursor()

def cursor (   self)
:return: the currently set cursor which provides access to the data

◆ end_access()

def end_access (   self)
Call this method once you are done using the instance. It is automatically
called on destruction, and should be called just in time to allow system
resources to be freed.

Once you called end_access, you must call begin access before reusing this instance!

The documentation for this class was generated from the following file: