/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/facilities/facilities-00-00-04/facilities/bitmanip.h

Go to the documentation of this file.
00001 // $Id: bitmanip.h,v 1.1.1.1 2005/10/17 06:11:40 maqm Exp $
00002 // bitmanip.h
00003 // Author:  Sawyer Gillespie
00004 //          University of Washington, Physics Department
00005 //          March 1999
00006 //          hgillesp@u.washington.edu
00007 //  
00008 //  Defines several inline routines to provide access to various
00009 //  bit-patterns within various words. The functions byte_N return 
00010 //  the Nth byte of a given word counting from low to high bits.
00011 
00012 #ifndef _bitmanip_H__
00013 #define _bitmanip_H__
00014 
00015 #ifdef _MSC_VER
00016 #pragma once
00017 #endif
00018 
00019 namespace bitmanip {
00020 
00021 // template functions for getting/setting four bit words
00022 // i is the word #
00023 // v is the value
00024 // s it the new value
00025 
00026 template <class _T>
00027 inline short int   word ( short i, const _T& v )
00028 {
00029     short   shft = i*4;
00030     _T  mask = 0x000F << shft;
00031     return (v & mask) >> shft;
00032 }
00033 
00034 template <class _T>
00035 void    set_word ( short i, _T& v, const _T& s )
00036 {
00037     short   shft = i*4;
00038     _T  mask = 0x000F << shft;
00039     v = ((v & ~mask) | ((s << shft) & mask));
00040 }
00041 
00042 } // namespace bitmanip
00043 
00044 #endif

Generated on Tue Nov 29 22:57:55 2016 for BOSS_7.0.2 by  doxygen 1.4.7