Namespaces unified (sal+fi -> fail), Code cleanups (-> coding-style.txt), Doxygen-comments fixed.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1319 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-06-07 17:47:19 +00:00
parent cdd5379e19
commit b7d904140e
136 changed files with 1487 additions and 1554 deletions

View File

@ -1,9 +1,12 @@
#ifndef __BUFFERCACHE_HPP__
#define __BUFFERCACHE_HPP__
#ifndef __BUFFER_CACHE_HPP__
#define __BUFFER_CACHE_HPP__
#include <stdlib.h>
namespace fi {
// FIXME: (Maybe) This should be located in utils, because
// it's "Fail*-independend"...?
namespace fail {
/**
* \class BufferCache
@ -18,24 +21,24 @@ namespace fi {
template<class T> class BufferCache {
public:
BufferCache()
: m_Buffer(NULL), m_Buffer_count(0) {}
: m_Buffer(NULL), m_BufferCount(0) {}
~BufferCache() {}
/**
* Add an element to the array. The object pointed to remains untouched.
* @param val the element to add
* @returns 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
* @return 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
*/
int add(T val);
/**
* Remove an element from the array. The object pointed to remains untouched.
* @param val the element to remove
* @returns 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
* @return 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
*/
int remove(T val);
/**
* Remove an element at a specific position. The object pointed to remains untouched.
* @param val the element to remove
* @returns a pointer to the given element's successor if successful, -1 otherwise
* @return a pointer to the given element's successor if successful, -1 otherwise
*/
int erase(int i);
/**
@ -45,7 +48,7 @@ public:
/**
* Retrieve an element from the array. Should be inlined.
* @param idx the position to retrieve the element from
* @returns the element at the given position
* @return the element at the given position
*/
inline T get(size_t idx) { return m_Buffer[idx]; }
/**
@ -56,27 +59,29 @@ public:
inline void set(size_t idx, T val) { m_Buffer[idx] = val; }
/**
* Retrieves the current length of the array. Should be inlined.
* @returns the array length
* @return the array length
*/
inline size_t get_count() { return m_Buffer_count; }
inline size_t getCount() { return m_BufferCount; }
protected:
/**
* Changes the current length of the array. Should be inlined.
* @param new_count the new array length
*/
inline void set_count(size_t new_count) { m_Buffer_count = new_count; }
inline void setCount(size_t new_count) { m_BufferCount = new_count; }
/**
* Reallocates the buffer. This implementation is extremely primitive,
* but since the amount of entries is small,
* this will not be significant, hopefully. Should be inlined.
* @param new_size the new number of elements in the array
* @returns 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
* @return 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
*/
inline int reallocate_buffer(size_t new_size);
private:
// TODO: comments needed!
T *m_Buffer;
size_t m_Buffer_count;
size_t m_BufferCount;
};
} /* namespace fi */
#endif /* BUFFERCACHE_H_ */
} // end-of-namespace: fail
#endif // __BUFFER_CACHE_HPP__