OpenASIP  2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TPEF::ReferenceManager::SafePointer Class Reference

#include <SafePointer.hh>

Collaboration diagram for TPEF::ReferenceManager::SafePointer:
Collaboration graph

Public Member Functions

virtual ~SafePointer ()
 
SafePointablepointer () const
 
void setPointer (SafePointable *object)
 

Static Public Member Functions

static bool isAlive (SafePointer *pointerToCheck)
 
static bool isReferenced (const SafePointable *object)
 
static void addObjectReference (SectionIndexKey key, const SafePointable *obj)
 
static void addObjectReference (SectionOffsetKey key, const SafePointable *obj)
 
static void addObjectReference (FileOffsetKey key, const SafePointable *obj)
 
static void addObjectReference (SectionKey key, const SafePointable *obj)
 
static SectionIndexKey sectionIndexKeyFor (const SafePointable *obj)
 
static SectionOffsetKey sectionOffsetKeyFor (const SafePointable *obj)
 
static FileOffsetKey fileOffsetKeyFor (const SafePointable *obj)
 
static SectionKey sectionKeyFor (const SafePointable *obj)
 
static void notifyDeleted (const SafePointable *obj)
 
static void notifyDeleted (SafePointer *safePointer)
 
static void resolve ()
 
static void cleanupKeyTables ()
 
static void cleanup ()
 
template<typename MapType >
static bool unresolvedReferences (const MapType &mapToCheck, const ReferenceKey **unresolvedKey)
 
static const SafePointerreplaceReference (const SafePointer *old, SafePointable *obj)
 
static void replaceAllReferences (SafePointable *newObj, SafePointable *oldObj)
 
template<typename ObjType >
static SafePointergenericCreate (ObjType obj)
 

Static Public Attributes

static const SafePointer null
 The default SafePointer that is used in null references. More...
 

Protected Member Functions

 SafePointer (SectionIndexKey key)
 
 SafePointer (SectionOffsetKey key)
 
 SafePointer (FileOffsetKey key)
 
 SafePointer (SectionKey key)
 
 SafePointer (SafePointable *object)
 
template<typename KeyType , typename MapType >
void genericRegisterPointer (const KeyType &key, MapType &destinationMap, SafePointer *newSafePointer)
 

Static Protected Member Functions

template<typename KeyType , typename MapType >
static void genericAddObjectReference (const KeyType &key, MapType &destinationMap, const SafePointable *obj)
 
template<typename KeyType , typename MapType >
static KeyType genericKeyFor (const SafePointable *obj, MapType &sourceMap)
 
template<typename MapType >
static void safelyCleanupKeyTable (MapType &sourceMap, std::set< SafePointerList * > &listsToDelete)
 

Private Types

typedef std::pair< const SafePointable *, void * > KeyForCacheKey
 Key type for cache, void* is pointer to key map (sectioMap_, sectionOffsetMap, ...) More...
 
typedef std::map< KeyForCacheKey, const ReferenceKey * > KeyForCacheMap
 

Private Member Functions

SafePointeroperator= (SafePointer &)
 Assignment not allowed. More...
 
 SafePointer (SafePointer &)
 Copying not allowed. More...
 

Private Attributes

SafePointableobject_
 The reference to the real object. More...
 
std::string debugString_
 

Static Private Attributes

static SectionIndexMapsectionIndexMap_ = new SectionIndexMap
 Map of SafePointers that are requested using SectionIndexKeys. More...
 
static SectionOffsetMapsectionOffsetMap_ = new SectionOffsetMap
 Map of SafePointers that are requested using SectionOffsetKeys. More...
 
static FileOffsetMapfileOffsetMap_ = new FileOffsetMap
 Map of SafePointers that are requested using FileOffsetKeys. More...
 
static SectionMapsectionMap_ = new SectionMap
 Map of SafePointers that are requested using SectionKeys. More...
 
static ReferenceMapreferenceMap_ = new ReferenceMap
 Map of SafePointers that have resolved references. More...
 
static SafePointerSetaliveSafePointers_ = new SafePointerSet
 Set that cointains all alive (not deleted) SafePointers for extra safety. More...
 
static KeyForCacheMapkeyForCache_
 Map for cache. More...
 

Detailed Description

Indirection for object references.

Allows updating references later on, thus allows referencing objects that are created later. Helps with the dangling pointers problem, too.

References to objects that are not created yet are made with different kind of keys. These keys refer for example to sections and offsets in source binary file while reading the binary. After the binary is read and the object model of binary is constructed, these keys and keytables have no use.

