xref: /netbsd-src/external/bsd/elftosb/dist/common/Operation.cpp (revision 993229b6fea628ff8b1fa09146c80b0cfb2768eb)
1*993229b6Sjkunz /*
2*993229b6Sjkunz  * File:	Operation.cpp
3*993229b6Sjkunz  *
4*993229b6Sjkunz  * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5*993229b6Sjkunz  * See included license file for license details.
6*993229b6Sjkunz  */
7*993229b6Sjkunz 
8*993229b6Sjkunz #include "Operation.h"
9*993229b6Sjkunz 
10*993229b6Sjkunz using namespace elftosb;
11*993229b6Sjkunz 
12*993229b6Sjkunz //! The operation object takes ownership of \a source.
13*993229b6Sjkunz //!
14*993229b6Sjkunz //! Cross references between the target and source are updated.
setSource(DataSource * source)15*993229b6Sjkunz void LoadOperation::setSource(DataSource * source)
16*993229b6Sjkunz {
17*993229b6Sjkunz 	m_source = source;
18*993229b6Sjkunz 
19*993229b6Sjkunz 	if (m_target)
20*993229b6Sjkunz 	{
21*993229b6Sjkunz 		m_target->setSource(m_source);
22*993229b6Sjkunz 	}
23*993229b6Sjkunz 	if (m_source)
24*993229b6Sjkunz 	{
25*993229b6Sjkunz 		m_source->setTarget(m_target);
26*993229b6Sjkunz 	}
27*993229b6Sjkunz }
28*993229b6Sjkunz 
29*993229b6Sjkunz //! The operation object takes ownership of \a target.
30*993229b6Sjkunz //!
31*993229b6Sjkunz //! Cross references between the target and source are updated.
setTarget(DataTarget * target)32*993229b6Sjkunz void LoadOperation::setTarget(DataTarget * target)
33*993229b6Sjkunz {
34*993229b6Sjkunz 	m_target = target;
35*993229b6Sjkunz 
36*993229b6Sjkunz 	if (m_target)
37*993229b6Sjkunz 	{
38*993229b6Sjkunz 		m_target->setSource(m_source);
39*993229b6Sjkunz 	}
40*993229b6Sjkunz 	if (m_source)
41*993229b6Sjkunz 	{
42*993229b6Sjkunz 		m_source->setTarget(m_target);
43*993229b6Sjkunz 	}
44*993229b6Sjkunz }
45*993229b6Sjkunz 
46*993229b6Sjkunz //! Disposes of operations objects in the sequence.
~OperationSequence()47*993229b6Sjkunz OperationSequence::~OperationSequence()
48*993229b6Sjkunz {
49*993229b6Sjkunz //	iterator_t it = begin();
50*993229b6Sjkunz //	for (; it != end(); ++it)
51*993229b6Sjkunz //	{
52*993229b6Sjkunz //		delete it->second;
53*993229b6Sjkunz //	}
54*993229b6Sjkunz }
55*993229b6Sjkunz 
append(const OperationSequence * other)56*993229b6Sjkunz void OperationSequence::append(const OperationSequence * other)
57*993229b6Sjkunz {
58*993229b6Sjkunz 	const_iterator_t it = other->begin();
59*993229b6Sjkunz 	for (; it != other->end(); ++it)
60*993229b6Sjkunz 	{
61*993229b6Sjkunz 		m_operations.push_back(*it);
62*993229b6Sjkunz 	}
63*993229b6Sjkunz }
64