36#ifndef TTA_SAFEPOINTER_HH
37#define TTA_SAFEPOINTER_HH
60namespace ReferenceManager {
136 return reinterpret_cast<size_t>(key);
218 template <
typename MapType>
232#ifndef DOXYGEN_SHOULD_SKIP_THIS
243#define CREATE_SAFEPOINTER(x) \
244 ReferenceManager::SafePointer::debugCreate( x , __FILE__, __LINE__)
261 void setDebugString(std::string aStr);
262 std::string debugString()
const;
264 template <
typename ObjType>
265 static SafePointer* debugCreate(ObjType obj,
const char *file,
int line);
276#define CREATE_SAFEPOINTER(x) \
277 ReferenceManager::SafePointer::genericCreate(x)
280 template <
typename ObjType>
291 template <
typename KeyType,
typename MapType>
294 MapType& destinationMap,
297 template <
typename KeyType,
typename MapType>
299 const KeyType& key, MapType& destinationMap,
const SafePointable* obj);
301 template <
typename KeyType,
typename MapType>
304 template <
typename MapType>
307 std::set<SafePointerList*>&
FileOffset fileOffset() const
size_t operator()(const SectionIndexKey &key) const
size_t operator()(const FileOffsetKey &key) const
size_t operator()(const SectionOffsetKey &key) const
size_t operator()(const SafePointable *const &key) const
size_t operator()(const SectionKey &key) const
std::list< SafePointer * > SafePointerListType
Type of the container to hold the SafePointers in.
std::string::size_type LengthType
Type of the list length value.
void append(SafePointer *newSafePointer)
SafePointer * front() const
virtual ~SafePointerList()
SafePointable * reference_
Object that SafePointers in this list are pointing to.
void setReference(const SafePointable *obj)
LengthType length() const
SafePointerListType list_
Container for SafePointers.
SafePointable * reference() const
SafePointer & operator=(SafePointer &)
Assignment not allowed.
static void safelyCleanupKeyTable(MapType &sourceMap, std::set< SafePointerList * > &listsToDelete)
SafePointable * pointer() const
SafePointable * object_
The reference to the real object.
void genericRegisterPointer(const KeyType &key, MapType &destinationMap, SafePointer *newSafePointer)
static bool isAlive(SafePointer *pointerToCheck)
static void addObjectReference(SectionIndexKey key, const SafePointable *obj)
static SectionOffsetMap * sectionOffsetMap_
Map of SafePointers that are requested using SectionOffsetKeys.
static const SafePointer * replaceReference(const SafePointer *old, SafePointable *obj)
static const SafePointer null
The default SafePointer that is used in null references.
static FileOffsetMap * fileOffsetMap_
Map of SafePointers that are requested using FileOffsetKeys.
static FileOffsetKey fileOffsetKeyFor(const SafePointable *obj)
static KeyType genericKeyFor(const SafePointable *obj, MapType &sourceMap)
static SectionOffsetKey sectionOffsetKeyFor(const SafePointable *obj)
void setPointer(SafePointable *object)
static void cleanupKeyTables()
static void notifyDeleted(const SafePointable *obj)
static bool unresolvedReferences(const MapType &mapToCheck, const ReferenceKey **unresolvedKey)
static SafePointerSet * aliveSafePointers_
Set that cointains all alive (not deleted) SafePointers for extra safety.
static SectionIndexKey sectionIndexKeyFor(const SafePointable *obj)
static SectionKey sectionKeyFor(const SafePointable *obj)
std::pair< const SafePointable *, void * > KeyForCacheKey
Key type for cache, void* is pointer to key map (sectioMap_, sectionOffsetMap, ......
static void genericAddObjectReference(const KeyType &key, MapType &destinationMap, const SafePointable *obj)
static SectionMap * sectionMap_
Map of SafePointers that are requested using SectionKeys.
static ReferenceMap * referenceMap_
Map of SafePointers that have resolved references.
static SectionIndexMap * sectionIndexMap_
Map of SafePointers that are requested using SectionIndexKeys.
SafePointer(SafePointer &)
Copying not allowed.
std::map< KeyForCacheKey, const ReferenceKey * > KeyForCacheMap
static void replaceAllReferences(SafePointable *newObj, SafePointable *oldObj)
static bool isReferenced(const SafePointable *object)
static SafePointer * genericCreate(ObjType obj)
static KeyForCacheMap * keyForCache_
Map for cache.
SectionIndex index() const
SectionId sectionId() const
SectionId sectionId() const
SectionOffset offset() const
SectionId sectionId() const
std::map< SectionKey, SafePointerList * > SectionMap
Map for SafePointers that are requested using SectionKeys.
std::map< SectionIndexKey, SafePointerList * > SectionIndexMap
Map for SafePointers that are requested using SectionIndexKeys.
std::map< SectionOffsetKey, SafePointerList * > SectionOffsetMap
Map for 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.
std::map< FileOffsetKey, SafePointerList * > FileOffsetMap
Map for SafePointers that are requested using FileOffsetKeys.
std::set< SafePointer * > SafePointerSet
Unordered set of SafePointers.
HalfWord SectionId
Type for storing binary file section ids.