EDoc::DictionarySpecific Class Reference

#include <include/EDoc/DictionarySpecific.h>

Inheritance diagram for EDoc::DictionarySpecific:

EDoc::CatchBlock EDoc::CodeBlock EDoc::Exception EDoc::FunctionLoc EDoc::FunctionTypeLoc EDoc::Location EDoc::ManagedObject EDoc::PropogatingException EDoc::StringIdentifiedObject EDoc::TryBlock EDoc::TypeLoc

Detailed Description

Encapsulates functionality common to all dictionary specific types.

A dictionary specific type is a type/class which "belongs" to a particular instance of the Dictionary class. Objects that belong to one dictionary can NOT be referenced by object from another dictionary. They need to be specially copied/merged. For this reason there is special processing that occurs for assignment and copies of dictionary specific objects to ensure that these rules are not violated.

HISTORY

This was done because the other option was to use identifiers and lookups or copies of all the data. Initially this was attempted but processing time and memory usage were enormous, so the method was changed in order to store pointers directly to members. However objects can only store pointers to other members that belong to the same Dictionary instance. This means that when a dictionary object is destroyed along with all objects that "belong" to it, no other objects are invalidated.

As a result this class was created in order to simplify management of these objects.

All DictionarySpecific objects have functionality to replace pointer references and to validate themselves.

See also:
See Dictionary.

Definition at line 64 of file DictionarySpecific.h.

Public Member Functions

 DictionarySpecific (Dictionary *dict_in)
 Create this dictionary specific object belonging to the given dictionary.
virtual ~DictionarySpecific ()
 Destructor.
virtual size_t ReplaceReferences (PStack &stack, void *remove, void *replace)=0
 Replaces all references of pointers referencing remove with pointers to replace.
virtual std::ostream & Print (std::ostream &out, std::string prefix="") const =0
 Print the current object to the given stream in a user readable manner.
std::string ToString (std::string prefix="") const
 Returns a string representing the current object in a user readable manner.
virtual void Validate (PStack &stack, const Dictionary &dict_in) const =0
 Performs internal valtidation on the current object and will throw a BugException if the validation fails.

Protected Attributes

Dictionarydict
 A reference to the dictionary this object belongs to.

Private Member Functions

 DictionarySpecific (const DictionarySpecific &right)
 COPY DISALLOWED.
DictionarySpecificoperator= (const DictionarySpecific &right)
 ASSIGNMENT DISALLOWED.

Friends

class ManagedObject


Constructor & Destructor Documentation

EDoc::DictionarySpecific::DictionarySpecific ( Dictionary dict_in  ) 

Create this dictionary specific object belonging to the given dictionary.

Parameters:
dict_in The dictionary that this object will belong to if NULL then will use the dictionary that can be obtained by: GetCurrentDictionaryAssert()

Definition at line 29 of file DictionarySpecific.cpp.

EDoc::DictionarySpecific::~DictionarySpecific (  )  [inline, virtual]

Destructor.

Note:
EDoc++ data included.

Definition at line 82 of file DictionarySpecific.h.

EDoc::DictionarySpecific::DictionarySpecific ( const DictionarySpecific right  )  [private]

COPY DISALLOWED.


Member Function Documentation

EDoc::DictionarySpecific::ReplaceReferences ( PStack stack,
void *  remove,
void *  replace 
) [pure virtual]

Replaces all references of pointers referencing remove with pointers to replace.

The replacement is used because when after Read()'ing it is possible to have two instances of an object indexed by the same key. The contents of them must be merged and all references to one object be changed to reference the other. Then the now unreferenced object would be deleted. This is a part of the loading phase and is a result of the fact that GCC can generate multiple tree nodes for a single type. Thus when loading we often get the same type multiple times.

Todo:
As an option in the future we may choose to allow replace to be a NULL pointer. In which case it will completely erase references to a particular object instead of having to replace them with something else. This works for containers, but for non-optional fixed pointers it may cause some problems. Maybe in these cases, we should throw an exception that indicates to the user that they cant just erase that reference, they must at least replace it in some places with something or first erase other nodes that reference it first. This exception would need to include as its data a reference to the object that cant release its reference to "remove".

Implemented in EDoc::CatchBlock, EDoc::CodeBlock, EDoc::Exception, EDoc::File, EDoc::Function, EDoc::FunctionLoc, EDoc::FunctionType, EDoc::FunctionTypeLoc, EDoc::Location, EDoc::ManagedObject, EDoc::PropogatingException, EDoc::TryBlock, EDoc::Type, and EDoc::TypeLoc.