Definition at line 188 of file SafePointer.hh.

Member Typedef Documentation

◆ KeyForCacheKey

typedef std::pair<const SafePointable*, void*> TPEF::ReferenceManager::SafePointer::KeyForCacheKey
private

Key type for cache, void* is pointer to key map (sectioMap_, sectionOffsetMap, ...)

Definition at line 339 of file SafePointer.hh.

◆ KeyForCacheMap

Definition at line 340 of file SafePointer.hh.

Constructor & Destructor Documentation

◆ ~SafePointer()

TPEF::ReferenceManager::SafePointer::~SafePointer ( )
virtual

Destructor.

Informs of deletion of itself to the reference manager.

Definition at line 256 of file SafePointer.cc.

256  {
257  notifyDeleted(this);
258 }

References notifyDeleted().

Here is the call graph for this function:

◆ SafePointer() [1/6]

TPEF::ReferenceManager::SafePointer::SafePointer ( SectionIndexKey  key)
protected

Construct a SafePointer using SectionIndexKey.

Parameters
keyKey to use while requesting the reference.

Definition at line 199 of file SafePointer.cc.

199  :
200  object_(NULL) {
201 
203 }

References genericRegisterPointer(), and sectionIndexMap_.

Here is the call graph for this function:

◆ SafePointer() [2/6]

TPEF::ReferenceManager::SafePointer::SafePointer ( SectionOffsetKey  key)
protected

Construct a SafePointer using SectionOffsetKey.

Parameters
keyKey to use while requesting the reference.

Definition at line 210 of file SafePointer.cc.

210  :
211  object_(NULL) {
212 
214 }

References genericRegisterPointer(), and sectionOffsetMap_.

Here is the call graph for this function:

◆ SafePointer() [3/6]

TPEF::ReferenceManager::SafePointer::SafePointer ( FileOffsetKey  key)
protected

Construct a SafePointer using FileOffsetKey.

Parameters
keyKey to use while requesting the reference.

Definition at line 221 of file SafePointer.cc.

221  :
222  object_(NULL) {
223 
225 }

References fileOffsetMap_, and genericRegisterPointer().

Here is the call graph for this function:

◆ SafePointer() [4/6]

TPEF::ReferenceManager::SafePointer::SafePointer ( SectionKey  key)
protected

Construct a SafePointer using section reference.

Parameters
keyKey object to use while requesting the reference.

Definition at line 232 of file SafePointer.cc.

232  :
233  object_(NULL) {
234 
235  genericRegisterPointer(key, *sectionMap_, this);
236 }

References genericRegisterPointer(), and sectionMap_.

Here is the call graph for this function:

◆ SafePointer() [5/6]

TPEF::ReferenceManager::SafePointer::SafePointer ( SafePointable object)
protected

Construct a SafePointer using object reference.

Parameters
objectObject to use while requesting the reference.

Definition at line 243 of file SafePointer.cc.

243  :
244  object_(object) {
245 
246  if (object != NULL) {
247  genericRegisterPointer(object, *referenceMap_, this);
248  }
249 }

References genericRegisterPointer(), and referenceMap_.

Here is the call graph for this function:

◆ SafePointer() [6/6]

TPEF::ReferenceManager::SafePointer::SafePointer ( SafePointer )
private

Copying not allowed.

Member Function Documentation

◆ addObjectReference() [1/4]

void TPEF::ReferenceManager::SafePointer::addObjectReference ( FileOffsetKey  key,
const SafePointable obj 
)
static

Inform of a connection between a FileOffsetKey and an object.

Connects given key with object and sets possible old SafePointers connected with the key to point to this object.

Parameters
keyKey that the object is connected to.
objPointer to the connected object.
Exceptions
KeyAlreadyExistsIf entry with given key already exists.

Definition at line 337 of file SafePointer.cc.

337  {
339 }

References fileOffsetMap_, and genericAddObjectReference().

Here is the call graph for this function:

◆ addObjectReference() [2/4]

void TPEF::ReferenceManager::SafePointer::addObjectReference ( SectionIndexKey  key,
const SafePointable obj 
)
static

Inform of a connection between a SectionIndexKey and an object.

Connects given key with object and sets possible old SafePointers connected with the key to point to this object.

Parameters
keyKey that the object is connected to.
objPointer to the connected object.
Exceptions
KeyAlreadyExistsIf entry with given key already exists.

Definition at line 306 of file SafePointer.cc.

306  {
308 }

References genericAddObjectReference(), and sectionIndexMap_.

