apps/elftosb/common/DataTarget.h
/*
* File: DataTarget.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
#if !defined(_DataTarget_h_)
#define _DataTarget_h_
#include "stdafx.h"
#include "DataSource.h"
namespace elftosb
{
// Forward declaration
class DataSource;
class DataTarget
{
public:
struct AddressRange
{
uint32_t m_begin;
uint32_t m_end;
};
public:
DataTarget()
: m_source(0)
{
}
virtual ~DataTarget() {}
virtual bool isBounded() { return false; }
virtual uint32_t getBeginAddress() { return 0; }
virtual uint32_t getEndAddress() { return 0; }
virtual DataTarget::AddressRange getRangeForSegment(DataSource &source, DataSource::Segment &segment) = 0;
inline void setSource(DataSource *source) { m_source = source; }
inline DataSource *getSource() const { return m_source; }
protected:
DataSource *m_source;
};
class ConstantDataTarget : public DataTarget
{
public:
ConstantDataTarget(uint32_t start)
: DataTarget()
, m_begin(start)
, m_end(0)
, m_hasEnd(false)
{
}
ConstantDataTarget(uint32_t start, uint32_t end)
: DataTarget()
, m_begin(start)
, m_end(end)
, m_hasEnd(true)
{
}
virtual bool isBounded() { return m_hasEnd; }
virtual uint32_t getBeginAddress() { return m_begin; }
virtual uint32_t getEndAddress() { return m_end; }
virtual DataTarget::AddressRange getRangeForSegment(DataSource &source, DataSource::Segment &segment);
protected:
uint32_t m_begin;
uint32_t m_end;
bool m_hasEnd;
};
class NaturalDataTarget : public DataTarget
{
public:
NaturalDataTarget()
: DataTarget()
{
}
virtual bool isBounded() { return true; }
virtual DataTarget::AddressRange getRangeForSegment(DataSource &source, DataSource::Segment &segment);
};
}; // namespace elftosb
#endif // _DataTarget_h_
elftosb::DataSource
Abstract base class for data sources.
Definition: apps/elftosb/common/DataSource.h:33
elftosb::ConstantDataTarget::m_begin
uint32_t m_begin
Start address.
Definition: apps/elftosb/common/DataTarget.h:103
elftosb::ConstantDataTarget::ConstantDataTarget
ConstantDataTarget(uint32_t start)
Constructor taking only a begin address.
Definition: apps/elftosb/common/DataTarget.h:78
elftosb::ConstantDataTarget
Target with a constant values for the addresses.
Definition: apps/elftosb/common/DataTarget.h:74
elftosb::NaturalDataTarget::NaturalDataTarget
NaturalDataTarget()
Default constructor.
Definition: apps/elftosb/common/DataTarget.h:119
elftosb::DataTarget::DataTarget
DataTarget()
Default constructor.
Definition: apps/elftosb/common/DataTarget.h:47
elftosb::DataTarget::isBounded
virtual bool isBounded()
Whether the target is just a single address or has an end to it.
Definition: apps/elftosb/common/DataTarget.h:55
elftosb
Definition: BootImage.h:13
elftosb::DataTarget::getRangeForSegment
virtual DataTarget::AddressRange getRangeForSegment(DataSource &source, DataSource::Segment &segment)=0
Return the address range for a segment of a data source.
elftosb::DataTarget
Abstract base class for the target address or range of data.
Definition: apps/elftosb/common/DataTarget.h:34
elftosb::NaturalDataTarget
Target address that is the "natural" location of whatever the source data is.
Definition: apps/elftosb/common/DataTarget.h:115
elftosb::DataTarget::AddressRange
Simple structure that describes an addressed region of memory.
Definition: apps/elftosb/common/DataTarget.h:39
elftosb::DataTarget::m_source
DataSource * m_source
Corresponding data source for this target.
Definition: apps/elftosb/common/DataTarget.h:64
elftosb::DataTarget::~DataTarget
virtual ~DataTarget()
Destructor.
Definition: apps/elftosb/common/DataTarget.h:53
elftosb::ConstantDataTarget::ConstantDataTarget
ConstantDataTarget(uint32_t start, uint32_t end)
Constructor taking both begin and end addresses.
Definition: apps/elftosb/common/DataTarget.h:87
elftosb::DataSource::Segment
Discrete, contiguous part of the source&#39;s data.
Definition: apps/elftosb/common/DataSource.h:42
elftosb::ConstantDataTarget::m_end
uint32_t m_end
End address.
Definition: apps/elftosb/common/DataTarget.h:104
elftosb::ConstantDataTarget::m_hasEnd
bool m_hasEnd
Was an end address specified?
Definition: apps/elftosb/common/DataTarget.h:105
elftosb::ConstantDataTarget::isBounded
virtual bool isBounded()
The target is bounded if an end address was specified.
Definition: apps/elftosb/common/DataTarget.h:96
elftosb::NaturalDataTarget::isBounded
virtual bool isBounded()
Natural data targets are bounded by their source&#39;s segment lengths.
Definition: apps/elftosb/common/DataTarget.h:125