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:
@ -1,11 +1,10 @@
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
#include <time.h>
|
||||
|
||||
#include "Logger.hpp"
|
||||
|
||||
using std::endl;
|
||||
namespace fail {
|
||||
|
||||
void Logger::timestamp()
|
||||
{
|
||||
@ -23,3 +22,5 @@ void Logger::timestamp()
|
||||
}
|
||||
(*m_pDest) << "] ";
|
||||
}
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class Logger
|
||||
* Provides logging mechanisms.
|
||||
@ -58,4 +60,6 @@ class Logger
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* __LOGGER_HPP__ */
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __LOGGER_HPP__
|
||||
|
||||
@ -7,8 +7,11 @@ using namespace boost::icl;
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "SAL/SALConfig.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class MemoryMap
|
||||
* An efficient container for memory maps with holes.
|
||||
@ -16,17 +19,17 @@ using namespace boost::icl;
|
||||
class MemoryMap
|
||||
{
|
||||
#ifdef BOOST_1_46_OR_NEWER
|
||||
typedef interval<sal::address_t>::type address_interval;
|
||||
typedef interval_set<sal::address_t>::type address_set;
|
||||
typedef interval<address_t>::type address_interval;
|
||||
typedef interval_set<address_t>::type address_set;
|
||||
|
||||
address_set as;
|
||||
public:
|
||||
MemoryMap() {}
|
||||
void clear() { as.clear(); }
|
||||
void add(sal::address_t addr, int size) { as.add(address_interval(addr, addr+size-1)); }
|
||||
void isMatching(sal::address_t addr, int size) { return intersects(as, address_interval(addr, addr+size-1)); }
|
||||
void add(address_t addr, int size) { as.add(address_interval(addr, addr+size-1)); }
|
||||
void isMatching(address_t addr, int size) { return intersects(as, address_interval(addr, addr+size-1)); }
|
||||
#endif
|
||||
std::set<sal::address_t> as;
|
||||
std::set<address_t> as;
|
||||
public:
|
||||
MemoryMap() {}
|
||||
/**
|
||||
@ -37,7 +40,7 @@ public:
|
||||
/**
|
||||
* Adds one or a sequence of addresses to the map.
|
||||
*/
|
||||
void add(sal::address_t addr, int size = 1)
|
||||
void add(address_t addr, int size = 1)
|
||||
{
|
||||
for (int i = 0; i < size; ++i) {
|
||||
as.insert(addr + i);
|
||||
@ -48,7 +51,7 @@ public:
|
||||
* Determines whether a given memory access at address \a addr with width
|
||||
* \a size hits the map.
|
||||
*/
|
||||
bool isMatching(sal::address_t addr, int size = 1)
|
||||
bool isMatching(address_t addr, int size = 1)
|
||||
{
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (as.find(addr + i) != as.end()) {
|
||||
@ -62,7 +65,7 @@ public:
|
||||
* The (STL-style) iterator of this class used to iterate over all
|
||||
* addresses in this map.
|
||||
*/
|
||||
typedef std::set<sal::address_t>::iterator iterator;
|
||||
typedef std::set<address_t>::iterator iterator;
|
||||
|
||||
/**
|
||||
* Returns an (STL-style) iterator to the beginning of the internal data
|
||||
@ -77,4 +80,6 @@ public:
|
||||
iterator end() { return as.end(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __MEMORYMAP_HPP__
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "ProtoStream.hpp"
|
||||
|
||||
using namespace std;
|
||||
namespace fail {
|
||||
|
||||
ProtoOStream::ProtoOStream(std::ostream *outfile) : m_outfile(outfile)
|
||||
{
|
||||
@ -14,7 +14,7 @@ bool ProtoOStream::writeMessage(google::protobuf::Message* m)
|
||||
m_outfile->write(reinterpret_cast<char*>(&m_size), sizeof(m_size));
|
||||
|
||||
if (m_outfile->bad()) {
|
||||
m_log << "Could not write to file!" << endl;
|
||||
m_log << "Could not write to file!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -23,9 +23,6 @@ bool ProtoOStream::writeMessage(google::protobuf::Message* m)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//PROTOISTREAM
|
||||
|
||||
ProtoIStream::ProtoIStream(std::istream *infile) : m_infile(infile)
|
||||
{
|
||||
m_log.setDescription("ProtoStream");
|
||||
@ -35,7 +32,7 @@ ProtoIStream::ProtoIStream(std::istream *infile) : m_infile(infile)
|
||||
void ProtoIStream::reset()
|
||||
{
|
||||
m_infile->clear();
|
||||
m_infile->seekg(0,ios::beg);
|
||||
m_infile->seekg(0, std::ios::beg);
|
||||
}
|
||||
|
||||
bool ProtoIStream::getNext(google::protobuf::Message* m)
|
||||
@ -55,6 +52,8 @@ bool ProtoIStream::getNext(google::protobuf::Message* m)
|
||||
std::string st(buf, m_size);
|
||||
m->ParseFromString(st);
|
||||
|
||||
delete[] buf;
|
||||
delete [] buf;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __PROTOSTREAM_HPP__
|
||||
#define __PROTOSTREAM_HPP__
|
||||
#define __PROTOSTREAM_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
@ -22,6 +22,8 @@
|
||||
|
||||
#include "Logger.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
/**
|
||||
* \class ProtoOStream
|
||||
*
|
||||
@ -47,7 +49,6 @@ class ProtoOStream
|
||||
bool writeMessage(google::protobuf::Message* m);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \class ProtoIStream
|
||||
*
|
||||
@ -80,4 +81,6 @@ class ProtoIStream
|
||||
bool getNext(google::protobuf::Message* m);
|
||||
};
|
||||
|
||||
#endif
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __PROTOSTREAM_HPP__
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
#include "SynchronizedCounter.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
int SynchronizedCounter::increment()
|
||||
{
|
||||
// Acquire lock on the queue
|
||||
@ -27,4 +28,5 @@ int SynchronizedCounter::getValue()
|
||||
#endif
|
||||
return m_counter;
|
||||
} // Lock is automatically released here
|
||||
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
// Thread safe counter
|
||||
|
||||
#ifndef __SYNCHRONIZED_COUNTER_HPP__
|
||||
#define __SYNCHRONIZED_COUNTER_HPP__
|
||||
#define __SYNCHRONIZED_COUNTER_HPP__
|
||||
|
||||
#ifndef __puma
|
||||
#include <boost/thread.hpp>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
namespace fail {
|
||||
|
||||
class SynchronizedCounter
|
||||
{
|
||||
private:
|
||||
@ -23,4 +25,6 @@ private:
|
||||
int getValue();
|
||||
};
|
||||
|
||||
#endif
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __SYNCHRONIZED_COUNTER_HPP__
|
||||
|
||||
@ -2,13 +2,16 @@
|
||||
// TODO We should consider to use Aspects for synchronisation primitives..
|
||||
|
||||
#ifndef __SYNCHRONIZED_MAP_HPP__
|
||||
#define __SYNCHRONIZED_MAP_HPP__
|
||||
#define __SYNCHRONIZED_MAP_HPP__
|
||||
|
||||
#include <map>
|
||||
|
||||
#ifndef __puma
|
||||
#include <boost/thread.hpp>
|
||||
#endif
|
||||
|
||||
namespace fail {
|
||||
|
||||
template <typename Tkey, typename Tvalue>
|
||||
class SynchronizedMap
|
||||
{
|
||||
@ -103,7 +106,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
} // Lock is automatically released here
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __SYNCHRONIZED_MAP_HPP__
|
||||
|
||||
@ -2,13 +2,16 @@
|
||||
// from: http://www.quantnet.com/cplusplus-multithreading-boost/
|
||||
|
||||
#ifndef __SYNCHRONIZED_QUEUE_HPP__
|
||||
#define __SYNCHRONIZED_QUEUE_HPP__
|
||||
#define __SYNCHRONIZED_QUEUE_HPP__
|
||||
|
||||
#include <queue>
|
||||
|
||||
#ifndef __puma
|
||||
#include <boost/thread.hpp>
|
||||
#endif
|
||||
|
||||
namespace fail {
|
||||
|
||||
template <typename T>
|
||||
class SynchronizedQueue
|
||||
{
|
||||
@ -84,7 +87,8 @@ private:
|
||||
return false;
|
||||
}
|
||||
} // Lock is automatically released here
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __SYNCHRONIZED_QUEUE_HPP__
|
||||
|
||||
Reference in New Issue
Block a user