BitfieldHelper.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00024 //----------------------------------------------------------------------
00025 #ifndef ICL_CORE_BITFIELD_HELPER_H_INCLUDED
00026 #define ICL_CORE_BITFIELD_HELPER_H_INCLUDED
00027 
00028 #include "icl_core/TemplateHelper.h"
00029 
00030 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00031 # include "icl_core/Deprecate.h"
00032 #endif
00033 
00034 namespace icl_core {
00035 
00039 template <typename T>
00040 void setBits(int bits, typename ConvertToRef<T>::ToRef bitfield)
00041 {
00042   bitfield = T(int(bitfield) | bits);
00043 }
00044 
00048 template <typename T>
00049 void clearBits(int bits, typename ConvertToRef<T>::ToRef bitfield)
00050 {
00051   bitfield = T(int(bitfield) & ~bits);
00052 }
00053 
00057 template <typename T>
00058 bool isBitSet(int bit, typename ConvertToRef<T>::ToConstRef bitfield)
00059 {
00060   return (bitfield & T(bit)) != 0;
00061 }
00062 
00064 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00065 
00070 template <typename T>
00071 void SetBits(int bits, typename ConvertToRef<T>::ToRef bitfield) ICL_CORE_GCC_DEPRECATE_STYLE;
00072 template <typename T>
00073 ICL_CORE_VC_DEPRECATE_STYLE void SetBits(int bits, typename ConvertToRef<T>::ToRef bitfield)
00074 {
00075   setBits(bits, bitfield);bitfield = T(int(bitfield) | bits);
00076 }
00077 
00082 template <typename T>
00083 void ClearBits(int bits, typename ConvertToRef<T>::ToRef bitfield) ICL_CORE_GCC_DEPRECATE_STYLE;
00084 template <typename T>
00085 ICL_CORE_VC_DEPRECATE_STYLE void ClearBits(int bits, typename ConvertToRef<T>::ToRef bitfield)
00086 {
00087   clearBits(bits, bitfield);
00088 }
00089 
00094 template <typename T>
00095 bool IsBitSet(int bit, typename ConvertToRef<T>::ToConstRef bitfield) ICL_CORE_GCC_DEPRECATE_STYLE;
00096 template <typename T>
00097 ICL_CORE_VC_DEPRECATE_STYLE bool IsBitSet(int bit, typename ConvertToRef<T>::ToConstRef bitfield)
00098 {
00099   return isBitSet(bit, bitfield);
00100 }
00101 
00102 #endif
00103 
00104 
00105 }
00106 
00107 #endif


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:18