Referenced by TPEF::TPEFLineNumSectionWriter::actualWriteData(), TPEF::TPEFStringSectionWriter::actualWriteData(), TPEF::TPEFResourceSectionWriter::actualWriteData(), TPEF::TPEFRelocSectionWriter::actualWriteData(), TPEF::TPEFASpaceSectionWriter::actualWriteData(), TPEF::TPEFCodeSectionWriter::actualWriteData(), TPEF::TPEFDataSectionWriter::actualWriteData(), TPEF::TPEFDebugSectionWriter::actualWriteData(), TPEF::TPEFSymbolSectionWriter::actualWriteData(), TPEF::TPEFSectionWriter::actualWriteHeader(), TPEF::TPEFUDataSectionWriter::createKeys(), TPEF::AOutSymbolSectionReader::initializeSymbol(), TPEF::TPEFASpaceSectionReader::readData(), TPEF::TPEFSymbolSectionReader::readData(), TPEF::TPEFCodeSectionReader::readData(), TPEF::TPEFRelocSectionReader::readData(), TPEF::TPEFSectionReader::readData(), TPEF::AOutSymbolSectionReader::readData(), TPEF::TPEFReader::readData(), TPEF::AOutReader::readData(), resolve(), TPEF::AOutTextSectionReader::setReference(), and TPEF::TPEFASpaceSectionWriter::writeElement().

Here is the call graph for this function:

◆ addObjectReference() [3/4]

void TPEF::ReferenceManager::SafePointer::addObjectReference ( SectionKey  key,
const SafePointable obj 
)
static

Inform of a connection between a SectionKey and an object.

Connects given key with object and sets possible old SafePointers connected with the key to point to this object.

Parameters
keyKey that the object is connected to.
objPointer to the connected object.
Exceptions
KeyAlreadyExistsIf entry with given key already exists.

Definition at line 352 of file SafePointer.cc.

352  {
354 }

References genericAddObjectReference(), and sectionMap_.

Here is the call graph for this function:

◆ addObjectReference() [4/4]

void TPEF::ReferenceManager::SafePointer::addObjectReference ( SectionOffsetKey  key,
const SafePointable obj 
)
static

Inform of a connection between a SectionOffsetKey and an object.

Connects given key with object and sets possible old SafePointers connected with the key to point to this object.

Parameters
keyKey that the object is connected to.
objPointer to the connected object.
Exceptions
KeyAlreadyExistsIf entry with given key already exists.

Definition at line 321 of file SafePointer.cc.

322  {
324 }

References genericAddObjectReference(), and sectionOffsetMap_.

Here is the call graph for this function:

◆ cleanup()

void TPEF::ReferenceManager::SafePointer::cleanup ( )
static

Frees all dynamically allocated memory consumed in reference managing.

Deletes all entires in all maps, safe pointer lists in them and all alive safe pointers. This method should be called in the destructor of Binary or in the end of the program.

Definition at line 667 of file SafePointer.cc.

667  {
668 
671 }

References cleanupKeyTables(), MapTools::deleteAllValues(), and referenceMap_.

Referenced by TPEF::Binary::~Binary().

Here is the call graph for this function:

◆ cleanupKeyTables()

void TPEF::ReferenceManager::SafePointer::cleanupKeyTables ( )
static

Deletes all entries in all key maps, doesn't clean the ReferenceMap.

Deletes also the SafePointer lists found in the maps if they are not found in the reference map. Does not delete SafePointers. This can be called to free some needless resources after the object model of binary file is fully constructed, and resolve() is called without an exception.

Definition at line 644 of file SafePointer.cc.

644  {
645 
646  set<SafePointerList*> listsToDelete;
647  safelyCleanupKeyTable(*sectionIndexMap_, listsToDelete);
648  safelyCleanupKeyTable(*sectionOffsetMap_, listsToDelete);
649  safelyCleanupKeyTable(*fileOffsetMap_, listsToDelete);
650  safelyCleanupKeyTable(*sectionMap_, listsToDelete);
651 
652  AssocTools::deleteAllItems(listsToDelete);
653 
654  // clear keyForCache...
655  keyForCache_->clear();
656 }

References AssocTools::deleteAllItems(), fileOffsetMap_, keyForCache_, safelyCleanupKeyTable(), sectionIndexMap_, sectionMap_, and sectionOffsetMap_.

Referenced by cleanup(), TPEF::BinaryReader::readBinary(), and TPEF::BinaryWriter::writeBinary().

Here is the call graph for this function:

◆ fileOffsetKeyFor()

