Classes. More...

#include <gclasses.h>

Inheritance diagram for GClasses:
[legend]

Public Member Functions

 GClasses (GSession *session, size_t max)
 
GClassesGetClassTree (void)
 
GClassGetFirst (void) const
 
GClassGetLast (void) const
 
size_t GetMaxDepth (void) const
 
size_t GetNbNodes (void) const
 
size_t GetNbTopNodes (void) const
 
size_t GetTab (GClass **tab, GClass *node, bool children=false)
 
size_t GetNbObjs (const GClass *obj) const
 
size_t GetMaxObjId (const GClass *obj) const
 
size_t GetMaxObjPos (const GClass *obj) const
 
R::RCursor< GClassGetObjs (const GClass *obj) const
 
size_t GetObjs (GClass **&tab, bool alloc)
 
GClassGetObj (const GClass *obj, size_t id, bool load=true, bool null=false)
 
GClassGetObj (const GClass *obj, const R::RString &name, bool load=true, bool null=false)
 
void LoadIndex (const GClass *obj, GConcept *concept, R::RNumContainer< size_t, true > &refs)
 
void BuildIndex (const GClass *obj)
 
virtual void InsertObj (GClass *parent, GClass *obj)
 
virtual void DeleteObj (GClass *obj)
 
double GetUpOperationsCost (const GClass *u, const GClass *v) const
 

Private Member Functions

void Init (R::RConfig *config)
 
void OpenFiles (R::RConfig *config, R::RString subdir)
 
bool DoCreateIndex (const GClass *obj) const
 
bool DoCreateTree (const GClass *obj) const
 
void AssignId (GClass *obj)
 
void LoadObjs (const GClass *obj)
 
void LoadDesc (const GClass *obj, R::RContainer< GVector, true, true > *&vectors, size_t blockid, size_t id)
 
void SaveDesc (const GClass *obj, const R::RContainer< GVector, true, true > &vectors, size_t &blockid, size_t id)
 
void FlushDesc (const GClass *obj)
 
void UpdateIndex (const GClass *obj, const GDescription &desc, size_t id, bool add)
 
virtual void Clear (void)
 
virtual void Clear (const GClass *obj, bool del)
 
- Private Member Functions inherited from RTree< GClasses, GClass, false >
 RTree (void)
 
void ClearNode (GClass *node)
 
GClass * GetFirst (void) const
 
GClass * GetLast (void) const
 
size_t GetMaxDepth (void) const
 
GClass * GetTop (void)
 
const GClass * GetTop (void) const
 
size_t GetNbNodes (void) const
 
size_t GetNbTopNodes (void) const
 
size_t GetTab (GClass **tab, GClass *node, bool children=false)
 
void InsertNode (GClass *to, GClass *node)
 
void DeleteNodes (GClass *node, bool del=false)
 
void DeleteNode (GClass *node, bool del=false)
 
void UpdateDepth (GClass *node)
 
void MoveNode (GClass *to, GClass *node)
 
void Copy (const RTree< GClasses, GClass, a > &src)
 
void DeepCopy (GClass *src, GClass *newparent)
 
GClass * GetNode (const TUse &tag) const
 
double GetUpOperationsCost (const GClass *u, const GClass *v) const
 
virtual ~RTree (void)
 
- Private Member Functions inherited from GObjects< GClass, hClasses >
 GObjects (GSession *session, size_t size, const R::RString &name, tObjType type)
 
size_t GetNbObjs (const GClass *obj) const
 
size_t GetMaxObjId (const GClass *obj) const
 
size_t GetMaxObjPos (const GClass *obj) const
 
R::RCursor< GClassGetObjs (const GClass *obj) const
 
size_t GetObjs (GClass **&tab, bool alloc)
 
GClassGetObj (const GClass *obj, size_t id, bool load=true, bool null=false)
 
GClassGetObj (const GClass *obj, const R::RString &name, bool load=true, bool null=false)
 
