- refactored Formatter -> DeFormatter, Formatter
- refactored Symbolizer -> DeSymbolizer, Symbolizer - Formatter is a Processor::Block - changed retrieval for Processor::Buffer git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@1064 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
#define __RADIO_BLOCK_H__
|
#define __RADIO_BLOCK_H__
|
||||||
|
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
|
#include <exception>
|
||||||
#include "Buffer.hpp"
|
#include "Buffer.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace Processor
|
namespace Processor
|
||||||
{
|
{
|
||||||
class Block
|
class Block
|
||||||
@@ -24,16 +24,6 @@ class Block
|
|||||||
|
|
||||||
virtual void process() = 0;
|
virtual void process() = 0;
|
||||||
|
|
||||||
IBuffer* buffer_in(size_t index=0) const
|
|
||||||
{
|
|
||||||
return m_buf_in;
|
|
||||||
}
|
|
||||||
|
|
||||||
IBuffer* buffer_out(size_t index=0) const
|
|
||||||
{
|
|
||||||
return m_buf_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t num_in() const
|
size_t num_in() const
|
||||||
{
|
{
|
||||||
return m_num_in;
|
return m_num_in;
|
||||||
@@ -54,6 +44,36 @@ class Block
|
|||||||
m_buf_out = buf;
|
m_buf_out = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Buffer<T>* buffer_in(size_t index=0)
|
||||||
|
{
|
||||||
|
Buffer<T> *buf = nullptr;
|
||||||
|
if (m_buf_in)
|
||||||
|
{
|
||||||
|
buf = dynamic_cast<Processor::Buffer<T>*>(m_buf_in);
|
||||||
|
}
|
||||||
|
if (!buf)
|
||||||
|
{
|
||||||
|
throw Exception("buffer_in() failed!");
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Buffer<T>* buffer_out(size_t index=0)
|
||||||
|
{
|
||||||
|
Buffer<T> *buf = nullptr;
|
||||||
|
if (m_buf_out)
|
||||||
|
{
|
||||||
|
buf = dynamic_cast<Processor::Buffer<T>*>(m_buf_out);
|
||||||
|
}
|
||||||
|
if (!buf)
|
||||||
|
{
|
||||||
|
throw Exception("buffer_out() failed!");
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
size_t m_num_in;
|
size_t m_num_in;
|
||||||
size_t m_num_out;
|
size_t m_num_out;
|
||||||
@@ -62,6 +82,8 @@ class Block
|
|||||||
bool m_isBypass;
|
bool m_isBypass;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // Processor
|
} // Processor
|
||||||
|
|
||||||
#endif // __RADIO_BLOCK_H__
|
#endif // __RADIO_BLOCK_H__
|
||||||
|
|||||||
@@ -5,9 +5,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "Exception.hpp"
|
||||||
#define EXC_MSG(code) (std::string(__PRETTY_FUNCTION__) + ", line " + std::to_string(__LINE__) + ", code " + std::to_string(code))
|
|
||||||
#define EXC_EXCEPT(code) throw Buffer::Exception(EXC_MSG(code))
|
|
||||||
|
|
||||||
#ifdef PROCESSOR_BUFFER_USE_EXCEPTIONS
|
#ifdef PROCESSOR_BUFFER_USE_EXCEPTIONS
|
||||||
#define RETURN_OR_EXCEPT(code) EXC_EXCEPT(code)
|
#define RETURN_OR_EXCEPT(code) EXC_EXCEPT(code)
|
||||||
@@ -17,6 +15,25 @@
|
|||||||
|
|
||||||
namespace Processor
|
namespace Processor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Exception : public std::exception
|
||||||
|
{
|
||||||
|
std::string m_msg;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Exception(std::string msg)
|
||||||
|
: std::exception()
|
||||||
|
, m_msg(msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
const char* what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW
|
||||||
|
{
|
||||||
|
return m_msg.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class IBuffer
|
class IBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -33,23 +50,6 @@ class Buffer : public IBuffer
|
|||||||
Err_InvalidSize=1
|
Err_InvalidSize=1
|
||||||
};
|
};
|
||||||
|
|
||||||
class Exception : public std::exception
|
|
||||||
{
|
|
||||||
std::string m_msg;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Exception(std::string msg)
|
|
||||||
: std::exception()
|
|
||||||
, m_msg(msg)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
const char* what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW
|
|
||||||
{
|
|
||||||
return m_msg.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
Buffer(size_t capacity=0);
|
Buffer(size_t capacity=0);
|
||||||
~Buffer();
|
~Buffer();
|
||||||
Buffer(const Buffer<T> &rhs) = delete;
|
Buffer(const Buffer<T> &rhs) = delete;
|
||||||
|
|||||||
Reference in New Issue
Block a user