@epoch:

Since I've never done ANY OO programming, I thought this would be a
good first attempt: a binary pipe class.  Do you think something like
this would fit the bill?


Code:
--------------------
    
  bPipe:  a class for manipulation of binary pipes..
  
  Binary pipes: an array of 1 or more 32bit unsigned integers plus an initial 
element holding a hash with:
  
        guidPipeID              => guid,        # Serial number of the pipe.
        value                   => 0,           # A bigint representation of 
the pipe.
        nPipeLength             => 0,           # number of bits of this pipe.
        nPipeTopMask            => 0,           # The bit mask to discard 
unneeded bits from the topmost segment of the pipe.
        nPipeArbMask            => 0,           # An arbitrary mask value.
        nCreate                 => 0,           # time() at creation.
        nLastAccess             => 0,           # time() at last access.
        nLastUpdate             => 0,           # time() at last update.
        bLocked                 => 0 || 1,      # Lock the pipe (don't allow 
updates).
        bHidden                 => 0 || 1,      # Don't allow access to the 
pipe (except to unlock the pipe (which requires the guid).
        timers                  => @timers,     # An array of timer objects 
which will cause the pipe to update itself.
  
  
        Methods:
  
        my $bPipe = Pipe::new($nLength);        # Creates a new pipe object of 
$nLength bit length.  Initializes an array of int(roundup(($nLength / 32)) 
unsigned ints;
                                                # Initializes the attribute 
hash.  Creates the nPipeTopMask.  Initializes nPipeID
                                                # Pushes the attribute hash 
onto the int array.
                                                # Returns the new binary pipe 
object.
  
        $bPipe->attr([attribute], [$newValue]); # Returns a hash of pipe 
attributes.  $bPipe->attr('nPipeWidth') returns the length of the pipe, etc.
                                                # If $newValue is defined, sets 
the attribute with $newValue.  In the case of:
                                                # $bPipe->attr('nPipeLength', 
$newLength), this can be used to grow or shrink the length of the pipe.
  
        $bPipe->push( [$bValue] );              # Increments the pipe, 
discarding the top bit ( bit at $bPipe->attr('nPipelength') ) and setting the 
bottom bit to !!$bValue.
                                                # Returns (new bottom bit, 
discarded top bit).
  
        $bPipe->pop( [$bValue] );               # Decrements the pipe, setting 
the top bit to !!$bValue and disarding the bottom bit.
                                                # Returns (discarded bottom 
bit, new top bit).
  
        $bPipe->set([$nPosition], [$bValue]);   # Sets the bit at $nPosition to 
!!$bValue.
                                                # If $nPosition is undefined, 
then sets the bottom bit to !!$bValue.
  
        $bPipe->clear([$nPosition]);            # Clears the bit at $nPosition. 
 If $nPosition is undefined, clears the entire pipe.
  
        $bPipe->read([$nPosition]);             # Returns the bit value at 
$nPosition.  If $nPosition is undefined, returns a bigint representation of the 
whole pipe.
  
        $bPipe->readbstr([$nPosition]);         # Returns a bigint binary 
string of nPipeLength showing a representation of the pipe.  If $nPosition is 
defined,
                                                                                
                                        # returns the string with all bits set 
to 0 except for the bit at $nPosition (i.e. a binary mask).
  
        $bPipe->readhstr([$nPosition]);         # Returns a bigint hex string 
representation of the pipe.  If $nPosition is defined,
                                                                                
                                        # returns the string with all bits set 
to 0 except for the bit at $nPosition (i.e. a binary mask).
  
        $bPipe->IsEmpty();                      # Checks to see if any bit at 
any position in any element of the pipe array is set..
  
        $bPipe->lock($nPipeID);                 # Locks the pipe to prevent 
updates. $nPipeID must == $bPipe->attr('guidPipeID');
                                                # Returns 1, success, 0 failure.
  
        $bPipe->unlock($nPipeID);               # Unlocks the pipe to permit 
updates. $nPipeID must == $bPipe->attr('guidPipeID');
                                                # Returns 1, success, 0 failure.
  
        $bPipe->hide($nPipeID);                 # Hides the pipe, preventing 
updates or reads.  $nPipeID must == $bPipe->attr('guidPipeID');
                                                # Returns 1, success, 0 failure.
  
        $bPipe->unhide($nPipeID);               # Unhides the pipe, allowing 
updates and reads.  $nPipeID must == $bPipe->attr('guidPipeID');
                                                # Returns 1, success, 0 failure.
  
  
        $bPipe->CreateTimer(method, when, [freq], [bRepeat],   
Code:
--------------------
    ref     [@args]);
                                                                                
                                        # Creates a timer object in $bPipe so 
that $bPipe can update itself.
                                                                                
                                        # Returns a timer id;
    
        $bPipe->DestroyTimer($idTimer);         # Destroys the $idTimer timer 
object in $bPipe.
    
    
    
--------------------


-- 
gharris999
------------------------------------------------------------------------
gharris999's Profile: http://forums.slimdevices.com/member.php?userid=115
View this thread: http://forums.slimdevices.com/showthread.php?t=49028

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to