FileOffsetKey TPEF::ReferenceManager::SafePointer::fileOffsetKeyFor ( const SafePointable obj)
static

Returns the FileOffsetKey connected to given object.

Returns
The key.
Parameters
objObject to look the key for.
Exceptions
KeyNotFoundIf the key cannot be found for the object.

Definition at line 394 of file SafePointer.cc.

394  {
395  return genericKeyFor<FileOffsetKey>(obj, *fileOffsetMap_);
396 }

References fileOffsetMap_.

Referenced by TPEF::FileOffsetReplacer::tryToReplace().

◆ genericAddObjectReference()

template<typename KeyType , typename MapType >
static void TPEF::ReferenceManager::SafePointer::genericAddObjectReference ( const KeyType &  key,
MapType &  destinationMap,
const SafePointable obj 
)
staticprotected

Referenced by addObjectReference().

◆ genericCreate()

template<typename ObjType >
static SafePointer* TPEF::ReferenceManager::SafePointer::genericCreate ( ObjType  obj)
static

◆ genericKeyFor()

template<typename KeyType , typename MapType >
static KeyType TPEF::ReferenceManager::SafePointer::genericKeyFor ( const SafePointable obj,
MapType &  sourceMap 
)
staticprotected

◆ genericRegisterPointer()

template<typename KeyType , typename MapType >
void TPEF::ReferenceManager::SafePointer::genericRegisterPointer ( const KeyType &  key,
MapType &  destinationMap,
SafePointer newSafePointer 
)
protected

Referenced by SafePointer().

◆ isAlive()

bool TPEF::ReferenceManager::SafePointer::isAlive ( SafePointer pointerToCheck)
static

Check if SafePointer is alive, that is it's not deleted yet.

Parameters
pointerToCheckThe pointer to check.
Returns
True if SafePointer is alive.

Definition at line 267 of file SafePointer.cc.

267  {
268 
269  return
270  (pointerToCheck != NULL &&
271  AssocTools::containsKey(*aliveSafePointers_, pointerToCheck));
272 }

References aliveSafePointers_, and AssocTools::containsKey().

Referenced by TPEF::ReferenceManager::SafePointerList::cleanupDead(), and TPEF::ReferenceManager::SafePointerList::setReference().

Here is the call graph for this function:

◆ isReferenced()

bool TPEF::ReferenceManager::SafePointer::isReferenced ( const SafePointable object)
static

Check if object is referenced, that is reference manager is managing SafePointers that point to that object.

Parameters
objectObject to check.
Returns
True if object is referenced.

Definition at line 282 of file SafePointer.cc.

282  {
283 
284  if (!MapTools::containsKey(*referenceMap_, object)) {
285  return false;
286  }
287 
288  SafePointerList* theList = (*referenceMap_)[object];
289  theList->cleanupDead();
290 
291  return (theList->length() > 0);
292 }

References TPEF::ReferenceManager::SafePointerList::cleanupDead(), MapTools::containsKey(), TPEF::ReferenceManager::SafePointerList::length(), and referenceMap_.

Referenced by TPEF::TPEFStringSectionWriter::actualWriteData(), TPEF::TPEFDataSectionWriter::actualWriteData(), TPEF::TPEFCodeSectionWriter::actualWriteData(), and TPEF::TPEFUDataSectionWriter::createKeys().

Here is the call graph for this function:

◆ notifyDeleted() [1/2]

void TPEF::ReferenceManager::SafePointer::notifyDeleted ( const SafePointable obj)
static

Inform of deletion of an object.

All SafePointers that are pointing to the deleted object are set to NULL and the object's entry is removed from the ReferenceMap.

Parameters
objDeleted object.

Definition at line 421 of file SafePointer.cc.

421  {
422 
423  if (!MapTools::containsKey(*referenceMap_, obj)) {
424  return;
425  }
426 
427  SafePointerList *listOfObj = (*referenceMap_)[obj];
428 
429  assert(listOfObj != NULL);
430  listOfObj->cleanup();
431 
432  // if the safe pointer list we just cleaned up is not referenced in any
433  // map anymore, it can be deleted safely
434 
435  // TODO: for hashmap implementation this will take *very* long time
436  // so fix this before change typedefs in SafePointer.hh
437  if (!MapTools::containsValue(*sectionMap_, listOfObj) &&
440  !MapTools::containsValue(*fileOffsetMap_, listOfObj)) {
441  delete listOfObj;
442  }
443 
444  referenceMap_->erase(obj);
445 }

