Go to the documentation of this file.
42 using std::insert_iterator;
54 namespace ReferenceManager {
90 reference_(aList.reference_) {
92 for (SafePointerListType::iterator i = aList.
list_.begin();
93 i != aList.
list_.end(); i++) {
117 for (SafePointerListType::iterator i =
list_.begin();
118 i !=
list_.end(); i++) {
135 list_.push_back(newSafePointer);
147 if (anotherSafePointerList == NULL) {
152 insert_iterator<SafePointerListType> ii(
list_,
155 copy(anotherSafePointerList->
list_.begin(),
156 anotherSafePointerList->
list_.end(), ii);
176 for (SafePointerListType::iterator i =
list_.begin();
246 if (
object != NULL) {
270 (pointerToCheck != NULL &&
291 return (theList->
length() > 0);
409 return genericKeyFor<SectionKey>(obj, *
sectionMap_);
429 assert(listOfObj != NULL);
458 if (safePointer == &
null) {
462 unsigned int pointersFound = 0;
463 pointersFound = (*aliveSafePointers_).erase(safePointer);
464 assert(pointersFound == 1);
500 std::stringstream errorMessage;
501 errorMessage <<
"Cannot find section with identification code "
502 << key.
sectionId() <<
" in the section map.";
505 errorMessage <<
" SafePointer created in : "
506 << l->
front()->debugString();
510 __FILE__, __LINE__,
__func__, errorMessage.str());
517 assert(pointersToSection != NULL);
522 if (theSection == NULL) {
523 std::stringstream errorMessage;
524 errorMessage <<
"Can't get section of reference pointed "
525 <<
"by SectionOffsetKey.";
528 errorMessage <<
" SafePointer created in : "
529 << l->
front()->debugString();
533 __FILE__, __LINE__,
__func__, errorMessage.str());
545 std::stringstream errorMessage;
546 errorMessage <<
"Can't resolve section offset, because there"
547 <<
" no object stored stored for key sectionId: "
550 errorMessage <<
" SafePointer created in : "
551 << l->
front()->debugString();
555 "SafePointer::resolve()",
565 std::stringstream errorMessage;
571 dynamic_cast<const SectionKey*
>(unresolvedKey);
573 errorMessage <<
"with section keys. Requested identification code: "
577 firstUnresolvedPointerOfList =
585 errorMessage <<
"Problem with section index keys. "
586 <<
"Requested section identification code: "
587 <<
static_cast<int>(indexKey->
sectionId())
589 << indexKey->
index() << std::endl;
591 firstUnresolvedPointerOfList =
600 errorMessage <<
"Problem with section offset keys. "
601 <<
"Requested section identification code: "
602 <<
static_cast<int>(sectionOffsetKey->
sectionId())
604 << sectionOffsetKey->
offset() << std::endl;
606 firstUnresolvedPointerOfList =
614 errorMessage <<
"Problem with file offset keys. "
615 <<
"Requested section identification code: "
618 firstUnresolvedPointerOfList =
622 if (errorMessage.str() !=
"") {
625 assert(firstUnresolvedPointerOfList != NULL);
626 errorMessage <<
" SafePointer created in : "
627 << firstUnresolvedPointerOfList->debugString();
630 __FILE__, __LINE__,
__func__, errorMessage.str());
646 set<SafePointerList*> listsToDelete;
676 #ifndef DOXYGEN_SHOULD_SKIP_THIS
680 SafePointer::SIMap() {
684 const SafePointerList*
694 SafePointer::SOMap() {
698 const SafePointerList*
699 SafePointer::SOMapAt(SectionOffsetKey k) {
708 SafePointer::FOMap() {
713 const SafePointerList*
714 SafePointer::FOMapAt(FileOffsetKey k) {
723 SafePointer::RMap() {
727 const SafePointerList*
728 SafePointer::RMapAt(SafePointable* k) {
737 SafePointer::SMap() {
741 const SafePointerList*
742 SafePointer::SMapAt(SectionKey k) {
751 SafePointer::setDebugString(std::string aString) {
756 SafePointer::debugString()
const {
FileOffset fileOffset() const
SectionOffset offset() const
virtual Chunk * chunk(SectionOffset offset) const
static bool isReferenced(const SafePointable *object)
void setReference(const SafePointable *obj)
SafePointable * reference_
Object that SafePointers in this list are pointing to.
SectionIndex index() const
void genericRegisterPointer(const KeyType &key, MapType &destinationMap, SafePointer *newSafePointer)
static FileOffsetKey fileOffsetKeyFor(const SafePointable *obj)
std::set< SafePointer * > SafePointerSet
Unordered set of SafePointers.
LengthType length() const
static const SafePointer null
The default SafePointer that is used in null references.
static SectionOffsetMap * sectionOffsetMap_
Map of SafePointers that are requested using SectionOffsetKeys.
std::map< const SafePointable *, SafePointerList * > ReferenceMap
Map for resolved references, that is SafePointers that are pointing to the created object.
SectionId sectionId() const
static void genericAddObjectReference(const KeyType &key, MapType &destinationMap, const SafePointable *obj)
static void addObjectReference(SectionIndexKey key, const SafePointable *obj)
static KeyForCacheMap * keyForCache_
Map for cache.
static void notifyDeleted(const SafePointable *obj)
std::map< SectionIndexKey, SafePointerList * > SectionIndexMap
Map for SafePointers that are requested using SectionIndexKeys.
static SectionMap * sectionMap_
Map of SafePointers that are requested using SectionKeys.
static FileOffsetMap * fileOffsetMap_
Map of SafePointers that are requested using FileOffsetKeys.
#define assert(condition)
static void cleanupKeyTables()
SectionId sectionId() const
std::map< FileOffsetKey, SafePointerList * > FileOffsetMap
Map for SafePointers that are requested using FileOffsetKeys.
SectionId sectionId() const
static ReferenceMap * referenceMap_
Map of SafePointers that have resolved references.
SafePointable * reference() const
std::map< SectionOffsetKey, SafePointerList * > SectionOffsetMap
Map for SafePointers that are requested using SectionOffsetKeys.
static SectionKey sectionKeyFor(const SafePointable *obj)
static SectionOffsetKey sectionOffsetKeyFor(const SafePointable *obj)
void append(SafePointer *newSafePointer)
static SafePointerSet * aliveSafePointers_
Set that cointains all alive (not deleted) SafePointers for extra safety.
void setPointer(SafePointable *object)
static SectionIndexMap * sectionIndexMap_
Map of SafePointers that are requested using SectionIndexKeys.
std::map< KeyForCacheKey, const ReferenceKey * > KeyForCacheMap
SafePointer(SectionIndexKey key)
static void safelyCleanupKeyTable(MapType &sourceMap, std::set< SafePointerList * > &listsToDelete)
static bool isAlive(SafePointer *pointerToCheck)
SafePointer * front() const
SafePointerListType list_
Container for SafePointers.
static bool unresolvedReferences(const MapType &mapToCheck, const ReferenceKey **unresolvedKey)
static SectionIndexKey sectionIndexKeyFor(const SafePointable *obj)
std::map< SectionKey, SafePointerList * > SectionMap
Map for SafePointers that are requested using SectionKeys.
virtual ~SafePointerList()