The Road to Clang-Format part 1
Whitespace: The Darkening
Change-Id: I9c0c355ddf22f9b27763c97e3e85079c135ae7a7
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/src/chip_data/hei_chip_data.hpp b/src/chip_data/hei_chip_data.hpp
index 0e8bbc2..685ed12 100644
--- a/src/chip_data/hei_chip_data.hpp
+++ b/src/chip_data/hei_chip_data.hpp
@@ -5,4 +5,4 @@
namespace libhei
{
-} //end namespace libhei
+} // end namespace libhei
diff --git a/src/chip_data/hei_chip_data_stream.hpp b/src/chip_data/hei_chip_data_stream.hpp
index 6d4d303..25b8635 100755
--- a/src/chip_data/hei_chip_data_stream.hpp
+++ b/src/chip_data/hei_chip_data_stream.hpp
@@ -4,7 +4,8 @@
@file hei_chip_data_stream.hpp
@brief Description: The ChipDataStream class
-ChipDataStream makes it possible to read a buffer of binary data using the stream operators, ">>".
+ChipDataStream makes it possible to read a buffer of binary data using the
+stream operators, ">>".
Instantiate ChipDataStream class with a pointer to a data buffer
and its size in bytes as below:
@@ -26,154 +27,155 @@
{
/**
-* ChipDataStream
-* ChipDataStream offers convenient stream operator access to binary data.
-**/
+ * ChipDataStream
+ * ChipDataStream offers convenient stream operator access to binary data.
+ **/
class ChipDataStream
{
private:
- /** iv_buffer points to the first address of the Chip Data File
- buffer. **/
- const void * const iv_buffer;
- /** iv_bufferSize is the size of the data buffer. It is
- initialized when the ChipDataStream class is instantiated. **/
- const size_t iv_bufferSize;
- /** iv_asyncOffset keeps an offset into the buffer. This
- offset is incremented appropriately as data is read. **/
- size_t iv_asyncOffset;
+ /** iv_buffer points to the first address of the Chip Data File
+ buffer. **/
+ const void * const iv_buffer;
+ /** iv_bufferSize is the size of the data buffer. It is
+ initialized when the ChipDataStream class is instantiated. **/
+ const size_t iv_bufferSize;
+ /** iv_asyncOffset keeps an offset into the buffer. This
+ offset is incremented appropriately as data is read. **/
+ size_t iv_asyncOffset;
public:
- /* Constructors */
+ /* Constructors */
- /**
- When instantiating the ChipDataStream object a pointer to a
- data buffer containing all the data and its size is passed
- into the class.
- **/
- ChipDataStream(void * i_buffer, size_t i_bufferSize) :
- iv_asyncOffset(0), iv_buffer(i_buffer), iv_bufferSize(i_bufferSize) {}
+ /**
+ When instantiating the ChipDataStream object a pointer to a
+ data buffer containing all the data and its size is passed
+ into the class.
+ **/
+ ChipDataStream(void * i_buffer, size_t i_bufferSize) :
+ iv_asyncOffset(0), iv_buffer(i_buffer), iv_bufferSize(i_bufferSize)
+ {}
- /** Eliminate copy and assignment operator constructors **/
- ChipDataStream ( const ChipDataStream & ) = delete;
- ChipDataStream & operator=( const ChipDataStream & ) = delete;
+ /** Eliminate copy and assignment operator constructors **/
+ ChipDataStream(const ChipDataStream &) = delete;
+ ChipDataStream & operator=(const ChipDataStream &) = delete;
- /** Destructor **/
+ /** Destructor **/
- ~ChipDataStream() = default;
+ ~ChipDataStream() = default;
- /** Functions **/
+ /** Functions **/
- /**
- *@brief Default case for "operator>>" template.
- *@param D: A type
- *@param o_right: A pointer to where the data is stored
- *@return *this: A pointer to "this" object
- **/
- template <class D>
- ChipDataStream & operator>>( D & o_right )
- {
- read( &o_right, sizeof(D) );
- return *this;
- }
+ /**
+ *@brief Default case for "operator>>" template.
+ *@param D: A type
+ *@param o_right: A pointer to where the data is stored
+ *@return *this: A pointer to "this" object
+ **/
+ template <class D>
+ ChipDataStream & operator>>(D & o_right)
+ {
+ read(&o_right, sizeof(D));
+ return *this;
+ }
private:
- /**
- *@brief Read does the copy from the buffer
- *@param o_buf a pointer to the location to copy to
- *@param i_size the size (in bytes) to copy
- *@return None\n\n
- **/
- void read( void * o_buf, size_t i_size )
- {
- /* Ensure memory is not accessed outside i_buffer */
- HEI_ASSERT((iv_asyncOffset + i_size) <= iv_bufferSize);
- /* Copy appropriate bytes from i_buffer to o_buff */
- memcpy(o_buf,(char *)iv_buffer+iv_asyncOffset,i_size);
- /* Increment asynchronous offset to next piece of data */
- iv_asyncOffset = iv_asyncOffset + i_size;
- }
+ /**
+ *@brief Read does the copy from the buffer
+ *@param o_buf a pointer to the location to copy to
+ *@param i_size the size (in bytes) to copy
+ *@return None\n\n
+ **/
+ void read(void * o_buf, size_t i_size)
+ {
+ /* Ensure memory is not accessed outside i_buffer */
+ HEI_ASSERT((iv_asyncOffset + i_size) <= iv_bufferSize);
+ /* Copy appropriate bytes from i_buffer to o_buff */
+ memcpy(o_buf, (char *)iv_buffer + iv_asyncOffset, i_size);
+ /* Increment asynchronous offset to next piece of data */
+ iv_asyncOffset = iv_asyncOffset + i_size;
+ }
};
/*
-* Note: The specializations below ensure the big-endian Chip Data File
-* format is converted into the host format.
-*/
+ * Note: The specializations below ensure the big-endian Chip Data File
+ * format is converted into the host format.
+ */
/**
-* @brief This template extracts a uint16_t data type from the data buffer
-* @param o_right: A pointer to where the data is stored
-* @return *this: A pointer to "this" object
-**/
+ * @brief This template extracts a uint16_t data type from the data buffer
+ * @param o_right: A pointer to where the data is stored
+ * @return *this: A pointer to "this" object
+ **/
template <> inline
- ChipDataStream & ChipDataStream::operator>>( uint16_t & o_right )
- {
- read( &o_right, sizeof(o_right));
- be16toh( o_right );
- return *this;
- }
+ChipDataStream & ChipDataStream::operator>>(uint16_t & o_right)
+{
+ read(&o_right, sizeof(o_right));
+ be16toh(o_right);
+ return *this;
+}
/**@brief This template extracts an int16_t type from the data buffer
-* @param o_right: A pointer to where the data is stored
-* @return *this: A pointer to "this" object
-**/
+ * @param o_right: A pointer to where the data is stored
+ * @return *this: A pointer to "this" object
+ **/
template <> inline
- ChipDataStream & ChipDataStream::operator>>( int16_t & o_right )
- {
- read( &o_right, sizeof(o_right) );
- be16toh( o_right );
- return *this;
- }
+ChipDataStream & ChipDataStream::operator>>(int16_t & o_right)
+{
+ read(&o_right, sizeof(o_right));
+ be16toh(o_right);
+ return *this;
+}
/**@brief This template extracts a uint32_t type from the data buffer
-* @param o_right: A pointer to where the data is stored
-* @return *this: A pointer to "this" object
-**/
+ * @param o_right: A pointer to where the data is stored
+ * @return *this: A pointer to "this" object
+ **/
template <> inline
- ChipDataStream & ChipDataStream::operator>>( uint32_t & o_right )
- {
- read( &o_right, sizeof(o_right) );
- be32toh( o_right );
- return *this;
- }
+ChipDataStream & ChipDataStream::operator>>(uint32_t & o_right)
+{
+ read(&o_right, sizeof(o_right));
+ be32toh(o_right);
+ return *this;
+}
/**@brief This template extracts an int32_t type from the data buffer
-* @param o_right: A pointer to where the data is stored
-* @return *this: A pointer to "this" object
-**/
+ * @param o_right: A pointer to where the data is stored
+ * @return *this: A pointer to "this" object
+ **/
template <> inline
- ChipDataStream & ChipDataStream::operator>>( int32_t & o_right )
- {
- read( &o_right, sizeof(o_right) );
- be32toh( o_right );
- return *this;
- }
+ChipDataStream & ChipDataStream::operator>>(int32_t & o_right)
+{
+ read(&o_right, sizeof(o_right));
+ be32toh(o_right);
+ return *this;
+}
/**@brief This template extracts a uint64_t type from the data buffer
-* @param o_right: A pointer to where the data is stored
-* @return *this: A pointer to "this" object
-**/
+ * @param o_right: A pointer to where the data is stored
+ * @return *this: A pointer to "this" object
+ **/
template <> inline
- ChipDataStream & ChipDataStream::operator>>( uint64_t & o_right )
- {
- read( &o_right, sizeof(o_right) );
- be64toh( o_right );
- return *this;
- }
+ChipDataStream & ChipDataStream::operator>>(uint64_t & o_right)
+{
+ read(&o_right, sizeof(o_right));
+ be64toh(o_right);
+ return *this;
+}
/**@brief This template extracts an int64_t type from the data buffer
-* @param o_right: A pointer to where the data is stored
-* @return *this: A pointer to "this" object
-**/
+ * @param o_right: A pointer to where the data is stored
+ * @return *this: A pointer to "this" object
+ **/
template <> inline
- ChipDataStream & ChipDataStream::operator>>( int64_t & o_right )
- {
- read( &o_right, sizeof(o_right) );
- be64toh( o_right );
- return *this;
- }
+ChipDataStream & ChipDataStream::operator>>(int64_t & o_right)
+{
+ read(&o_right, sizeof(o_right));
+ be64toh(o_right);
+ return *this;
+}
-} /** namespace libhei **/
+} // namespace libhei
diff --git a/src/hei_chip.hpp b/src/hei_chip.hpp
index 38a4ba2..216a4cc 100644
--- a/src/hei_chip.hpp
+++ b/src/hei_chip.hpp
@@ -17,16 +17,16 @@
~Chip() = default;
- Chip( const Chip & ) = default;
+ Chip(const Chip &) = default;
- Chip & operator=( const Chip & ) = default;
+ Chip & operator=(const Chip &) = default;
/**
* @brief Constructor.
* @param i_chip See description for iv_chip.
* @param i_type See description for iv_type.
*/
- Chip( void * i_chip, ChipType_t i_type ) :
+ Chip(void * i_chip, ChipType_t i_type) :
iv_chip(i_chip), iv_type(i_type)
{}
@@ -38,17 +38,16 @@
public: // Operators
- bool operator==( const Chip & r ) const
+ bool operator==(const Chip & r) const
{
return (iv_chip == r.iv_chip) &&
(iv_type == r.iv_type);
}
- bool operator<( const Chip & r ) const
+ bool operator<(const Chip & r) const
{
- return ( iv_chip < r.iv_chip ) ||
- ( (iv_chip == r.iv_chip) &&
- (iv_type < r.iv_type) );
+ return (iv_chip < r.iv_chip) ||
+ ((iv_chip == r.iv_chip) && (iv_type < r.iv_type));
}
private:
@@ -72,4 +71,3 @@
}; // end class Chip
} // end namespace libhei
-
diff --git a/src/hei_includes.hpp b/src/hei_includes.hpp
index 82b38b3..0b33436 100644
--- a/src/hei_includes.hpp
+++ b/src/hei_includes.hpp
@@ -16,11 +16,11 @@
// macros:
//
// Tracing (inputs same as printf() from <cstdio>):
-// HEI_INF( ... ) // Generic informational trace
-// HEI_ERR( ... ) // Error path trace
+// HEI_INF(...) // Generic informational trace
+// HEI_ERR(...) // Error path trace
//
// Assertion (at a minimum should work like assert() from <cassert>):
-// HEI_ASSERT( expression )
+// HEI_ASSERT(expression)
//
#include <hei_user_defines.hpp>
@@ -28,4 +28,3 @@
#include <hei_chip.hpp>
#include <hei_return_code.hpp>
#include <hei_types.hpp>
-
diff --git a/src/hei_isolation_data.hpp b/src/hei_isolation_data.hpp
index ee1432d..f0c89c8 100644
--- a/src/hei_isolation_data.hpp
+++ b/src/hei_isolation_data.hpp
@@ -23,10 +23,10 @@
~IsolationData() = default;
/** @brief Copy constructor. */
- IsolationData( const IsolationData & ) = default;
+ IsolationData(const IsolationData &) = default;
/** @brief Assignment operator. */
- IsolationData & operator=( const IsolationData & ) = default;
+ IsolationData & operator=(const IsolationData &) = default;
private: // Instance variables
@@ -41,9 +41,9 @@
* @brief Adds a signature to the signature list.
* @param i_signature The target signature.
*/
- void addSignature( const Signature & i_signature )
+ void addSignature(const Signature & i_signature)
{
- iv_sigLists.push_back( i_signature );
+ iv_sigLists.push_back(i_signature);
}
/** @brief Allows access to the signature list. */
@@ -61,4 +61,3 @@
}; // end class IsolationData
} // end namespace libhei
-
diff --git a/src/hei_main.hpp b/src/hei_main.hpp
index 21aebd2..5cc10bd 100644
--- a/src/hei_main.hpp
+++ b/src/hei_main.hpp
@@ -63,11 +63,11 @@
*
* @return RC_SUCCESS or RC_CHIP_DATA_INVALID or RC_CHIP_DATA_INITIALIZED
*/
-inline ReturnCode initialize( void * i_buffer, size_t i_bufferSize,
- bool i_forceInit = false )
+inline ReturnCode initialize(void * i_buffer, size_t i_bufferSize,
+ bool i_forceInit = false)
{
- return Isolator::getSingleton().initialize( i_buffer, i_bufferSize,
- i_forceInit );
+ return Isolator::getSingleton().initialize(i_buffer, i_bufferSize,
+ i_forceInit);
}
/**
@@ -97,11 +97,10 @@
*
* @return RC_SUCCESS or RC_CHIP_DATA_MISSING
*/
-inline ReturnCode isolate( const std::vector<Chip> & i_chipList,
- IsolationData & o_isoData )
+inline ReturnCode isolate(const std::vector<Chip> & i_chipList,
+ IsolationData & o_isoData)
{
- return Isolator::getSingleton().isolate( i_chipList, o_isoData );
+ return Isolator::getSingleton().isolate(i_chipList, o_isoData);
}
} // end namespace libhei
-
diff --git a/src/hei_return_code.hpp b/src/hei_return_code.hpp
index 5d0526e..c9ebc8a 100644
--- a/src/hei_return_code.hpp
+++ b/src/hei_return_code.hpp
@@ -13,33 +13,33 @@
* @brief Constructor.
* @param i_rc The error code value.
*/
- explicit constexpr ReturnCode( uint32_t i_rc = 0 ) :
- iv_rc( i_rc )
+ explicit constexpr ReturnCode(uint32_t i_rc = 0) :
+ iv_rc(i_rc)
{}
/** @brief Default copy constructor. */
- ReturnCode( const ReturnCode & ) = default;
+ ReturnCode(const ReturnCode &) = default;
/** @brief Default assignment operator. */
- ReturnCode& operator=( const ReturnCode & ) = default;
+ ReturnCode& operator=(const ReturnCode &) = default;
/** @brief Default destructor. */
~ReturnCode() = default;
- /** @brief Integral type conversion function. */
+ /** @brief Integral type conversion function. */
operator uint32_t() const { return iv_rc; }
/** @brief Integral type conversion function. */
operator uint64_t() const { return iv_rc; }
/** @brief Equals operator. */
- bool operator==( const ReturnCode & rhs ) const
+ bool operator==(const ReturnCode & rhs) const
{
return rhs.iv_rc == iv_rc;
}
/** @brief Not equals operator. */
- bool operator!=( const ReturnCode & rhs ) const
+ bool operator!=(const ReturnCode & rhs) const
{
return rhs.iv_rc != iv_rc;
}
@@ -76,4 +76,3 @@
static constexpr ReturnCode RC_REG_ACCESS_FAILURE = ReturnCode(0x00000004);
} // end namespace libhei
-
diff --git a/src/hei_types.hpp b/src/hei_types.hpp
index 9accfcb..698d811 100644
--- a/src/hei_types.hpp
+++ b/src/hei_types.hpp
@@ -172,4 +172,3 @@
};
} // end namespace libhei
-
diff --git a/src/hei_user_interface.hpp b/src/hei_user_interface.hpp
index fbfe92c..81b1473 100644
--- a/src/hei_user_interface.hpp
+++ b/src/hei_user_interface.hpp
@@ -44,8 +44,8 @@
* failure the user application is responsible for reporting why the
* register access failed.
*/
-ReturnCode registerRead( void * i_chip, void * o_buffer, size_t & io_bufSize,
- uint64_t i_regType, uint64_t i_address );
+ReturnCode registerRead(void * i_chip, void * o_buffer, size_t & io_bufSize,
+ uint64_t i_regType, uint64_t i_address);
#ifndef __HEI_READ_ONLY
@@ -80,10 +80,9 @@
* failure the user application is responsible for reporting why the
* register access failed.
*/
-ReturnCode registerWrite( void * i_chip, void * i_buffer, size_t & io_bufSize,
- uint64_t i_regType, uint64_t i_address );
+ReturnCode registerWrite(void * i_chip, void * i_buffer, size_t & io_bufSize,
+ uint64_t i_regType, uint64_t i_address);
#endif
} // end namespace libhei
-
diff --git a/src/isolator/hei_isolation_node.cpp b/src/isolator/hei_isolation_node.cpp
index a0bbf37..b30a678 100644
--- a/src/isolator/hei_isolation_node.cpp
+++ b/src/isolator/hei_isolation_node.cpp
@@ -5,8 +5,8 @@
//------------------------------------------------------------------------------
-bool IsolationNode::analyze( const Chip & i_chip, AttentionType_t i_attnType,
- IsolationData & io_isoData ) const
+bool IsolationNode::analyze(const Chip & i_chip, AttentionType_t i_attnType,
+ IsolationData & io_isoData) const
{
bool o_activeAttn = false; // Initially, assume no active attentions.
@@ -14,34 +14,34 @@
pushIsolationStack();
// A rule for i_attnType must exist.
- auto rule_itr = iv_rules.find( i_attnType );
- HEI_ASSERT( iv_rules.end() != rule_itr );
+ auto rule_itr = iv_rules.find(i_attnType);
+ HEI_ASSERT(iv_rules.end() != rule_itr);
// Get the returned BitString for this rule.
- const BitString * bs = rule_itr->second->getBitString( i_chip );
+ const BitString * bs = rule_itr->second->getBitString(i_chip);
// Ensure this BitString is not longer than the maximum bit field.
- HEI_ASSERT( bs->getBitLen() <= sizeof(RegisterBit_t) * 8 );
+ HEI_ASSERT(bs->getBitLen() <= sizeof(RegisterBit_t) * 8);
// Find all active bits for this rule.
- for ( RegisterBit_t bit = 0; bit < bs->getBitLen(); bit++ )
+ for (RegisterBit_t bit = 0; bit < bs->getBitLen(); bit++)
{
// Continue to the next bit if not active.
- if ( !bs->isBitSet(bit) ) continue;
+ if (!bs->isBitSet(bit)) continue;
// At least one active bit was found.
o_activeAttn = true;
// Determine if this attention originated from another register or if it
// is a leaf in the isolation tree.
- auto child_itr = iv_children.find( bit );
- if ( iv_children.end() != child_itr )
+ auto child_itr = iv_children.find(bit);
+ if (iv_children.end() != child_itr)
{
// This bit was driven from an attention from another register.
// Continue down the isolation tree to look for more attentions.
- bool attnFound = child_itr->second->analyze( i_chip, i_attnType,
- io_isoData );
- if ( !attnFound )
+ bool attnFound = child_itr->second->analyze(i_chip, i_attnType,
+ io_isoData);
+ if (!attnFound)
{
// Something went wrong. There should have been an active
// attention. It's possible there is a bug in the Chip Data
@@ -53,18 +53,18 @@
// io_isoData. If there are no other active attentions, the user
// application could use this signature to help determine, and
// circumvent, the isolation problem.
- io_isoData.addSignature( Signature { i_chip, iv_hwReg.getId(),
- iv_hwReg.getInstance(),
- bit, i_attnType } );
+ io_isoData.addSignature(Signature { i_chip, iv_hwReg.getId(),
+ iv_hwReg.getInstance(),
+ bit, i_attnType });
}
}
else
{
// We have reached a leaf in the isolation tree. Add this bit's
// signature to io_isoData.
- io_isoData.addSignature( Signature { i_chip, iv_hwReg.getId(),
- iv_hwReg.getInstance(),
- bit, i_attnType } );
+ io_isoData.addSignature(Signature { i_chip, iv_hwReg.getId(),
+ iv_hwReg.getInstance(),
+ bit, i_attnType });
}
}
@@ -76,14 +76,13 @@
//------------------------------------------------------------------------------
-void IsolationNode::addRule( AttentionType_t i_attnType,
- const Register * i_rule )
+void IsolationNode::addRule(AttentionType_t i_attnType, const Register * i_rule)
{
// A rule for this attention type should not already exist.
- HEI_ASSERT( iv_rules.end() == iv_rules.find(i_attnType) );
+ HEI_ASSERT(iv_rules.end() == iv_rules.find(i_attnType));
// The rule should not be null.
- HEI_ASSERT( nullptr != i_rule );
+ HEI_ASSERT(nullptr != i_rule);
// Add the new rule.
iv_rules[i_attnType] = i_rule;
@@ -91,13 +90,13 @@
//------------------------------------------------------------------------------
-void IsolationNode::addChild( uint8_t i_bit, const IsolationNode * i_child )
+void IsolationNode::addChild(uint8_t i_bit, const IsolationNode * i_child)
{
// An entry for this bit should not already exist.
- HEI_ASSERT( iv_children.end() == iv_children.find(i_bit) );
+ HEI_ASSERT(iv_children.end() == iv_children.find(i_bit));
// The child register should not be null.
- HEI_ASSERT( nullptr != i_child );
+ HEI_ASSERT(nullptr != i_child);
// Add the new rule.
iv_children[i_bit] = i_child;
@@ -112,15 +111,14 @@
void IsolationNode::pushIsolationStack() const
{
// Ensure this node does not already exist in cv_isolationStack.
- auto itr = std::find( cv_isolationStack.begin(),
- cv_isolationStack.end(), this );
- HEI_ASSERT( cv_isolationStack.end() == itr );
+ auto itr = std::find(cv_isolationStack.begin(),
+ cv_isolationStack.end(), this);
+ HEI_ASSERT(cv_isolationStack.end() == itr);
// Push to node to the stack.
- cv_isolationStack.push_back( this );
+ cv_isolationStack.push_back(this);
}
//------------------------------------------------------------------------------
} // end namespace libhei
-
diff --git a/src/isolator/hei_isolation_node.hpp b/src/isolator/hei_isolation_node.hpp
index eaf18e5..3fc8a37 100644
--- a/src/isolator/hei_isolation_node.hpp
+++ b/src/isolator/hei_isolation_node.hpp
@@ -42,8 +42,8 @@
* @param i_hwReg A reference to the HardwareRegister targeted for
* isolation.
*/
- explicit IsolationNode( const HardwareRegister & i_hwReg ) :
- iv_hwReg( i_hwReg )
+ explicit IsolationNode(const HardwareRegister & i_hwReg) :
+ iv_hwReg(i_hwReg)
{}
/** @brief Destructor. */
@@ -60,7 +60,7 @@
*
* Needed by Flyweight class, but should not be allowed in general.
*/
- IsolationNode( const IsolationNode & ) = default;
+ IsolationNode(const IsolationNode &) = default;
/**
* @brief Explicitly disables assignment operator.
@@ -69,7 +69,7 @@
* of the constant instance variables, but helps communicate it is not
* allowed.
*/
- IsolationNode & operator=( const IsolationNode & ) = delete;
+ IsolationNode & operator=(const IsolationNode &) = delete;
private: // Instance variables
@@ -111,8 +111,8 @@
* @return True, if any active attentions found on this register.
* False, otherwise.
*/
- bool analyze( const Chip & i_chip, AttentionType_t i_attnType,
- IsolationData & io_isoData ) const;
+ bool analyze(const Chip & i_chip, AttentionType_t i_attnType,
+ IsolationData & io_isoData) const;
// TODO: The next two functions are only intended to be used during
// initialization of the isolator. Consider, making them private and
@@ -129,7 +129,7 @@
* @param The target attention type.
* @param The rule for this attention type.
*/
- void addRule( AttentionType_t i_attnType, const Register * i_rule );
+ void addRule(AttentionType_t i_attnType, const Register * i_rule);
/**
* @brief Adds a child register to analyze for the given bit in this
@@ -141,22 +141,22 @@
* @param The target bit on this register.
* @param The child register to analyze for the given bit.
*/
- void addChild( RegisterBit_t i_bit, const IsolationNode * i_child );
+ void addChild(RegisterBit_t i_bit, const IsolationNode * i_child);
public: // Operators
/** @brief Equals operator. */
- bool operator==( const IsolationNode & i_r ) const
+ bool operator==(const IsolationNode & i_r) const
{
// iv_hwReg should be unique per IsolationNode.
- return ( iv_hwReg == i_r.iv_hwReg );
+ return (iv_hwReg == i_r.iv_hwReg);
}
/** @brief Less than operator. */
- bool operator<( const IsolationNode & i_r ) const
+ bool operator<(const IsolationNode & i_r) const
{
// iv_hwReg should be unique per IsolationNode.
- return ( iv_hwReg < i_r.iv_hwReg );
+ return (iv_hwReg < i_r.iv_hwReg);
}
private: // Isolation stack and supporting functions.
@@ -187,4 +187,3 @@
};
} // end namespace libhei
-
diff --git a/src/isolator/hei_isolator.cpp b/src/isolator/hei_isolator.cpp
index e977054..45ca647 100644
--- a/src/isolator/hei_isolator.cpp
+++ b/src/isolator/hei_isolator.cpp
@@ -11,29 +11,29 @@
namespace libhei
{
-ReturnCode Isolator::initialize( void * i_buffer, size_t i_bufferSize,
- bool i_forceInit )
+ReturnCode Isolator::initialize(void * i_buffer, size_t i_bufferSize,
+ bool i_forceInit)
{
ReturnCode rc;
// BEGIN temporary code
- HEI_INF( "Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize,
- i_forceInit );
+ HEI_INF("Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize,
+ i_forceInit);
Flyweight<ScomRegister> & sfw = Flyweight<ScomRegister>::getSingleton();
Flyweight<IdScomRegister> & ifw = Flyweight<IdScomRegister>::getSingleton();
- sfw.get( ScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID,
- REG_INST_DEFAULT, REG_ACCESS_RW, 0x01234567 } );
- sfw.get( ScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID,
- REG_INST_DEFAULT, REG_ACCESS_RW, 0x00112233 } );
+ sfw.get(ScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID,
+ REG_INST_DEFAULT, REG_ACCESS_RW, 0x01234567 });
+ sfw.get(ScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID,
+ REG_INST_DEFAULT, REG_ACCESS_RW, 0x00112233 });
- ifw.get( IdScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID,
- REG_INST_DEFAULT, REG_ACCESS_RW,
- 0x0123456789abcdef } );
- ifw.get( IdScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID,
- REG_INST_DEFAULT, REG_ACCESS_RW,
- 0x0011223344556677 } );
+ ifw.get(IdScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID,
+ REG_INST_DEFAULT, REG_ACCESS_RW,
+ 0x0123456789abcdef });
+ ifw.get(IdScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID,
+ REG_INST_DEFAULT, REG_ACCESS_RW,
+ 0x0011223344556677 });
// END temporary code
return rc;
@@ -54,8 +54,8 @@
Flyweight<IdScomRegister>::getSingleton().clear();
}
-ReturnCode Isolator::isolate( const std::vector<Chip> & i_chipList,
- IsolationData & o_isoData ) const
+ReturnCode Isolator::isolate(const std::vector<Chip> & i_chipList,
+ IsolationData & o_isoData) const
{
ReturnCode rc;
@@ -66,11 +66,10 @@
HardwareRegister::flushAll();
// Analyze active error on each chip.
- for ( auto const & chip : i_chipList )
+ for (auto const & chip : i_chipList)
{
// BEGIN temporary code
- HEI_INF( "Isolator::isolate(%p,%u)", chip.getChip(),
- chip.getType() );
+ HEI_INF("Isolator::isolate(%p,%u)", chip.getChip(), chip.getType());
// END temporary code
}
diff --git a/src/isolator/hei_isolator.hpp b/src/isolator/hei_isolator.hpp
index 1cc29b7..3c4a589 100644
--- a/src/isolator/hei_isolator.hpp
+++ b/src/isolator/hei_isolator.hpp
@@ -41,10 +41,10 @@
}
/** @brief Copy constructor. */
- Isolator( const Isolator & ) = delete;
+ Isolator(const Isolator &) = delete;
/** @brief Assignment operator. */
- Isolator & operator=( const Isolator & ) = delete;
+ Isolator & operator=(const Isolator &) = delete;
public:
@@ -56,8 +56,8 @@
}
/** @brief See API wrapper description in hei_main.hpp. */
- ReturnCode initialize( void * i_buffer, size_t i_bufferSize,
- bool i_forceInit = false );
+ ReturnCode initialize(void * i_buffer, size_t i_bufferSize,
+ bool i_forceInit = false);
/**
* @brief See API wrapper description in hei_main.hpp.
@@ -68,8 +68,8 @@
void uninitialize();
/** @brief See API wrapper description in hei_main.hpp. */
- ReturnCode isolate( const std::vector<Chip> & i_chipList,
- IsolationData & o_isoData ) const;
+ ReturnCode isolate(const std::vector<Chip> & i_chipList,
+ IsolationData & o_isoData) const;
private:
diff --git a/src/isolator/hei_signature.hpp b/src/isolator/hei_signature.hpp
index 018673a..4be04b3 100644
--- a/src/isolator/hei_signature.hpp
+++ b/src/isolator/hei_signature.hpp
@@ -25,21 +25,21 @@
* @param i_bit The target bit within this register.
* @param i_attnType The attention type reported by this bit.
*/
- Signature( const Chip & i_chip, RegisterId_t i_id,
- RegisterInstance_t i_instance, RegisterBit_t i_bit,
- AttentionType_t i_attnType ) :
- iv_chip( i_chip ), iv_id( i_id ), iv_instance( i_instance ),
- iv_bit( i_bit ), iv_attnType( i_attnType )
+ Signature(const Chip & i_chip, RegisterId_t i_id,
+ RegisterInstance_t i_instance, RegisterBit_t i_bit,
+ AttentionType_t i_attnType) :
+ iv_chip(i_chip), iv_id(i_id), iv_instance(i_instance),
+ iv_bit(i_bit), iv_attnType(i_attnType)
{}
/** @brief Destructor. */
~Signature() = default;
/** @brief Copy constructor. */
- Signature( const Signature & ) = default;
+ Signature(const Signature &) = default;
/** @brief Assignment operator. */
- Signature & operator=( const Signature & ) = default;
+ Signature & operator=(const Signature &) = default;
private: // Instance variables.
@@ -68,4 +68,3 @@
};
} // end namespace libhei
-
diff --git a/src/register/hei_hardware_register.cpp b/src/register/hei_hardware_register.cpp
index 3334662..52dc28c 100755
--- a/src/register/hei_hardware_register.cpp
+++ b/src/register/hei_hardware_register.cpp
@@ -13,7 +13,7 @@
//------------------------------------------------------------------------------
#if 0
-void HardwareRegister::setBitString( const BitString *bs )
+void HardwareRegister::setBitString(const BitString *bs)
{
BitString & l_string = accessBitString();
l_string.setString(*bs);
@@ -22,10 +22,10 @@
//------------------------------------------------------------------------------
-const BitString * HardwareRegister::getBitString( const Chip & i_chip ) const
+const BitString * HardwareRegister::getBitString(const Chip & i_chip) const
{
// Verify this register belongs on i_chip.
- verifyAccessorChip( i_chip );
+ verifyAccessorChip(i_chip);
// Calling read() will ensure that an entry exists in the cache and the
// entry has at been synched with hardware at least once. Note that we
@@ -33,21 +33,21 @@
// will be created in the cache, if it does not exist, when the cache is
// accessed below.
- if ( ( REG_ACCESS_NONE != getAccessLevel() ) &&
- ( REG_ACCESS_WO != getAccessLevel() ) )
+ if ((REG_ACCESS_NONE != getAccessLevel()) &&
+ (REG_ACCESS_WO != getAccessLevel()))
{
- read( i_chip );
+ read(i_chip);
}
- return &( accessCache(i_chip) );
+ return &(accessCache(i_chip));
}
//------------------------------------------------------------------------------
-BitString & HardwareRegister::accessBitString( const Chip & i_chip )
+BitString & HardwareRegister::accessBitString(const Chip & i_chip)
{
// Verify this register belongs on i_chip.
- verifyAccessorChip( i_chip );
+ verifyAccessorChip(i_chip);
// Calling read() will ensure that an entry exists in the cache and the
// entry has at been synched with hardware at least once. Note that we
@@ -55,52 +55,52 @@
// will be created in the cache, if it does not exist, when the cache is
// accessed below.
- if ( ( REG_ACCESS_NONE != getAccessLevel() ) &&
- ( REG_ACCESS_WO != getAccessLevel() ) )
+ if ((REG_ACCESS_NONE != getAccessLevel()) &&
+ (REG_ACCESS_WO != getAccessLevel()))
{
- read( i_chip );
+ read(i_chip);
}
- return accessCache( i_chip );
+ return accessCache(i_chip);
}
//------------------------------------------------------------------------------
-ReturnCode HardwareRegister::read( const Chip & i_chip, bool i_force ) const
+ReturnCode HardwareRegister::read(const Chip & i_chip, bool i_force) const
{
ReturnCode rc;
// Verify this register belongs on i_chip.
- verifyAccessorChip( i_chip );
+ verifyAccessorChip(i_chip);
// Read from hardware only if the read is forced or the entry for this
// instance does not exist in the cache.
- if ( i_force || !queryCache(i_chip) )
+ if (i_force || !queryCache(i_chip))
{
// This register must be readable.
- HEI_ASSERT( ( REG_ACCESS_NONE != getAccessLevel() ) &&
- ( REG_ACCESS_WO != getAccessLevel() ) );
+ HEI_ASSERT((REG_ACCESS_NONE != getAccessLevel()) &&
+ (REG_ACCESS_WO != getAccessLevel()));
// Get the buffer from the register cache.
- BitString & bs = accessCache( i_chip );
+ BitString & bs = accessCache(i_chip);
// Get the byte size of the buffer.
- size_t sz_buffer = BitString::getMinBytes( bs.getBitLen() );
+ size_t sz_buffer = BitString::getMinBytes(bs.getBitLen());
// Read this register from hardware.
- rc = registerRead( i_chip.getChip(), bs.getBufAddr(),
- sz_buffer, getRegisterType(), getAddress() );
- if ( RC_SUCCESS != rc )
+ rc = registerRead(i_chip.getChip(), bs.getBufAddr(), sz_buffer,
+ getRegisterType(), getAddress());
+ if (RC_SUCCESS != rc)
{
// The read failed and we can't trust what was put in the register
// cache. So remove this instance's entry from the cache.
- flush( i_chip );
+ flush(i_chip);
}
else
{
// Sanity check. The returned size of the data written to the buffer
// should match the register size.
- HEI_ASSERT( getSize() == sz_buffer );
+ HEI_ASSERT(getSize() == sz_buffer);
}
}
@@ -111,35 +111,35 @@
#ifndef __HEI_READ_ONLY
-ReturnCode HardwareRegister::write( const Chip & i_chip ) const
+ReturnCode HardwareRegister::write(const Chip & i_chip) const
{
ReturnCode rc;
// Verify this register belongs on i_chip.
- verifyAccessorChip( i_chip );
+ verifyAccessorChip(i_chip);
// This register must be writable.
- HEI_ASSERT( ( REG_ACCESS_NONE != getAccessLevel() ) &&
- ( REG_ACCESS_RO != getAccessLevel() ) );
+ HEI_ASSERT((REG_ACCESS_NONE != getAccessLevel()) &&
+ (REG_ACCESS_RO != getAccessLevel()));
// An entry for this register must exist in the cache.
- HEI_ASSERT( queryCache(i_chip) );
+ HEI_ASSERT(queryCache(i_chip));
// Get the buffer from the register cache.
- BitString & bs = accessCache( i_chip );
+ BitString & bs = accessCache(i_chip);
// Get the byte size of the buffer.
- size_t sz_buffer = BitString::getMinBytes( bs.getBitLen() );
+ size_t sz_buffer = BitString::getMinBytes(bs.getBitLen());
// Write to this register to hardware.
- rc = registerWrite( i_chip.getChip(), bs.getBufAddr(),
- sz_buffer, getRegisterType(), getAddress() );
+ rc = registerWrite(i_chip.getChip(), bs.getBufAddr(),
+ sz_buffer, getRegisterType(), getAddress());
- if ( RC_SUCCESS == rc )
+ if (RC_SUCCESS == rc)
{
// Sanity check. The returned size of the data written to the buffer
// should match the register size.
- HEI_ASSERT( getSize() == sz_buffer );
+ HEI_ASSERT(getSize() == sz_buffer);
}
return rc;
@@ -153,18 +153,18 @@
//------------------------------------------------------------------------------
-bool HardwareRegister::Cache::query( const Chip & i_chip,
- const HardwareRegister * i_hwReg ) const
+bool HardwareRegister::Cache::query(const Chip & i_chip,
+ const HardwareRegister * i_hwReg) const
{
// Does i_chip exist in the cache?
- auto chipPairItr = iv_cache.find( i_chip );
- if ( iv_cache.end() != chipPairItr )
+ auto chipPairItr = iv_cache.find(i_chip);
+ if (iv_cache.end() != chipPairItr)
{
auto & hwRegMap = chipPairItr->second; // for ease of use
// Does i_hwReg exist in the cache?
- auto hwRegPairItr = hwRegMap.find( i_hwReg );
- if ( hwRegMap.end() != hwRegPairItr )
+ auto hwRegPairItr = hwRegMap.find(i_hwReg);
+ if (hwRegMap.end() != hwRegPairItr)
{
return true;
}
@@ -175,11 +175,11 @@
//------------------------------------------------------------------------------
-BitString & HardwareRegister::Cache::access( const Chip & i_chip,
- const HardwareRegister * i_hwReg )
+BitString & HardwareRegister::Cache::access(const Chip & i_chip,
+ const HardwareRegister * i_hwReg)
{
// If the entry does not exist, create a new entry.
- if ( !query(i_chip, i_hwReg) )
+ if (!query(i_chip, i_hwReg))
{
BitString * bs = new BitStringBuffer { i_hwReg->getSize() * 8 };
iv_cache[i_chip][i_hwReg] = bs;
@@ -194,9 +194,9 @@
void HardwareRegister::Cache::flush()
{
// Delete all of the BitStrings.
- for ( auto & chipPair : iv_cache )
+ for (auto & chipPair : iv_cache)
{
- for ( auto & hwRegPair : chipPair.second )
+ for (auto & hwRegPair : chipPair.second)
{
delete hwRegPair.second;
}
@@ -211,18 +211,18 @@
//------------------------------------------------------------------------------
-void HardwareRegister::Cache::flush( const Chip & i_chip,
- const HardwareRegister * i_hwReg )
+void HardwareRegister::Cache::flush(const Chip & i_chip,
+ const HardwareRegister * i_hwReg)
{
// Does i_chip exist in the cache?
- auto chipPairItr = iv_cache.find( i_chip );
- if ( iv_cache.end() != chipPairItr )
+ auto chipPairItr = iv_cache.find(i_chip);
+ if (iv_cache.end() != chipPairItr)
{
auto & hwRegMap = chipPairItr->second; // for ease of use
// Does i_hwReg exist in the cache?
- auto hwRegPairItr = hwRegMap.find( i_hwReg );
- if ( hwRegMap.end() != hwRegPairItr )
+ auto hwRegPairItr = hwRegMap.find(i_hwReg);
+ if (hwRegMap.end() != hwRegPairItr)
{
delete hwRegPairItr->second; // delete the BitString
hwRegMap.erase(i_hwReg); // remove the entry for this register
@@ -230,7 +230,7 @@
// If i_hwReg was the only entry for i_chip, we can remove i_chip from
// the cache.
- if ( hwRegMap.empty() )
+ if (hwRegMap.empty())
{
iv_cache.erase(i_chip);
}
@@ -240,4 +240,3 @@
//------------------------------------------------------------------------------
} // end namespace libhei
-
diff --git a/src/register/hei_hardware_register.hpp b/src/register/hei_hardware_register.hpp
index ead7b16..ab1c66e 100755
--- a/src/register/hei_hardware_register.hpp
+++ b/src/register/hei_hardware_register.hpp
@@ -50,11 +50,11 @@
* @param i_instance Instance of this register
* @param i_accessLevel Hardware access level for this register.
*/
- HardwareRegister( ChipType_t i_chipType, RegisterId_t i_id,
- RegisterInstance_t i_instance,
- RegisterAccessLevel_t i_accessLevel ) :
- Register(), iv_chipType( i_chipType ), iv_id( i_id ),
- iv_instance( i_instance ), iv_accessLevel( i_accessLevel )
+ HardwareRegister(ChipType_t i_chipType, RegisterId_t i_id,
+ RegisterInstance_t i_instance,
+ RegisterAccessLevel_t i_accessLevel) :
+ Register(), iv_chipType(i_chipType), iv_id(i_id),
+ iv_instance(i_instance), iv_accessLevel(i_accessLevel)
{}
private: // Instance variables
@@ -102,31 +102,31 @@
public: // Operators
/** @brief Equals operator. */
- bool operator==( const HardwareRegister & i_r ) const
+ bool operator==(const HardwareRegister & i_r) const
{
// Comparing register type, chip type, and address should be sufficient.
- return ( getRegisterType() == i_r.getRegisterType() ) &&
- ( getChipType() == i_r.getChipType() ) &&
- ( getAddress() == i_r.getAddress() );
+ return (getRegisterType() == i_r.getRegisterType()) &&
+ (getChipType() == i_r.getChipType() ) &&
+ (getAddress() == i_r.getAddress() );
}
/** @brief Less than operator. */
- bool operator<( const HardwareRegister & i_r ) const
+ bool operator<(const HardwareRegister & i_r) const
{
// Comparing register type, chip type, and address should be sufficient.
- if ( getRegisterType() < i_r.getRegisterType() )
+ if (getRegisterType() < i_r.getRegisterType())
{
return true;
}
- else if ( getRegisterType() == i_r.getRegisterType() )
+ else if (getRegisterType() == i_r.getRegisterType())
{
- if ( getChipType() < i_r.getChipType() )
+ if (getChipType() < i_r.getChipType())
{
return true;
}
- else if ( getChipType() == i_r.getChipType() )
+ else if (getChipType() == i_r.getChipType())
{
- return ( getAddress() < i_r.getAddress() );
+ return (getAddress() < i_r.getAddress());
}
}
@@ -136,7 +136,7 @@
public:
/** Function overloaded from parent Register class. */
- const BitString * getBitString( const Chip & i_chip ) const;
+ const BitString * getBitString(const Chip & i_chip) const;
#if 0
/**
@@ -157,9 +157,9 @@
* read from hardware and update the cache.
* @return See the return code from the registerRead() user interface API.
*/
- ReturnCode read( const Chip & i_chip, bool i_force = false ) const;
+ ReturnCode read(const Chip & i_chip, bool i_force = false) const;
- #ifndef __HEI_READ_ONLY
+#ifndef __HEI_READ_ONLY
/**
* @brief Writes the value stored in the register cache to hardware via the
@@ -167,9 +167,9 @@
* @param i_chip The target chip in which this register belongs.
* @return See the return code from the registerWrite() user interface API.
*/
- ReturnCode write( const Chip & i_chip ) const;
+ ReturnCode write(const Chip & i_chip) const;
- #endif // __HEI_READ_ONLY
+#endif // __HEI_READ_ONLY
protected:
@@ -182,14 +182,14 @@
* @param i_chip The target chip in which this register belongs.
* @return A reference to the BitString.
*/
- BitString & accessBitString( const Chip & i_chip );
+ BitString & accessBitString(const Chip & i_chip);
private: // Hardware accessor management functions.
/** @brief Asserts this register belongs on the target accessor chip. */
- void verifyAccessorChip( const Chip & i_chip ) const
+ void verifyAccessorChip(const Chip & i_chip) const
{
- HEI_ASSERT( getChipType() == i_chip.getType() );
+ HEI_ASSERT(getChipType() == i_chip.getType());
}
private: // Register cache class variable
@@ -212,10 +212,10 @@
~Cache() = default;
/** @brief Copy constructor. */
- Cache( const Cache & ) = delete;
+ Cache(const Cache &) = delete;
/** @brief Assignment operator. */
- Cache & operator=( const Cache & ) = delete;
+ Cache & operator=(const Cache &) = delete;
/**
* @brief Queries if a specific entry exists in the cache.
@@ -223,8 +223,8 @@
* @param i_hwReg The target register.
* @return True if the entry exists, false otherwise.
*/
- bool query( const Chip & i_chip,
- const HardwareRegister * i_hwReg ) const;
+ bool query(const Chip & i_chip,
+ const HardwareRegister * i_hwReg) const;
/**
* @brief Returns the data buffer for the given chip and register.
@@ -234,8 +234,8 @@
* @note If an entry does not exist in the cache, an entry will be
* created and the BitString will be initialized to 0.
*/
- BitString & access( const Chip & i_chip,
- const HardwareRegister * i_hwReg );
+ BitString & access(const Chip & i_chip,
+ const HardwareRegister * i_hwReg);
/** @brief Flushes entire contents from cache. */
void flush();
@@ -245,7 +245,7 @@
* @param i_chip The target chip.
* @param i_hwReg The target register.
*/
- void flush( const Chip & i_chip, const HardwareRegister * i_hwReg );
+ void flush(const Chip & i_chip, const HardwareRegister * i_hwReg);
private:
@@ -279,9 +279,9 @@
* @brief Flushes this register from the cache.
* @param i_chip The target chip in which this register belongs.
*/
- void flush( const Chip & i_chip ) const
+ void flush(const Chip & i_chip) const
{
- cv_cache.flush( i_chip, this );
+ cv_cache.flush(i_chip, this);
}
private: // Register cache management functions.
@@ -290,20 +290,19 @@
* @param i_chip The target chip in which this register belongs.
* @return True if an entry for this register exist in this cache.
*/
- bool queryCache( const Chip & i_chip ) const
+ bool queryCache(const Chip & i_chip) const
{
- return cv_cache.query( i_chip, this );
+ return cv_cache.query(i_chip, this);
}
/**
* @param i_chip The target chip in which this register belongs.
* @return A reference to this register's BitString in cache.
*/
- BitString & accessCache( const Chip & i_chip ) const
+ BitString & accessCache(const Chip & i_chip) const
{
- return cv_cache.access( i_chip, this );
+ return cv_cache.access(i_chip, this);
}
};
} // end namespace libhei
-
diff --git a/src/register/hei_register.hpp b/src/register/hei_register.hpp
index 2a5c6ef..4514c28 100755
--- a/src/register/hei_register.hpp
+++ b/src/register/hei_register.hpp
@@ -17,7 +17,7 @@
Register * fir = new HardwareRegister(REG_ADDRESS, REG_WIDTH,
CHIP_TYPE, ACCESS_RO);
-Register * mask = new ConstantRegister( 0xffffffff00000000 );
+Register * mask = new ConstantRegister(0xffffffff00000000);
Register * fir_mask = new AndRegister(fir, mask);
const BitString * bs = fir_mask->getBitString(chip);
@@ -37,10 +37,10 @@
* @param i_chip Indicates which chip to access for this register.
* @return A BitString containing the value of this register.
*/
- virtual const BitString * getBitString( const Chip & i_chip ) const = 0;
+ virtual const BitString * getBitString(const Chip & i_chip) const = 0;
};
// Pure virtual destructor must be defined.
inline Register::~Register() {}
-}//end namespace libhei
+} // end namespace libhei
diff --git a/src/register/hei_scom_register.hpp b/src/register/hei_scom_register.hpp
index 04fd124..c90d5be 100644
--- a/src/register/hei_scom_register.hpp
+++ b/src/register/hei_scom_register.hpp
@@ -25,11 +25,11 @@
* @param i_accessLevel Hardware access level for this register.
* @param i_address A 4-byte address for this SCOM register.
*/
- ScomRegister( ChipType_t i_chipType, RegisterId_t i_id,
- RegisterInstance_t i_instance,
- RegisterAccessLevel_t i_accessLevel, uint32_t i_address ) :
- HardwareRegister( i_chipType, i_id, i_instance, i_accessLevel ),
- iv_address( i_address )
+ ScomRegister(ChipType_t i_chipType, RegisterId_t i_id,
+ RegisterInstance_t i_instance,
+ RegisterAccessLevel_t i_accessLevel, uint32_t i_address) :
+ HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel),
+ iv_address(i_address)
{}
/** @brief Destructor. */
@@ -46,7 +46,7 @@
*
* Needed by Flyweight class, but should not be allowed in general.
*/
- ScomRegister( const ScomRegister & ) = default;
+ ScomRegister(const ScomRegister &) = default;
/**
* @brief Explicitly disables assignment operator.
@@ -55,7 +55,7 @@
* of the constant instance variables, but helps communicate it is not
* allowed.
*/
- ScomRegister & operator=( const ScomRegister & ) = delete;
+ ScomRegister & operator=(const ScomRegister &) = delete;
public: // Accessor functions
@@ -65,7 +65,7 @@
/** Function overloaded from parent HardwareRegister class. */
RegisterAddress_t getAddress() const
{
- return static_cast<RegisterAddress_t>( iv_address );
+ return static_cast<RegisterAddress_t>(iv_address);
}
/** Function overloaded from parent HardwareRegister class. */
@@ -104,11 +104,11 @@
* @param i_accessLevel Hardware access level for this register.
* @param i_address An 8-byte address for this Indirect SCOM register.
*/
- IdScomRegister( ChipType_t i_chipType, RegisterId_t i_id,
- RegisterInstance_t i_instance,
- RegisterAccessLevel_t i_accessLevel, uint64_t i_address ) :
- HardwareRegister( i_chipType, i_id, i_instance, i_accessLevel ),
- iv_address( i_address )
+ IdScomRegister(ChipType_t i_chipType, RegisterId_t i_id,
+ RegisterInstance_t i_instance,
+ RegisterAccessLevel_t i_accessLevel, uint64_t i_address) :
+ HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel),
+ iv_address(i_address)
{}
/** @brief Destructor. */
@@ -125,7 +125,7 @@
*
* Needed by Flyweight class, but should not be allowed in general.
*/
- IdScomRegister( const IdScomRegister & ) = default;
+ IdScomRegister(const IdScomRegister &) = default;
/**
* @brief Explicitly disables assignment operator.
@@ -134,7 +134,7 @@
* of the constant instance variables, but helps communicate it is not
* allowed.
*/
- IdScomRegister & operator=( const IdScomRegister & ) = delete;
+ IdScomRegister & operator=(const IdScomRegister &) = delete;
public: // Accessor functions
@@ -144,7 +144,7 @@
/** Function overloaded from parent HardwareRegister class. */
RegisterAddress_t getAddress() const
{
- return static_cast<RegisterAddress_t>( iv_address );
+ return static_cast<RegisterAddress_t>(iv_address);
}
/** Function overloaded from parent HardwareRegister class. */
@@ -158,4 +158,3 @@
}; // end class IdScomRegister
} // end namespace libhei
-
diff --git a/src/util/hei_bit_string.cpp b/src/util/hei_bit_string.cpp
index 55da5cd..25443a6 100755
--- a/src/util/hei_bit_string.cpp
+++ b/src/util/hei_bit_string.cpp
@@ -22,23 +22,23 @@
//------------------------------------------------------------------------------
-uint64_t BitString::getFieldRight( uint64_t i_pos, uint64_t i_len ) const
+uint64_t BitString::getFieldRight(uint64_t i_pos, uint64_t i_len) const
{
- HEI_ASSERT( nullptr != getBufAddr() ); // must to have a valid address
- HEI_ASSERT( 0 < i_len ); // must have at least one bit
- HEI_ASSERT( i_len <= UINT64_BIT_LEN ); // i_len length must be valid
- HEI_ASSERT( i_pos + i_len <= getBitLen() ); // field must be within range
+ HEI_ASSERT(nullptr != getBufAddr()); // must to have a valid address
+ HEI_ASSERT(0 < i_len); // must have at least one bit
+ HEI_ASSERT(i_len <= UINT64_BIT_LEN); // i_len length must be valid
+ HEI_ASSERT(i_pos + i_len <= getBitLen()); // field must be within range
// Get the relative address of this byte and the relative starting position
// within the byte.
uint64_t relPos = 0;
- uint8_t * relAddr = getRelativePosition( relPos, i_pos );
+ uint8_t * relAddr = getRelativePosition(relPos, i_pos);
// Get the length of the target bit field within this byte and the length of
// the bit field for any remaining bits.
uint64_t bf_len = i_len;
uint64_t remain_len = 0;
- if ( UINT8_BIT_LEN < relPos + i_len )
+ if (UINT8_BIT_LEN < relPos + i_len)
{
// The target bit field crosses a byte boundary. So truncate the bit
// length for this byte and update the remaining length.
@@ -52,12 +52,12 @@
bf >>= UINT8_BIT_LEN - bf_len; // Right justify the value.
// Check for any remaining bits after this target byte.
- if ( 0 != remain_len )
+ if (0 != remain_len)
{
// Recursively call this function on the remaining bits and push them
// into the right side of the return value.
uint64_t val = static_cast<uint64_t>(bf) << remain_len;
- return val | getFieldRight( i_pos + bf_len, remain_len );
+ return val | getFieldRight(i_pos + bf_len, remain_len);
}
// Nothing more to do. Simply return this bit field.
@@ -66,23 +66,23 @@
//------------------------------------------------------------------------------
-void BitString::setFieldLeft( uint64_t i_pos, uint64_t i_len, uint64_t i_val )
+void BitString::setFieldLeft(uint64_t i_pos, uint64_t i_len, uint64_t i_val)
{
- HEI_ASSERT( nullptr != getBufAddr() ); // must to have a valid address
- HEI_ASSERT( 0 < i_len ); // must have at least one bit
- HEI_ASSERT( i_len <= UINT64_BIT_LEN ); // i_len length must be valid
- HEI_ASSERT( i_pos + i_len <= getBitLen() ); // field must be within range
+ HEI_ASSERT(nullptr != getBufAddr()); // must to have a valid address
+ HEI_ASSERT(0 < i_len); // must have at least one bit
+ HEI_ASSERT(i_len <= UINT64_BIT_LEN); // i_len length must be valid
+ HEI_ASSERT(i_pos + i_len <= getBitLen()); // field must be within range
// Get the relative address of this byte and the relative starting position
// within the byte.
uint64_t relPos = 0;
- uint8_t * relAddr = getRelativePosition( relPos, i_pos );
+ uint8_t * relAddr = getRelativePosition(relPos, i_pos);
// Get the length of the target bit field within this byte and the length of
// the bit field for any remaining bits.
uint64_t bf_len = i_len;
uint64_t remain_len = 0;
- if ( UINT8_BIT_LEN < relPos + i_len )
+ if (UINT8_BIT_LEN < relPos + i_len)
{
// The target bit field crosses a byte boundary. So truncate the bit
// length for this byte and update the remaining length.
@@ -109,24 +109,24 @@
*relAddr = bf_l | bf | bf_r;
// Check for any remaining bits after this target byte.
- if ( 0 != remain_len )
+ if (0 != remain_len)
{
// Recursively call this function on the remaining bits.
- setFieldLeft( i_pos + bf_len, remain_len, i_val << bf_len );
+ setFieldLeft(i_pos + bf_len, remain_len, i_val << bf_len);
}
}
//------------------------------------------------------------------------------
-void BitString::setPattern( uint64_t i_sPos, uint64_t i_sLen,
- uint64_t i_pattern, uint64_t i_pLen )
+void BitString::setPattern(uint64_t i_sPos, uint64_t i_sLen, uint64_t i_pattern,
+ uint64_t i_pLen)
{
HEI_ASSERT(nullptr != getBufAddr()); // must to have a valid address
HEI_ASSERT(0 < i_sLen); // must have at least one bit
HEI_ASSERT(i_sPos + i_sLen <= getBitLen()); // field must be within range
HEI_ASSERT(0 < i_pLen); // must have at least one bit
- HEI_ASSERT(i_pLen <= UINT64_BIT_LEN); // i_pLen length must be valid
+ HEI_ASSERT(i_pLen <= UINT64_BIT_LEN); // i_pLen length must be valid
// Get a bit string for the pattern subset (right justified).
// Note that we cannot use a BitStringBuffer here because this function
@@ -138,105 +138,105 @@
// Iterate the range in chunks the size of i_pLen.
uint64_t endPos = i_sPos + i_sLen;
- for ( uint64_t pos = i_sPos; pos < endPos; pos += i_pLen )
+ for (uint64_t pos = i_sPos; pos < endPos; pos += i_pLen)
{
// The true chunk size is either i_pLen or the leftovers at the end.
- uint64_t len = std::min( i_pLen, endPos - pos );
+ uint64_t len = std::min(i_pLen, endPos - pos);
// Get this chunk's pattern value, truncate (right justified) if needed.
- uint64_t pattern = bs.getFieldRight( 0, len );
+ uint64_t pattern = bs.getFieldRight(0, len);
// Set the pattern in this string.
- setFieldRight( pos, len, pattern );
+ setFieldRight(pos, len, pattern);
}
}
//------------------------------------------------------------------------------
-void BitString::setString( const BitString & i_sStr, uint64_t i_sPos,
- uint64_t i_sLen, uint64_t i_dPos )
+void BitString::setString(const BitString & i_sStr, uint64_t i_sPos,
+ uint64_t i_sLen, uint64_t i_dPos)
{
// Ensure the source parameters are valid.
- HEI_ASSERT( nullptr != i_sStr.getBufAddr() );
- HEI_ASSERT( 0 < i_sLen ); // at least one bit to copy
- HEI_ASSERT( i_sPos + i_sLen <= i_sStr.getBitLen() );
+ HEI_ASSERT(nullptr != i_sStr.getBufAddr());
+ HEI_ASSERT(0 < i_sLen); // at least one bit to copy
+ HEI_ASSERT(i_sPos + i_sLen <= i_sStr.getBitLen());
// Ensure the destination has at least one bit available to copy.
- HEI_ASSERT( nullptr != getBufAddr() );
- HEI_ASSERT( i_dPos < getBitLen() );
+ HEI_ASSERT(nullptr != getBufAddr());
+ HEI_ASSERT(i_dPos < getBitLen());
// If the source length is greater than the destination length than the
// extra source bits are ignored.
- uint64_t actLen = std::min( i_sLen, getBitLen() - i_dPos );
+ uint64_t actLen = std::min(i_sLen, getBitLen() - i_dPos);
// The bit strings may be in overlapping memory spaces. So we need to copy
// the data in the correct direction to prevent overlapping.
uint64_t sRelOffset = 0, dRelOffset = 0;
- uint8_t * sRelAddr = i_sStr.getRelativePosition( sRelOffset, i_sPos );
- uint8_t * dRelAddr = getRelativePosition( dRelOffset, i_dPos );
+ uint8_t * sRelAddr = i_sStr.getRelativePosition(sRelOffset, i_sPos);
+ uint8_t * dRelAddr = getRelativePosition(dRelOffset, i_dPos);
// Copy the data.
- if ( (dRelAddr == sRelAddr) && (dRelOffset == sRelOffset) )
+ if ((dRelAddr == sRelAddr) && (dRelOffset == sRelOffset))
{
// Do nothing. The source and destination are the same.
}
- else if ( (dRelAddr < sRelAddr) ||
- ((dRelAddr == sRelAddr) && (dRelOffset < sRelOffset)) )
+ else if ((dRelAddr < sRelAddr) ||
+ ((dRelAddr == sRelAddr) && (dRelOffset < sRelOffset)))
{
// Copy the data forward.
- for ( uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
- uint64_t value = i_sStr.getFieldRight( i_sPos + pos, len );
- setFieldRight( i_dPos + pos, len, value );
+ uint64_t value = i_sStr.getFieldRight(i_sPos + pos, len);
+ setFieldRight(i_dPos + pos, len, value);
}
}
else // Copy the data backwards.
{
// Get the first position of the last chunk (byte aligned).
- uint64_t lastPos = ((actLen-1) / UINT64_BIT_LEN) * UINT64_BIT_LEN;
+ uint64_t lastPos = ((actLen - 1) / UINT64_BIT_LEN) * UINT64_BIT_LEN;
// Start with the last chunk and work backwards.
- for ( int32_t pos = lastPos; 0 <= pos; pos -= UINT64_BIT_LEN )
+ for (int32_t pos = lastPos; 0 <= pos; pos -= UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
- uint64_t value = i_sStr.getFieldRight( i_sPos + pos, len );
- setFieldRight( i_dPos + pos, len, value );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
+ uint64_t value = i_sStr.getFieldRight(i_sPos + pos, len);
+ setFieldRight(i_dPos + pos, len, value);
}
}
}
//------------------------------------------------------------------------------
-void BitString::maskString( const BitString & i_mask )
+void BitString::maskString(const BitString & i_mask)
{
// Get the length of the smallest string.
- uint64_t actLen = std::min( getBitLen(), i_mask.getBitLen() );
+ uint64_t actLen = std::min(getBitLen(), i_mask.getBitLen());
- for ( uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
- uint64_t dVal = getFieldRight( pos, len );
- uint64_t sVal = i_mask.getFieldRight( pos, len );
+ uint64_t dVal = getFieldRight(pos, len);
+ uint64_t sVal = i_mask.getFieldRight(pos, len);
- setFieldRight( pos, len, dVal & ~sVal );
+ setFieldRight(pos, len, dVal & ~sVal);
}
}
//------------------------------------------------------------------------------
-bool BitString::isEqual( const BitString & i_str ) const
+bool BitString::isEqual(const BitString & i_str) const
{
- if ( getBitLen() != i_str.getBitLen() )
+ if (getBitLen() != i_str.getBitLen())
return false; // size not equal
- for ( uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( getBitLen() - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(getBitLen() - pos, UINT64_BIT_LEN);
- if ( getFieldRight(pos, len) != i_str.getFieldRight(pos, len) )
+ if (getFieldRight(pos, len) != i_str.getFieldRight(pos, len))
return false; // bit strings do not match
}
@@ -247,11 +247,11 @@
bool BitString::isZero() const
{
- for ( uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( getBitLen() - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(getBitLen() - pos, UINT64_BIT_LEN);
- if ( 0 != getFieldRight(pos, len) )
+ if (0 != getFieldRight(pos, len))
return false; // something is non-zero
}
@@ -260,17 +260,17 @@
//------------------------------------------------------------------------------
-uint64_t BitString::getSetCount( uint64_t i_pos, uint64_t i_len ) const
+uint64_t BitString::getSetCount(uint64_t i_pos, uint64_t i_len) const
{
uint64_t endPos = i_pos + i_len;
- HEI_ASSERT( endPos <= getBitLen() );
+ HEI_ASSERT(endPos <= getBitLen());
uint64_t count = 0;
- for ( uint64_t i = i_pos; i < endPos; i++ )
+ for (uint64_t i = i_pos; i < endPos; i++)
{
- if ( isBitSet(i) ) count++;
+ if (isBitSet(i)) count++;
}
return count;
@@ -280,15 +280,15 @@
BitStringBuffer BitString::operator~() const
{
- BitStringBuffer bsb( getBitLen() );
+ BitStringBuffer bsb(getBitLen());
- for ( uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < getBitLen(); pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( getBitLen() - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(getBitLen() - pos, UINT64_BIT_LEN);
- uint64_t dVal = getFieldRight( pos, len );
+ uint64_t dVal = getFieldRight(pos, len);
- bsb.setFieldRight( pos, len, ~dVal );
+ bsb.setFieldRight(pos, len, ~dVal);
}
return bsb;
@@ -296,21 +296,21 @@
//------------------------------------------------------------------------------
-BitStringBuffer BitString::operator&( const BitString & i_bs ) const
+BitStringBuffer BitString::operator&(const BitString & i_bs) const
{
// Get the length of the smallest string.
- uint64_t actLen = std::min( getBitLen(), i_bs.getBitLen() );
+ uint64_t actLen = std::min(getBitLen(), i_bs.getBitLen());
- BitStringBuffer bsb( actLen );
+ BitStringBuffer bsb(actLen);
- for ( uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
- uint64_t dVal = getFieldRight( pos, len );
- uint64_t sVal = i_bs.getFieldRight( pos, len );
+ uint64_t dVal = getFieldRight(pos, len);
+ uint64_t sVal = i_bs.getFieldRight(pos, len);
- bsb.setFieldRight( pos, len, dVal & sVal );
+ bsb.setFieldRight(pos, len, dVal & sVal);
}
return bsb;
@@ -318,21 +318,21 @@
//------------------------------------------------------------------------------
-BitStringBuffer BitString::operator|( const BitString & i_bs ) const
+BitStringBuffer BitString::operator|(const BitString & i_bs) const
{
// Get the length of the smallest string.
- uint64_t actLen = std::min( getBitLen(), i_bs.getBitLen() );
+ uint64_t actLen = std::min(getBitLen(), i_bs.getBitLen());
- BitStringBuffer bsb( actLen );
+ BitStringBuffer bsb(actLen);
- for ( uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN )
+ for (uint64_t pos = 0; pos < actLen; pos += UINT64_BIT_LEN)
{
- uint64_t len = std::min( actLen - pos, UINT64_BIT_LEN );
+ uint64_t len = std::min(actLen - pos, UINT64_BIT_LEN);
- uint64_t dVal = getFieldRight( pos, len );
- uint64_t sVal = i_bs.getFieldRight( pos, len );
+ uint64_t dVal = getFieldRight(pos, len);
+ uint64_t sVal = i_bs.getFieldRight(pos, len);
- bsb.setFieldRight( pos, len, dVal | sVal );
+ bsb.setFieldRight(pos, len, dVal | sVal);
}
return bsb;
@@ -340,17 +340,17 @@
//------------------------------------------------------------------------------
-BitStringBuffer BitString::operator>>( uint64_t i_shift ) const
+BitStringBuffer BitString::operator>>(uint64_t i_shift) const
{
- BitStringBuffer bsb( getBitLen() ); // default all zeros
+ BitStringBuffer bsb(getBitLen()); // default all zeros
- if ( i_shift < getBitLen() )
+ if (i_shift < getBitLen())
{
// bso overlays bsb, containing the shifted offset.
- BitString bso ( bsb.getBitLen() - i_shift, bsb.getBufAddr(), i_shift );
+ BitString bso (bsb.getBitLen() - i_shift, bsb.getBufAddr(), i_shift);
// Copy this into bso.
- bso.setString( *this );
+ bso.setString(*this);
}
return bsb;
@@ -358,18 +358,18 @@
//------------------------------------------------------------------------------
-BitStringBuffer BitString::operator<<( uint64_t i_shift ) const
+BitStringBuffer BitString::operator<<(uint64_t i_shift) const
{
- BitStringBuffer bsb( getBitLen() ); // default all zeros
+ BitStringBuffer bsb(getBitLen()); // default all zeros
- if ( i_shift < getBitLen() )
+ if (i_shift < getBitLen())
{
// bso overlays *this, containing the shifted offset.
- BitString bso ( this->getBitLen() - i_shift, this->getBufAddr(),
- i_shift );
+ BitString bso (this->getBitLen() - i_shift, this->getBufAddr(),
+ i_shift);
// Copy bso into bsb.
- bsb.setString( bso );
+ bsb.setString(bso);
}
return bsb;
@@ -377,11 +377,11 @@
//------------------------------------------------------------------------------
-uint8_t * BitString::getRelativePosition( uint64_t & o_relPos,
- uint64_t i_absPos ) const
+uint8_t * BitString::getRelativePosition(uint64_t & o_relPos,
+ uint64_t i_absPos) const
{
- HEI_ASSERT( nullptr != getBufAddr() ); // must to have a valid address
- HEI_ASSERT( i_absPos < getBitLen() ); // must be a valid position
+ HEI_ASSERT(nullptr != getBufAddr()); // must to have a valid address
+ HEI_ASSERT(i_absPos < getBitLen()); // must be a valid position
o_relPos = (i_absPos + iv_offset) % UINT8_BIT_LEN;
@@ -392,8 +392,8 @@
// BitStringBuffer class
//##############################################################################
-BitStringBuffer::BitStringBuffer( uint64_t i_bitLen ) :
- BitString( i_bitLen, nullptr )
+BitStringBuffer::BitStringBuffer(uint64_t i_bitLen) :
+ BitString(i_bitLen, nullptr)
{
initBuffer();
}
@@ -407,52 +407,52 @@
//------------------------------------------------------------------------------
-BitStringBuffer::BitStringBuffer( const BitString & i_bs ) :
- BitString( i_bs.getBitLen(), nullptr )
+BitStringBuffer::BitStringBuffer(const BitString & i_bs) :
+ BitString(i_bs.getBitLen(), nullptr)
{
initBuffer();
- if ( !i_bs.isZero() ) setString( i_bs );
+ if (!i_bs.isZero()) setString(i_bs);
}
//------------------------------------------------------------------------------
-BitStringBuffer::BitStringBuffer( const BitStringBuffer & i_bsb ) :
- BitString( i_bsb.getBitLen(), nullptr )
+BitStringBuffer::BitStringBuffer(const BitStringBuffer & i_bsb) :
+ BitString(i_bsb.getBitLen(), nullptr)
{
initBuffer();
- if ( !i_bsb.isZero() ) setString( i_bsb );
+ if (!i_bsb.isZero()) setString(i_bsb);
}
//------------------------------------------------------------------------------
-BitStringBuffer & BitStringBuffer::operator=( const BitString & i_bs )
+BitStringBuffer & BitStringBuffer::operator=(const BitString & i_bs)
{
// The initBuffer() function will deallocate the buffer as well, however we
// also need to deallocate the buffer here before we set the length.
delete [] (uint8_t *)getBufAddr();
- setBufAddr( nullptr );
+ setBufAddr(nullptr);
- setBitLen( i_bs.getBitLen() );
+ setBitLen(i_bs.getBitLen());
initBuffer();
- if ( !i_bs.isZero() ) setString( i_bs );
+ if (!i_bs.isZero()) setString(i_bs);
return *this;
}
//------------------------------------------------------------------------------
-BitStringBuffer & BitStringBuffer::operator=( const BitStringBuffer & i_bsb )
+BitStringBuffer & BitStringBuffer::operator=(const BitStringBuffer & i_bsb)
{
- if ( this != &i_bsb ) // Check for assignment to self
+ if (this != &i_bsb) // Check for assignment to self
{
// The initBuffer() function will deallocate the buffer as well, however
// we also need to deallocate the buffer here before we set the length.
delete [] (uint8_t *)getBufAddr();
- setBufAddr( nullptr );
+ setBufAddr(nullptr);
- setBitLen( i_bsb.getBitLen() );
+ setBitLen(i_bsb.getBitLen());
initBuffer();
- if ( !i_bsb.isZero() ) setString( i_bsb );
+ if (!i_bsb.isZero()) setString(i_bsb);
}
return *this;
@@ -466,7 +466,7 @@
delete [] (uint8_t *)getBufAddr();
// create new buffer, initialized to 0's
- setBufAddr( new uint8_t[ getMinBytes(getBitLen()) ]() );
+ setBufAddr(new uint8_t[ getMinBytes(getBitLen()) ]());
}
} // end namespace libhei
diff --git a/src/util/hei_bit_string.hpp b/src/util/hei_bit_string.hpp
index 127ce61..7f83624 100755
--- a/src/util/hei_bit_string.hpp
+++ b/src/util/hei_bit_string.hpp
@@ -33,7 +33,7 @@
*
* uint8_t a[2]; // 16 bits of memory
* BitString bs { 16, a }; // init BitString for a
- * bs.setFieldRight( 0, 16, 0x1122 ); // set all 16 bits to 0x1122
+ * bs.setFieldRight(0, 16, 0x1122); // set all 16 bits to 0x1122
*
* Results in:
*
@@ -76,8 +76,7 @@
* @pre Use getMinBytes() to calulate the minimum number of bytes needed
* to allocate sufficient memory space for this bit string.
*/
- BitString( uint64_t i_bitLen, void * i_bufAddr,
- uint64_t i_offset = 0 ) :
+ BitString(uint64_t i_bitLen, void * i_bufAddr, uint64_t i_offset = 0) :
iv_bitLen(i_bitLen), iv_bufAddr(i_bufAddr), iv_offset(i_offset)
{}
@@ -98,9 +97,9 @@
* @return The minimum number of bytes required to allocate sufficient
* memory space for a bit string.
*/
- static uint64_t getMinBytes( uint64_t i_bitLen, uint64_t i_offset = 0 )
+ static uint64_t getMinBytes(uint64_t i_bitLen, uint64_t i_offset = 0)
{
- return (i_bitLen + i_offset + UINT8_BIT_LEN-1) / UINT8_BIT_LEN;
+ return (i_bitLen + i_offset + UINT8_BIT_LEN - 1) / UINT8_BIT_LEN;
}
/**
@@ -114,7 +113,7 @@
* @pre i_len <= UINT64_BIT_LEN
* @pre i_pos + i_len <= getBitLen()
*/
- uint64_t getFieldLeft( uint64_t i_pos, uint64_t i_len ) const
+ uint64_t getFieldLeft(uint64_t i_pos, uint64_t i_len) const
{
return getFieldRight(i_pos, i_len) << (UINT64_BIT_LEN - i_len);
}
@@ -130,7 +129,7 @@
* @pre i_len <= UINT64_BIT_LEN
* @pre i_pos + i_len <= getBitLen()
*/
- uint64_t getFieldRight( uint64_t i_pos, uint64_t i_len ) const;
+ uint64_t getFieldRight(uint64_t i_pos, uint64_t i_len) const;
/**
* @brief Sets a left-justified value of the given length into the bit
@@ -143,7 +142,7 @@
* @pre i_len <= UINT64_BIT_LEN
* @pre i_pos + i_len <= getBitLen()
*/
- void setFieldLeft( uint64_t i_pos, uint64_t i_len, uint64_t i_val );
+ void setFieldLeft(uint64_t i_pos, uint64_t i_len, uint64_t i_val);
/**
* @brief Sets a right-justified value of the given length into the bit
@@ -156,9 +155,9 @@
* @pre i_len <= UINT64_BIT_LEN
* @pre i_pos + i_len <= getBitLen()
*/
- void setFieldRight( uint64_t i_pos, uint64_t i_len, uint64_t i_val )
+ void setFieldRight(uint64_t i_pos, uint64_t i_len, uint64_t i_val)
{
- setFieldLeft( i_pos, i_len, i_val << (UINT64_BIT_LEN - i_len) );
+ setFieldLeft(i_pos, i_len, i_val << (UINT64_BIT_LEN - i_len));
}
/**
@@ -166,7 +165,7 @@
* @return True if the bit at the given position is set(1), false otherwise.
* @pre i_pos < getBitLen().
*/
- bool isBitSet( uint64_t i_pos ) const
+ bool isBitSet(uint64_t i_pos) const
{
return 0 != getFieldRight(i_pos, 1);
}
@@ -176,7 +175,7 @@
* @param i_pos The target position.
* @pre i_pos < getBitLen().
*/
- void setBit( uint64_t i_pos ) { setFieldRight( i_pos, 1, 1 ); }
+ void setBit(uint64_t i_pos) { setFieldRight(i_pos, 1, 1); }
/** @brief Sets the entire bit string to 1's. */
void setAll() { setPattern(UINT64_MAX); }
@@ -186,7 +185,7 @@
* @param i_pos The target position.
* @pre i_pos < getBitLen().
*/
- void clearBit( uint64_t i_pos ) { setFieldRight( i_pos, 1, 0 ); }
+ void clearBit(uint64_t i_pos) { setFieldRight(i_pos, 1, 0); }
/** @brief Sets the entire bit string to 0's. */
void clearAll() { setPattern(0); }
@@ -212,8 +211,8 @@
* Old String: 0001001000
* New String: 0000110000
*/
- void setPattern( uint64_t i_sPos, uint64_t i_sLen,
- uint64_t i_pattern, uint64_t i_pLen );
+ void setPattern(uint64_t i_sPos, uint64_t i_sLen, uint64_t i_pattern,
+ uint64_t i_pLen);
/**
* @brief Sets entire string based on the pattern and length provided.
@@ -223,9 +222,9 @@
* @post The entire string is filled with the pattern.
* @post The pattern is repeated/truncated as needed.
*/
- void setPattern( uint64_t i_pattern, uint64_t i_pLen )
+ void setPattern(uint64_t i_pattern, uint64_t i_pLen)
{
- setPattern( 0, getBitLen(), i_pattern, i_pLen );
+ setPattern(0, getBitLen(), i_pattern, i_pLen);
}
/**
@@ -235,9 +234,9 @@
* @post The entire string is filled with the pattern.
* @post The pattern is repeated/truncated as needed.
*/
- void setPattern( uint64_t i_pattern )
+ void setPattern(uint64_t i_pattern)
{
- setPattern( i_pattern, sizeof(i_pattern) * 8 );
+ setPattern(i_pattern, sizeof(i_pattern) * 8);
}
/**
@@ -258,8 +257,8 @@
* string, then the extra bits in this string are not modified.
* @note This string and the source string may specify overlapping memory.
*/
- void setString( const BitString & i_sStr, uint64_t i_sPos,
- uint64_t i_sLen, uint64_t i_dPos = 0 );
+ void setString(const BitString & i_sStr, uint64_t i_sPos, uint64_t i_sLen,
+ uint64_t i_dPos = 0);
/**
* @brief Set bits in this string based on the provided string.
@@ -269,9 +268,9 @@
* @note See the other definition of this function for details and
* restrictions.
*/
- void setString( const BitString & i_sStr )
+ void setString(const BitString & i_sStr)
{
- setString( i_sStr, 0, i_sStr.getBitLen() );
+ setString(i_sStr, 0, i_sStr.getBitLen());
}
/**
@@ -283,7 +282,7 @@
* @note If the length of the given string is less than the length of this
* string, then the extra bits in this string are not modified.
*/
- void maskString( const BitString & i_mask );
+ void maskString(const BitString & i_mask);
/**
* @param i_str The string to compare.
@@ -291,7 +290,7 @@
* @pre Both strings must be of equal length and have same values to be
* equal.
*/
- bool isEqual( const BitString & i_str ) const;
+ bool isEqual(const BitString & i_str) const;
/** @return True if there are no bit set(1) in this bit string, false
* otherwise. */
@@ -304,28 +303,28 @@
* @pre nullptr != getBufAddr()
* @pre i_pos + i_len <= getBitLen()
*/
- uint64_t getSetCount( uint64_t i_pos, uint64_t i_len ) const;
+ uint64_t getSetCount(uint64_t i_pos, uint64_t i_len) const;
/** @return The number of bits that are set(1) in this string. */
- uint64_t getSetCount() const { return getSetCount( 0, getBitLen() ); }
+ uint64_t getSetCount() const { return getSetCount(0, getBitLen()); }
/** @brief Comparison operator. */
- bool operator==( const BitString & i_str ) const { return isEqual(i_str); }
+ bool operator==(const BitString & i_str) const { return isEqual(i_str); }
/** @brief Bitwise NOT operator. */
BitStringBuffer operator~() const;
/** @brief Bitwise AND operator. */
- BitStringBuffer operator&( const BitString & i_bs ) const;
+ BitStringBuffer operator&(const BitString & i_bs) const;
/** @brief Bitwise OR operator. */
- BitStringBuffer operator|( const BitString & i_bs ) const;
+ BitStringBuffer operator|(const BitString & i_bs) const;
/** @brief Right shift operator. */
- BitStringBuffer operator>>( uint64_t i_shift ) const;
+ BitStringBuffer operator>>(uint64_t i_shift) const;
/** @brief Left shift operator. */
- BitStringBuffer operator<<( uint64_t i_shift ) const;
+ BitStringBuffer operator<<(uint64_t i_shift) const;
/**
* @brief Explicitly disables copy from BitString.
@@ -333,7 +332,7 @@
* Prevents assigning a BitString & to a BitString, which would strip
* polymorphism.
*/
- BitString( const BitString & i_bs ) = delete;
+ BitString(const BitString & i_bs) = delete;
/**
* @brief Explicitly disables assignment from BitStringBuffer.
@@ -341,7 +340,7 @@
* Allowing this would be dangerous if the BitStringBuffer goes out of scope
* because the BitString would point to memory that is no longer in context.
*/
- BitString & operator=( const BitStringBuffer & i_bsb ) = delete;
+ BitString & operator=(const BitStringBuffer & i_bsb) = delete;
/**
* @brief Explicitly disables copy from BitStringBuffer.
@@ -349,7 +348,7 @@
* Allowing this would be dangerous if the BitStringBuffer goes out of scope
* because the BitString would point to memory that is no longer in context.
*/
- BitString( const BitStringBuffer & i_bsb ) = delete;
+ BitString(const BitStringBuffer & i_bsb) = delete;
protected: // functions
@@ -358,10 +357,10 @@
* @pre Before calling this function, make sure you deallocate the old
* buffer to avoid memory leaks.
*/
- void setBufAddr( void * i_newBufAddr ) { iv_bufAddr = i_newBufAddr; }
+ void setBufAddr(void * i_newBufAddr) { iv_bufAddr = i_newBufAddr; }
/** @param i_newBitLen The new bit length of this bit string buffer. */
- void setBitLen( uint64_t i_newBitLen ) { iv_bitLen = i_newBitLen; }
+ void setBitLen(uint64_t i_newBitLen) { iv_bitLen = i_newBitLen; }
private: // functions
@@ -375,8 +374,8 @@
* @pre nullptr != getBufAddr()
* @pre i_absPos < getBitLen()
*/
- uint8_t * getRelativePosition( uint64_t & o_relPos,
- uint64_t i_absPos ) const;
+ uint8_t * getRelativePosition(uint64_t & o_relPos,
+ uint64_t i_absPos) const;
private: // instance variables
@@ -402,22 +401,22 @@
* @brief Constructor
* @param i_bitLen Number of bits in the string.
*/
- explicit BitStringBuffer( uint64_t i_bitLen );
+ explicit BitStringBuffer(uint64_t i_bitLen);
/** @brief Destructor */
~BitStringBuffer();
/** @brief Copy constructor from BitString */
- BitStringBuffer( const BitString & i_bs );
+ BitStringBuffer(const BitString & i_bs);
/** @brief Copy constructor from BitStringBuffer */
- BitStringBuffer( const BitStringBuffer & i_bsb );
+ BitStringBuffer(const BitStringBuffer & i_bsb);
/** @brief Assignment from BitString */
- BitStringBuffer & operator=( const BitString & i_bs );
+ BitStringBuffer & operator=(const BitString & i_bs);
/** @brief Assignment from BitStringBuffer */
- BitStringBuffer & operator=( const BitStringBuffer & i_bsb );
+ BitStringBuffer & operator=(const BitStringBuffer & i_bsb);
private: // functions
@@ -427,4 +426,3 @@
};
} // end namespace libhei
-
diff --git a/src/util/hei_flyweight.hpp b/src/util/hei_flyweight.hpp
index f308e3c..cd56d82 100644
--- a/src/util/hei_flyweight.hpp
+++ b/src/util/hei_flyweight.hpp
@@ -20,10 +20,10 @@
~Flyweight() { clear(); }
/** @brief Default copy constructor. */
- Flyweight( const Flyweight & ) = delete;
+ Flyweight(const Flyweight &) = delete;
/** @brief Default assignment operator. */
- Flyweight & operator=( const Flyweight & ) = delete;
+ Flyweight & operator=(const Flyweight &) = delete;
public:
@@ -40,20 +40,21 @@
* @param The target entry.
* @return A reference to this entry in the factory.
*/
- T & get( const T & i_entry )
+ T & get(const T & i_entry)
{
// The index is sorted by the value of the T objects. Check to see if
// this entry already exists in the factory.
- auto itr = std::lower_bound( iv_index.begin(), iv_index.end(), &i_entry,
- [](const T * a, const T * b) { return *a < *b; } );
+ auto itr =
+ std::lower_bound(iv_index.begin(), iv_index.end(), &i_entry,
+ [](const T * a, const T * b) { return *a < *b; });
// std::lower_bound() will return the first element that does not
// compare less than i_entry. So if an entry is found, we must make sure
// it does not have the same value as i_entry.
- if ( iv_index.end() == itr || !(i_entry == *(*itr)) )
+ if (iv_index.end() == itr || !(i_entry == *(*itr)))
{
// Create a new entry and store the pointer in the sorted index.
- itr = iv_index.insert( itr, new T { i_entry } );
+ itr = iv_index.insert(itr, new T { i_entry });
}
// Return a reference to this entry in the factory.
@@ -67,7 +68,7 @@
*/
void clear()
{
- for ( auto i : iv_index ) { delete i; }
+ for (auto i : iv_index) { delete i; }
iv_index.clear();
}
@@ -105,4 +106,3 @@
};
} // end namespace libhei
-