References assert, TPEF::ReferenceManager::SafePointerList::cleanup(), MapTools::containsKey(), MapTools::containsValue(), fileOffsetMap_, referenceMap_, sectionIndexMap_, sectionMap_, and sectionOffsetMap_.

Referenced by TPEF::SafePointable::~SafePointable(), and ~SafePointer().

Here is the call graph for this function:

◆ notifyDeleted() [2/2]

void TPEF::ReferenceManager::SafePointer::notifyDeleted ( SafePointer safePointer)
static

Inform of deletion of a SafePointer.

Removes SafePointer from the list of alive SafePointers.

Parameters
safePointerThe deleted SafePointer.

Definition at line 455 of file SafePointer.cc.

455  {
456 
457  // the null safe pointer is an exception, it shouldn't be never deleted
458  if (safePointer == &null) {
459  return;
460  }
461 
462  unsigned int pointersFound = 0;
463  pointersFound = (*aliveSafePointers_).erase(safePointer);
464  assert(pointersFound == 1);
465 }

References assert.

◆ operator=()

SafePointer& TPEF::ReferenceManager::SafePointer::operator= ( SafePointer )
private

Assignment not allowed.

◆ pointer()

SafePointable* TPEF::ReferenceManager::SafePointer::pointer ( ) const

◆ replaceAllReferences()

static void TPEF::ReferenceManager::SafePointer::replaceAllReferences ( SafePointable newObj,
SafePointable oldObj 
)
static

◆ replaceReference()

static const SafePointer* TPEF::ReferenceManager::SafePointer::replaceReference ( const SafePointer old,
SafePointable obj 
)
static

◆ resolve()

void TPEF::ReferenceManager::SafePointer::resolve ( )
static

Tries to resolve unresolved references.

Unreselved references are tried to be resolved by requesting a chunk with the section's chunk() method the reference points to. Chunks mean practically offset in the section and the size of the referenced data. If there's an unresolved reference to an offset in a section that can be chunked (section contains raw data), then we can create new elements using chunk() 'on demand'.

Exceptions
UnresolvedReferenceIf unresolvable references are found.

Definition at line 480 of file SafePointer.cc.

