15b60969cSIngo Weinhold/*
25b60969cSIngo Weinhold * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
35b60969cSIngo Weinhold * Distributed under the terms of the MIT License.
45b60969cSIngo Weinhold */
55b60969cSIngo Weinhold#ifndef TARGET_ADDRESS_RANGE_LIST_H
65b60969cSIngo Weinhold#define TARGET_ADDRESS_RANGE_LIST_H
75b60969cSIngo Weinhold
89395c270SIngo Weinhold
99395c270SIngo Weinhold#include <Array.h>
105b60969cSIngo Weinhold#include <Referenceable.h>
115b60969cSIngo Weinhold
125b60969cSIngo Weinhold#include "TargetAddressRange.h"
135b60969cSIngo Weinhold
145b60969cSIngo Weinhold
15c3e066cfSIngo Weinholdclass TargetAddressRangeList : public BReferenceable {
165b60969cSIngo Weinholdpublic:
175b60969cSIngo Weinhold								TargetAddressRangeList();
185b60969cSIngo Weinhold								TargetAddressRangeList(
195b60969cSIngo Weinhold									const TargetAddressRange& range);
205b60969cSIngo Weinhold								TargetAddressRangeList(
215b60969cSIngo Weinhold									const TargetAddressRangeList& other);
225b60969cSIngo Weinhold
235b60969cSIngo Weinhold			void				Clear();
245b60969cSIngo Weinhold			bool				AddRange(const TargetAddressRange& range);
255b60969cSIngo Weinhold	inline	bool				AddRange(target_addr_t start,
265b60969cSIngo Weinhold									target_size_t size);
275b60969cSIngo Weinhold
285b60969cSIngo Weinhold			int32				CountRanges() const;
295b60969cSIngo Weinhold			TargetAddressRange	RangeAt(int32 index) const;
305b60969cSIngo Weinhold
315b60969cSIngo Weinhold			target_addr_t		LowestAddress() const;
325b60969cSIngo Weinhold			TargetAddressRange	CoveringRange() const;
335b60969cSIngo Weinhold
34502fcbccSIngo Weinhold			bool				Contains(target_addr_t address) const;
35502fcbccSIngo Weinhold
365b60969cSIngo Weinhold			TargetAddressRangeList& operator=(
375b60969cSIngo Weinhold									const TargetAddressRangeList& other);
385b60969cSIngo Weinhold
395b60969cSIngo Weinholdprivate:
405b60969cSIngo Weinhold	typedef Array<TargetAddressRange> RangeArray;
415b60969cSIngo Weinhold
425b60969cSIngo Weinholdprivate:
435b60969cSIngo Weinhold			RangeArray			fRanges;
445b60969cSIngo Weinhold};
455b60969cSIngo Weinhold
465b60969cSIngo Weinhold
475b60969cSIngo Weinholdbool
485b60969cSIngo WeinholdTargetAddressRangeList::AddRange(target_addr_t start, target_size_t size)
495b60969cSIngo Weinhold{
505b60969cSIngo Weinhold	return AddRange(TargetAddressRange(start, size));
515b60969cSIngo Weinhold}
525b60969cSIngo Weinhold
535b60969cSIngo Weinhold
545b60969cSIngo Weinhold#endif	// TARGET_ADDRESS_RANGE_LIST_H
55