EDoc::DictionarySpecific::Print ( std::ostream &  out,
std::string  prefix = "" 
) const [pure virtual]

Print the current object to the given stream in a user readable manner.

Parameters:
out The stream to print to.
prefix A string prefix to display at the start of every line. As an example this can be used in order to indent the print by passing "\t" as the string.

Implemented in EDoc::CatchBlock, EDoc::CodeBlock, EDoc::Exception, EDoc::File, EDoc::Function, EDoc::FunctionLoc, EDoc::FunctionType, EDoc::FunctionTypeLoc, EDoc::Location, EDoc::ManagedObject, EDoc::PropogatingException, EDoc::TryBlock, EDoc::Type, and EDoc::TypeLoc.

Referenced by std::operator<<(), and ToString().

EDoc::DictionarySpecific::ToString ( std::string  prefix = ""  )  const

Returns a string representing the current object in a user readable manner.

This will return as a string exactly what Print() would display. This is primarily here for use from within python and for debugging.

Definition at line 34 of file DictionarySpecific.cpp.

References Print().

Referenced by EDoc::Dictionary::Read().

EDoc::DictionarySpecific::Validate ( PStack stack,
const Dictionary dict_in 
) const [pure virtual]

Performs internal valtidation on the current object and will throw a BugException if the validation fails.

This is primarily used to ensure that all DictionarySpecific objects are internally consistent, not referencing dictionaries that they actually do not belong to. It is also used for a few other validations too that if they fail would indicate a bug in the code somewhere.

Implemented in EDoc::CatchBlock, EDoc::CodeBlock, EDoc::Exception, EDoc::File, EDoc::Function, EDoc::FunctionLoc, EDoc::FunctionType, EDoc::FunctionTypeLoc, EDoc::Location, EDoc::ManagedObject, EDoc::PropogatingException, EDoc::TryBlock, EDoc::Type, and EDoc::TypeLoc.

EDoc::DictionarySpecific::operator= ( const DictionarySpecific right  )  [private]

ASSIGNMENT DISALLOWED.


Friends And Related Function Documentation

friend class ManagedObject [friend]

Definition at line 66 of file DictionarySpecific.h.


Field Documentation

Dictionary& EDoc::DictionarySpecific::dict [protected]

A reference to the dictionary this object belongs to.

Definition at line 150 of file DictionarySpecific.h.

Referenced by EDoc::ManagedObject::CAlwaysGet(), EDoc::CatchBlock::CatchBlock(), EDoc::Exception::Exception(), EDoc::Function::ExpandCallGraph(), EDoc::CodeBlock::ExpandCallGraph(), EDoc::FunctionLoc::FunctionLoc(), EDoc::FunctionTypeLoc::FunctionTypeLoc(), EDoc::Function::GetSubstException(), EDoc::Location::Location(), EDoc::ManagedObject::ManagedObject(), EDoc::Type::Merge(), EDoc::Location::Merge(), EDoc::Function::Merge(), EDoc::SpecificManagedObject< EDoc::Type >::New(), EDoc::TypeLoc::operator=(), EDoc::Type::operator=(), EDoc::TryBlock::operator=(), EDoc::PropogatingException::operator=(), EDoc::Location::operator=(), EDoc::FunctionTypeLoc::operator=(), EDoc::FunctionType::operator=(), EDoc::FunctionLoc::operator=(), EDoc::Function::operator=(), EDoc::Exception::operator=(), EDoc::CodeBlock::operator=(), EDoc::PropogatingException::PropogatingException(), EDoc::TryBlock::Read(), EDoc::Function::Read(), EDoc::CodeBlock::Read(), EDoc::TryBlock::TryBlock(), EDoc::TypeLoc::TypeLoc(), EDoc::TypeLoc::Validate(), EDoc::Type::Validate(), EDoc::TryBlock::Validate(), EDoc::PropogatingException::Validate(), EDoc::ManagedObject::Validate(), EDoc::Location::Validate(), EDoc::FunctionTypeLoc::Validate(), EDoc::FunctionType::Validate(), EDoc::FunctionLoc::Validate(), EDoc::Function::Validate(), EDoc::File::Validate(), EDoc::Exception::Validate(), EDoc::CodeBlock::Validate(), EDoc::CatchBlock::Validate(), EDoc::Type::Write(), and EDoc::Function::Write().


The documentation for this class was generated from the following files:
Generated on Tue Jan 20 18:26:08 2009 for EDoc-0.2.1 by  doxygen 1.5.1