480  {
481  // try to resolve references in sectionOffsetMap
482  for (SectionOffsetMap::iterator i = sectionOffsetMap_->begin();
483  i != sectionOffsetMap_->end(); i++) {
484 
485  SectionOffsetKey key = (*i).first;
486 
487  SafePointerList* l = (*i).second;
488  assert(l != NULL);
489  SafePointable* object = l->reference();
490 
491  // if reference is resolved continue
492  if (MapTools::containsKey(*referenceMap_, object)) {
493  continue;
494  }
495 
496  // there is no section with the identification code of the section
497  // offset key
499  *sectionMap_, SectionKey(key.sectionId()))) {
500  std::stringstream errorMessage;
501  errorMessage << "Cannot find section with identification code "
502  << key.sectionId() << " in the section map.";
503 
504 #ifndef NDEBUG
505  errorMessage << " SafePointer created in : "
506  << l->front()->debugString();
507 #endif
508 
509  throw UnresolvedReference(
510  __FILE__, __LINE__, __func__, errorMessage.str());
511  }
512 
513  // try to get the pointer to the section to request chunk from
514  SafePointerList* pointersToSection =
515  (*sectionMap_)[SectionKey(key.sectionId())];
516 
517  assert(pointersToSection != NULL);
518 
519  Section* theSection =
520  dynamic_cast<Section*>(pointersToSection->reference());
521 
522  if (theSection == NULL) {
523  std::stringstream errorMessage;
524  errorMessage << "Can't get section of reference pointed "
525  << "by SectionOffsetKey.";
526 
527 #ifndef NDEBUG
528  errorMessage << " SafePointer created in : "
529  << l->front()->debugString();
530 #endif
531 
532  throw UnresolvedReference(
533  __FILE__, __LINE__, __func__, errorMessage.str());
534  }
535 
536  SafePointable* chunk = NULL;
537  try {
538  chunk =
539  static_cast<SafePointable*>(theSection->chunk(key.offset()));
540 
541  } catch (const NotChunkable& e) {
542  // Probably there is some section that should be referred by
543  // section offsets but, while reading that section all necessary
544  // keys has not been stored.
545  std::stringstream errorMessage;
546  errorMessage << "Can't resolve section offset, because there"
547  << " no object stored stored for key sectionId: "
548  << key.sectionId() << " offset: " << key.offset();
549 #ifndef NDEBUG
550  errorMessage << " SafePointer created in : "
551  << l->front()->debugString();
552 #endif
553  throw UnresolvedReference(__FILE__,
554  __LINE__,
555  "SafePointer::resolve()",
556  errorMessage.str());
557  }
558 
559  assert(chunk != NULL);
560  addObjectReference(key, chunk);
561  }
562 
563  // check if key maps still contain unresolved references and
564  // give propriate error messages.
565  std::stringstream errorMessage;
566  const ReferenceKey *unresolvedKey = NULL;
567  SafePointer *firstUnresolvedPointerOfList = NULL;
568 
569  if (unresolvedReferences(*sectionMap_, &unresolvedKey)) {
570  const SectionKey *sectionKey =
571  dynamic_cast<const SectionKey*>(unresolvedKey);
572 
573  errorMessage << "with section keys. Requested identification code: "
574  << sectionKey->sectionId() << std::endl;
575 
576  // get first of unresolved pointers in safe pointer list
577  firstUnresolvedPointerOfList =
578  (*sectionMap_->find(*sectionKey)).second->front();
579  }
580 
581  if (unresolvedReferences(*sectionIndexMap_, &unresolvedKey)) {
582  const SectionIndexKey *indexKey =
583  dynamic_cast<const SectionIndexKey*>(unresolvedKey);
584 
585  errorMessage << "Problem with section index keys. "
586  << "Requested section identification code: "
587  << static_cast<int>(indexKey->sectionId())
588  << " index: "
589  << indexKey->index() << std::endl;
590 
591  firstUnresolvedPointerOfList =
592  (*sectionIndexMap_->find(*indexKey)).second->front();
593  }
594 
595  if (unresolvedReferences(*sectionOffsetMap_, &unresolvedKey)) {
596 
597  const SectionOffsetKey *sectionOffsetKey =
598  dynamic_cast<const SectionOffsetKey*>(unresolvedKey);
599 
600  errorMessage << "Problem with section offset keys. "
601  << "Requested section identification code: "
602  << static_cast<int>(sectionOffsetKey->sectionId())
603  << " offset: "
604  << sectionOffsetKey->offset() << std::endl;
605 
606  firstUnresolvedPointerOfList =
607  (*sectionOffsetMap_->find(*sectionOffsetKey)).second->front();
608  }
609 
610  if (unresolvedReferences(*fileOffsetMap_, &unresolvedKey)) {
611  const FileOffsetKey *fileOffsetKey =
612  dynamic_cast<const FileOffsetKey*>(unresolvedKey);
613 
614  errorMessage << "Problem with file offset keys. "
615  << "Requested section identification code: "
616  << fileOffsetKey->fileOffset() << std::endl;
617 
618  firstUnresolvedPointerOfList =
619  (*fileOffsetMap_->find(*fileOffsetKey)).second->front();
620  }
621 
622  if (errorMessage.str() != "") {
623 
624 #ifndef NDEBUG
625  assert(firstUnresolvedPointerOfList != NULL);
626  errorMessage << " SafePointer created in : "
627  << firstUnresolvedPointerOfList->debugString();
628 #endif
629  throw UnresolvedReference(
630  __FILE__, __LINE__, __func__, errorMessage.str());
631  }
632 }

References __func__, addObjectReference(), assert, TPEF::Section::chunk(), MapTools::containsKey(), TPEF::ReferenceManager::FileOffsetKey::fileOffset(), fileOffsetMap_, TPEF::ReferenceManager::SafePointerList::front(), TPEF::ReferenceManager::SectionIndexKey::index(), TPEF::ReferenceManager::SectionOffsetKey::offset(), TPEF::ReferenceManager::SafePointerList::reference(), referenceMap_, TPEF::ReferenceManager::SectionIndexKey::sectionId(), TPEF::ReferenceManager::SectionOffsetKey::sectionId(), TPEF::ReferenceManager::SectionKey::sectionId(), sectionIndexMap_, sectionMap_, sectionOffsetMap_, and unresolvedReferences().

Referenced by TPEF::BinaryReader::readBinary().

Here is the call graph for this function:

◆ safelyCleanupKeyTable()

template<typename MapType >
static void TPEF::ReferenceManager::SafePointer::safelyCleanupKeyTable ( MapType &  sourceMap,
std::set< SafePointerList * > &  listsToDelete 
)
staticprotected

Referenced by cleanupKeyTables().

◆ sectionIndexKeyFor()

SectionIndexKey TPEF::ReferenceManager::SafePointer::sectionIndexKeyFor ( const SafePointable obj)
static