void LoadIndex (const GClass *obj, GConcept *concept, R::RNumContainer< size_t, true > &refs)
 
void BuildIndex (const GClass *obj)
 
void LoadTree (const GClass *obj, GConceptTree *&tree, size_t blockid, size_t id)
 
void LoadTree (const GClass *obj, R::RContainer< GConceptRecord, false, true > &records, size_t &nbrecords, size_t &nbtoprecords, size_t &nbrefs)
 
bool FindDepthFirstRecord (const GClass *obj, GConceptRecord &rec, size_t idx)
 
bool FindRecord (const GClass *obj, GConceptRecord &rec, size_t synpos)
 
bool FindParentRecord (const GClass *obj, const GConceptRecord &search, GConceptRecord &rec)
 
bool FindFirstChildRecord (const GClass *obj, const GConceptRecord &search, GConceptRecord &rec, size_t idx)
 
bool FindNearestRecord (const GClass *obj, GConceptRecord &rec, size_t synpos)
 
bool FindNearestRecord (const GClass *obj, GConceptRecord &rec, size_t synpos, bool after)
 
bool FindRootRecord (const GClass *obj, const GConceptRecord &rec1, const GConceptRecord &rec2, GConceptRecord &rec)
 
size_t GetMinPosRecord (const GClass *obj, const GConceptRecord &rec, size_t nbbefore)
 
size_t GetMaxPosRecord (const GClass *obj, const GConceptRecord &rec, size_t nbafter)
 
size_t GetMaxPosRecord (const GClass *obj)
 
size_t GetMaxSyntacticPosRecord (const GClass *obj)
 
size_t GetNbTotalChildRecords (const GClass *obj, const GConceptRecord &rec)
 
virtual ~GObjects (void)
 

Additional Inherited Members

- Private Attributes inherited from RTree< GClasses, GClass, false >
GClass * First
 
GClass * Last
 
size_t NbTopNodes
 
size_t NbNodes
 
size_t MaxDepth
 

Detailed Description

Classes.

The GClasses provides just a tree of GClass.

Constructor & Destructor Documentation

GClasses ( GSession session,
size_t  max 
)

Construct a tree of classes.

Parameters
sessionSession.
maxInitial size of the container.

Member Function Documentation

GClasses* GetClassTree ( void  )
Returns
Pointer to the class.
GClass* GetFirst ( void  ) const
Returns
the first root class. If null, the tree is empty.
GClass* GetLast ( void  ) const
Returns
the last root class. If null, the tree is empty.
size_t GetMaxDepth ( void  ) const
Returns
the depth of the tree. If necessary, the depth is recomputed.
size_t GetNbNodes ( void  ) const
Returns
the total number of classes in the tree.
size_t GetNbTopNodes ( void  ) const
Returns
the total number of top classes in the tree.
size_t GetTab ( GClass **  tab,
GClass node,
bool  children = false 
)

Copy the classes of a class into a temporary array. This array must have the right size.

Parameters
tabTemporary array.
nodeParent class. If null, the array contains the top classes.
childrenMust the children be copied too.
Returns
Number of the nodes copied in the array
size_t GetNbObjs ( const GClass obj) const

Get the number of classes.

Parameters
objPseudo-parameter.
size_t GetMaxObjId ( const GClass obj) const

Get the highest identifier of the classes.

Parameters
objPseudo-parameter.
size_t GetMaxObjPos ( const GClass obj) const

Get the highest position occupied by a clas.

Parameters
objPseudo-parameter.
R::RCursor<GClass> GetObjs ( const GClass obj) const

Get a cursor to the classes.

Parameters
objPseudo-parameter.
size_t GetObjs ( GClass **&  tab,
bool  alloc 
)

Fill an array of classes.

Parameters
tabArray that will be filled.
allocMust the array be allocated ?
Returns
number of objects in the array (including null pointers).
GClass* GetObj ( const GClass obj,
size_t  id,
bool  load = true,
bool  null = false 
)

Get an class based on its identifier.