Returns the SectionIndexKey connected to given object.

Returns
The key.
Parameters
objObject to look the key for.
Exceptions
KeyNotFoundIf the key cannot be found for the object.

Definition at line 366 of file SafePointer.cc.

366  {
367  return genericKeyFor<SectionIndexKey>(obj, *sectionIndexMap_);
368 }

References sectionIndexMap_.

Referenced by TPEF::SectionIndexReplacer::tryToReplace().

◆ sectionKeyFor()

SectionKey TPEF::ReferenceManager::SafePointer::sectionKeyFor ( const SafePointable obj)
static

Returns the SectionKey connected to given object.

Returns
The key.
Parameters
objObject to look the key for.
Exceptions
KeyNotFoundIf the key cannot be found for the object.

Definition at line 408 of file SafePointer.cc.

408  {
409  return genericKeyFor<SectionKey>(obj, *sectionMap_);
410 }

References sectionMap_.

Referenced by TPEF::TPEFStringSectionWriter::actualWriteData(), TPEF::TPEFASpaceSectionWriter::actualWriteData(), TPEF::TPEFDataSectionWriter::actualWriteData(), TPEF::TPEFCodeSectionWriter::actualWriteData(), TPEF::TPEFSymbolSectionWriter::actualWriteData(), TPEF::TPEFUDataSectionWriter::createKeys(), TPEF::TPEFRelocSectionReader::finalize(), and TPEF::SectionIdReplacer::tryToReplace().

◆ sectionOffsetKeyFor()

SectionOffsetKey TPEF::ReferenceManager::SafePointer::sectionOffsetKeyFor ( const SafePointable obj)
static

Returns the SectionOffsetKey connected to given object.

Returns
The key.
Parameters
objObject to look the key for.
Exceptions
KeyNotFoundIf the key cannot be found for the object.

Definition at line 380 of file SafePointer.cc.

380  {
381  return genericKeyFor<SectionOffsetKey>(obj, *sectionOffsetMap_);
382 }

References sectionOffsetMap_.

Referenced by TPEF::SectionOffsetReplacer::tryToReplace().

◆ setPointer()

void TPEF::ReferenceManager::SafePointer::setPointer ( SafePointable object)

◆ unresolvedReferences()

template<typename MapType >
static bool TPEF::ReferenceManager::SafePointer::unresolvedReferences ( const MapType &  mapToCheck,
const ReferenceKey **  unresolvedKey 
)
static

Referenced by resolve().

Member Data Documentation

◆ aliveSafePointers_

SafePointerSet * TPEF::ReferenceManager::SafePointer::aliveSafePointers_ = new SafePointerSet
staticprivate

Set that cointains all alive (not deleted) SafePointers for extra safety.

Definition at line 332 of file SafePointer.hh.

Referenced by isAlive().

◆ debugString_

std::string TPEF::ReferenceManager::SafePointer::debugString_
private

Definition at line 352 of file SafePointer.hh.

◆ fileOffsetMap_

FileOffsetMap * TPEF::ReferenceManager::SafePointer::fileOffsetMap_ = new FileOffsetMap
staticprivate

Map of SafePointers that are requested using FileOffsetKeys.

Definition at line 322 of file SafePointer.hh.

Referenced by addObjectReference(), cleanupKeyTables(), fileOffsetKeyFor(), notifyDeleted(), resolve(), and SafePointer().

◆ keyForCache_

SafePointer::KeyForCacheMap * TPEF::ReferenceManager::SafePointer::keyForCache_
staticprivate
Initial value:

Map for cache.

Definition at line 343 of file SafePointer.hh.

Referenced by cleanupKeyTables().

◆ null

const SafePointer TPEF::ReferenceManager::SafePointer::null
static

◆ object_

SafePointable* TPEF::ReferenceManager::SafePointer::object_
private

The reference to the real object.

Definition at line 313 of file SafePointer.hh.

◆ referenceMap_

ReferenceMap * TPEF::ReferenceManager::SafePointer::referenceMap_ = new ReferenceMap
staticprivate

Map of SafePointers that have resolved references.

Definition at line 328 of file SafePointer.hh.

Referenced by cleanup(), isReferenced(), notifyDeleted(), resolve(), and SafePointer().

◆ sectionIndexMap_

SectionIndexMap * TPEF::ReferenceManager::SafePointer::sectionIndexMap_ = new SectionIndexMap
staticprivate

Map of SafePointers that are requested using SectionIndexKeys.

Definition at line 316 of file SafePointer.hh.

Referenced by addObjectReference(), cleanupKeyTables(), notifyDeleted(), resolve(), SafePointer(), and sectionIndexKeyFor().

◆ sectionMap_

SectionMap * TPEF::ReferenceManager::SafePointer::sectionMap_ = new SectionMap
staticprivate

Map of SafePointers that are requested using SectionKeys.

Definition at line 325 of file SafePointer.hh.

Referenced by addObjectReference(), cleanupKeyTables(), notifyDeleted(), resolve(), SafePointer(), and sectionKeyFor().

◆ sectionOffsetMap_

SectionOffsetMap * TPEF::ReferenceManager::SafePointer::sectionOffsetMap_ = new SectionOffsetMap
staticprivate

Map of SafePointers that are requested using SectionOffsetKeys.

Definition at line 319 of file SafePointer.hh.

Referenced by addObjectReference(), cleanupKeyTables(), notifyDeleted(), resolve(), SafePointer(), and sectionOffsetKeyFor().


The documentation for this class was generated from the following files:
UnresolvedReference
Definition: Exception.hh:370
TPEF::ReferenceManager::SafePointer::genericRegisterPointer
void genericRegisterPointer(const KeyType &key, MapType &destinationMap, SafePointer *newSafePointer)
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
MapTools::deleteAllValues
static void deleteAllValues(MapType &aMap)
TPEF::ReferenceManager::SafePointer::sectionOffsetMap_
static SectionOffsetMap * sectionOffsetMap_
Map of SafePointers that are requested using SectionOffsetKeys.
Definition: SafePointer.hh:319
TPEF::ReferenceManager::SafePointer::genericAddObjectReference
static void genericAddObjectReference(const KeyType &key, MapType &destinationMap, const SafePointable *obj)
TPEF::ReferenceManager::SafePointer::addObjectReference
static void addObjectReference(SectionIndexKey key, const SafePointable *obj)
Definition: SafePointer.cc:306
TPEF::ReferenceManager::SafePointer::keyForCache_
static KeyForCacheMap * keyForCache_
Map for cache.
Definition: SafePointer.hh:343
TPEF::ReferenceManager::SafePointer::notifyDeleted
static void notifyDeleted(const SafePointable *obj)
Definition: SafePointer.cc:421
TPEF::ReferenceManager::SafePointer::sectionMap_
static SectionMap * sectionMap_
Map of SafePointers that are requested using SectionKeys.
Definition: SafePointer.hh:325
TPEF::ReferenceManager::SafePointer::fileOffsetMap_
static FileOffsetMap * fileOffsetMap_
Map of SafePointers that are requested using FileOffsetKeys.
Definition: SafePointer.hh:322
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::ReferenceManager::SafePointer::cleanupKeyTables
static void cleanupKeyTables()
Definition: SafePointer.cc:644
TPEF::ReferenceManager::SafePointer::referenceMap_
static ReferenceMap * referenceMap_
Map of SafePointers that have resolved references.
Definition: SafePointer.hh:328
AssocTools::deleteAllItems
static void deleteAllItems(ContainerType &aMap)
__func__
#define __func__
Definition: Application.hh:67
TPEF::ReferenceManager::SafePointer::aliveSafePointers_
static SafePointerSet * aliveSafePointers_
Set that cointains all alive (not deleted) SafePointers for extra safety.
Definition: SafePointer.hh:332
TPEF::ReferenceManager::SafePointer::sectionIndexMap_
static SectionIndexMap * sectionIndexMap_
Map of SafePointers that are requested using SectionIndexKeys.
Definition: SafePointer.hh:316
TPEF::ReferenceManager::SafePointer::KeyForCacheMap
std::map< KeyForCacheKey, const ReferenceKey * > KeyForCacheMap
Definition: SafePointer.hh:340
TPEF::ReferenceManager::SafePointer::SafePointer
SafePointer(SectionIndexKey key)
Definition: SafePointer.cc:199
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
TPEF::ReferenceManager::SafePointer::safelyCleanupKeyTable
static void safelyCleanupKeyTable(MapType &sourceMap, std::set< SafePointerList * > &listsToDelete)
MapTools::containsValue
static bool containsValue(const MapType &aMap, const ValueType &aValue)
TPEF::ReferenceManager::SafePointer::unresolvedReferences
static bool unresolvedReferences(const MapType &mapToCheck, const ReferenceKey **unresolvedKey)
NotChunkable
Definition: Exception.hh:353
TPEF::ReferenceManager::SafePointer::object_
SafePointable * object_
The reference to the real object.
Definition: SafePointer.hh:313