Parameters
objPseudo-parameter.
idIdentifier of the class.
loadIf set to true, the class is eventually loaded into memory.
nullIf set to true, if the class does not exist, return 0, else an exception is generated.
Returns
a pointer to a class.
GClass* GetObj ( const GClass obj,
const R::RString name,
bool  load = true,
bool  null = false 
)

Get an class based on its name.

Parameters
objPseudo-parameter.
nameName of the class.
loadIf set to true, the class is eventually loaded into memory.
nullIf set to true, if the class does not exist, return 0, else an exception is generated.
Returns
a pointer to a class.
void LoadIndex ( const GClass obj,
GConcept concept,
R::RNumContainer< size_t, true > &  refs 
)

Load the identifiers of all classes described by a specific concept.

Parameters
objPseudo-parameter.
conceptConcept to search for.
refsIdentifiers of the classes.
void BuildIndex ( const GClass obj)

Build the index of all the classes from scratch. Since only the class descriptions are used, no occurrence information is* available.

Parameters
objPseudo-parameter.
virtual void InsertObj ( GClass parent,
GClass obj 
)
virtual

Insert a class.

Parameters
parentParent class.
objobject to insert.

Reimplemented from GObjects< GClass, hClasses >.

virtual void DeleteObj ( GClass obj)
virtual

Delete an object.

Parameters
objobject to delete.

Reimplemented from GObjects< GClass, hClasses >.

void Init ( R::RConfig config)
private

Initialize the parameters.

Parameters
configConfiguration structure.
void OpenFiles ( R::RConfig config,
R::RString  subdir 
)
private

Open the files in a given directory.

Parameters
configConfiguration structure.
subdirSub-directory where the files will be stored.
bool DoCreateIndex ( const GClass obj) const
private
Returns
if an index is create.
Parameters
objPseudo-parameter.
bool DoCreateTree ( const GClass obj) const
private
Returns
if the concept trees are created.
Parameters
objPseudo-parameter.
void AssignId ( GClass obj)
private

Assign an identifier to an class.

Parameters
objClass.
void LoadObjs ( const GClass obj)
private

Load all the classes.

Parameters
objPseudo-parameter.
void LoadDesc ( const GClass obj,
R::RContainer< GVector, true, true > *&  vectors,
size_t  blockid,
size_t  id 
)
private

Load the description of a given class.

Parameters
objPseudo-parameter.
vectorsVectors.
blockidIdentifier of the block of the class.
idIdentifier of the class.
void SaveDesc ( const GClass obj,
const R::RContainer< GVector, true, true > &  vectors,
size_t &  blockid,
size_t  id 
)
private

Save the description of a given class.

Parameters
objPseudo-parameter.
vectorsVectors.
blockidIdentifier of the block of the class (0 means the block will be found).
idIdentifier of the class.
void FlushDesc ( const GClass obj)
private

Flush the descriptions of the classes.

Parameters
objPseudo-parameter.
void UpdateIndex ( const GClass obj,
const GDescription desc,
size_t  id,
bool  add 
)
private

Update the index of a given class that is only described by a description.

Parameters
objPseudo-parameter.
descDescription.
idIdentifier of the class.
addClass must be added or removed from the index.
virtual void Clear ( void  )
privatevirtual

Clear the classes.

Reimplemented from RTree< GClasses, GClass, false >.

virtual void Clear ( const GClass obj,
bool  del 
)
privatevirtual

Clear the classes.

Parameters
objpseudo-parameter.

Reimplemented from GObjects< GClass, hClasses >.

double GetUpOperationsCost ( const GClass u,
const GClass v 
) const

Get the cost of the Up operations to move a token from a node to another one.

In their paper TreeRank: A Similarity Measure for Nearest Neighbor Searching in Phylogenetic Databases, Wang, Shan, Shasha and Piel define a similarity measure between two trees based on the different costs of up operations of the nodes of each tree.

Parameters
uFirst node.
vSecond node.
Returns
Cost of the up operations.