Stored Objects. More...
#include <gobjects.h>
Public Member Functions | |
GObjects (GSession *session, size_t size, const R::RString &name, tObjType type) | |
virtual void | InsertObj (C *obj, C *parent=0) |
virtual void | DeleteObj (C *obj) |
size_t | GetNbObjs (const C *obj) const |
size_t | GetMaxObjId (const C *obj) const |
size_t | GetMaxObjPos (const C *obj) const |
R::RCursor< C > | GetObjs (const C *obj) const |
size_t | GetObjs (C **&tab, bool alloc) |
C * | GetObj (const C *obj, size_t id, bool load=true, bool null=false) |
C * | GetObj (const C *obj, const R::RString &name, bool load=true, bool null=false) |
void | LoadIndex (const C *obj, GConcept *concept, R::RNumContainer< size_t, true > &refs) |
void | BuildIndex (const C *obj) |
void | LoadTree (const C *obj, GConceptTree *&tree, size_t blockid, size_t id) |
void | LoadTree (const C *obj, R::RContainer< GConceptRecord, false, true > &records, size_t &nbrecords, size_t &nbtoprecords, size_t &nbrefs) |
bool | FindDepthFirstRecord (const C *obj, GConceptRecord &rec, size_t idx) |
bool | FindRecord (const C *obj, GConceptRecord &rec, size_t synpos) |
bool | FindParentRecord (const C *obj, const GConceptRecord &search, GConceptRecord &rec) |
bool | FindFirstChildRecord (const C *obj, const GConceptRecord &search, GConceptRecord &rec, size_t idx) |
bool | FindNearestRecord (const C *obj, GConceptRecord &rec, size_t synpos) |
bool | FindNearestRecord (const C *obj, GConceptRecord &rec, size_t synpos, bool after) |
bool | FindRootRecord (const C *obj, const GConceptRecord &rec1, const GConceptRecord &rec2, GConceptRecord &rec) |
size_t | GetMinPosRecord (const C *obj, const GConceptRecord &rec, size_t nbbefore) |
size_t | GetMaxPosRecord (const C *obj, const GConceptRecord &rec, size_t nbafter) |
size_t | GetMaxPosRecord (const C *obj) |
size_t | GetMaxSyntacticPosRecord (const C *obj) |
size_t | GetNbTotalChildRecords (const C *obj, const GConceptRecord &rec) |
virtual | ~GObjects (void) |
Private Member Functions | |
void | Init (R::RConfig *config) |
virtual void | Clear (const C *obj, bool del) |
void | OpenFiles (R::RConfig *config, R::RString subdir) |
bool | DoCreateIndex (const C *obj) const |
bool | DoCreateTree (const C *obj) const |
void | AssignId (C *obj) |
void | LoadObjs (const C *obj) |
void | LoadDesc (const C *obj, R::RContainer< GVector, true, true > *&vectors, size_t blockid, size_t id) |
void | SaveDesc (const C *obj, const R::RContainer< GVector, true, true > &vectors, size_t &blockid, size_t id) |
void | FlushDesc (const C *obj) |
void | UpdateIndex (const C *obj, const GDescription &desc, size_t id, bool add) |
void | LoadNode (GConceptTree *tree, GConceptNode *parent) |
void | SaveNode (GConceptRecord *rec) |
void | SaveTree (const C *obj, const R::RContainer< GConceptRecord, false, true > &records, size_t nbrecords, size_t nbtoprecords, size_t nbrefs, size_t &blockid, size_t id) |
void | FlushTree (const C *obj) |
void | SeekRecord (const C *obj, size_t idx) |
Private Member Functions inherited from GKB | |
virtual | ~GKB (void)=0 |
tObjState | GetState (void) const |
GStorage * | GetStorage (void) const |
GConceptType * | GetTokenType (void) const |
GConceptType * | GetDCMIType (void) const |
GConceptType * | GetURIType (void) const |
GConceptType * | GetNamedEntityType (void) const |
GConceptType * | GetTaxonomyType (void) const |
GConcept * | GetContent (void) const |
GConcept * | GetUnknown (void) const |
GConcept * | GetURI (void) const |
GConcept * | GetNamedEntity (void) const |
GConcept * | GetIsA (void) const |
GConcept * | GetSynonym (void) const |
GConcept * | GetPartOf (void) const |
size_t | GetNbObjs (const GConceptType *obj) const |
size_t | GetMaxObjId (const GConceptType *obj) const |
GConceptType * | GetObj (const GConceptType *obj, char id, bool null) |
GConceptType * | GetObj (const GConceptType *obj, const R::RString &name, bool null) |
R::RCursor< GConceptType > | GetObjs (const GConceptType *obj) const |
GConceptType * | InsertObj (const GConceptType *obj, tConceptCat cat, size_t id, const R::RString &name, const R::RString &desc, bool &newone) |
GConceptType * | InsertObj (const GConceptType *obj, tConceptCat cat, size_t id, const R::RString &name, const R::RString &desc) |
GConceptType * | InsertObj (const GConceptType *obj, tConceptCat cat, const R::RString &name, const R::RString &desc, bool &newone) |
GConceptType * | InsertObj (const GConceptType *obj, tConceptCat cat, const R::RString &name, const R::RString &desc) |
size_t | GetNbObjs (const GConcept *obj) const |
size_t | GetMaxObjId (const GConcept *obj) const |
R::RCursor< GConcept > | GetObjs (const GConcept *obj) const |
GConcept * | GetObj (const GConcept *obj, size_t id) |
GConcept * | GetObj (const GConcept *obj, GConceptType *type, const R::RString &concept, bool null=false) |
GConcept * | InsertObj (const GConcept *obj, GConceptType *type, const R::RString &concept, bool &newone) |
GConcept * | InsertObj (const GConcept *obj, GConceptType *type, const R::RString &concept) |
GConcept * | InsertObj (const GConcept &concept, bool &newone) |
GConcept * | InsertObj (const GConcept &concept) |
GConcept * | RenameObj (GConcept *concept, const R::RString &name) |
void | DeleteObj (GConcept *concept) |
GStatement * | GetObj (const GStatement *obj, size_t id, bool null=false) |
GStatement * | GetObj (const GStatement *obj, GObject *subject, GObject *predicate, GObject *value, bool null=false) |
GStatement * | InsertObj (const GStatement *obj, size_t id, GObject *subject, GObject *predicate, GObject *value, double weight, bool &newone) |
GStatement * | InsertObj (const GStatement *obj, size_t id, GObject *subject, GObject *predicate, GObject *value, double weight) |
GKB (GSession *session) | |
void | ClearIndex (tObjType type) |
Private Member Functions inherited from RObjectContainer< C, true > | |
RObjectContainer (size_t first, size_t m, size_t i=0) | |
void | VerifyTab (size_t max) |
void | Clear (size_t m=0, size_t i=0) |
int | Compare (const RObjectContainer< C, true > &) const |
size_t | GetNbObjs (void) const |
size_t | GetMaxObjId (void) const |
size_t | GetMaxObjPos (void) const |
R::RCursor< C > | GetObjs (size_t min=0, size_t max=SIZE_MAX) const |
size_t | GetObjs (C **&tab, bool alloc, size_t min=0, size_t max=0) |
const C * | operator[] (size_t id) const |
C * | operator[] (size_t id) |
C * | GetObj (const TUse &tag, bool sortkey=true) |
bool | InsertObj (C *obj) |
void | DeleteObj (C *obj) |
void | AssignId (C *obj) |
virtual | ~RObjectContainer (void) |
Detailed Description
template<class C, const R::hNotification * hEvents>
class GALILEI::GObjects< C, hEvents >
Stored Objects.
This class represents a set of objects (class C). It aims is to encapsulate all the storage aspects of the management.
- Template Parameters
-
C The class of the objects managed. hEvents Array of notification to post concerning an object.
To manage correctly the objects, the list uses two static member functions of the class representing the elements (class C):
The first one specifies if the corresponding objects have descriptions (such as documents) or not (such as users). The second one specifies if the objects have a structure (documents) or not (all the other objects a priori).
The first parameter of several methods is a pseudo-parameter. It is used to differentiate methods with identical names. Several null pointer constants called pDoc, pProfile,etc. are defined and can be used for this parameter. In practice, these methods are called as followed:
The reason for this trick is that C++ does not managed methods with the same name, the same parameters but different return types.
For the storage of trees (to store the full description if documents), each node is stored as a record (GConceptRecord). The nodes are stored with using a depth-first approach: the first root node is stored, followed by its first child node, followed by its first grandchild nodes, etc.
Constructor & Destructor Documentation
GObjects | ( | GSession * | session, |
size_t | size, | ||
const R::RString & | name, | ||
tObjType | type | ||
) |
Constructor of a set of stored objects.
- Parameters
-
session Session. size Initial size of the list. name Name of the objects. type Type of the objects.
|
virtual |
Destructor.
Member Function Documentation
|
virtual |
|
virtual |
size_t GetNbObjs | ( | const C * | obj | ) | const |
Get the number of objects.
- Parameters
-
obj Pseudo-parameter.
size_t GetMaxObjId | ( | const C * | obj | ) | const |
Get the highest identifier of the objects.
- Parameters
-
obj Pseudo-parameter.
size_t GetMaxObjPos | ( | const C * | obj | ) | const |
Get the highest position occupied by an object.
- Parameters
-
obj Pseudo-parameter.
R::RCursor<C> GetObjs | ( | const C * | obj | ) | const |
Get the objects.
- Parameters
-
obj Pseudo-parameter.
- Returns
- a cursor over the objects.
size_t GetObjs | ( | C **& | tab, |
bool | alloc | ||
) |
Fill an array of objects.
- Parameters
-
tab Array that will be filled. alloc Must the array be allocated ?
- Returns
- number of objects in the array (including null pointers).
C* GetObj | ( | const C * | obj, |
size_t | id, | ||
bool | load = true , |
||
bool | null = false |
||
) |
Get an object based on its identifier.
- Parameters
-
obj Pseudo-parameter. id Identifier of the object. load If set to true, the object is eventually loaded into memory. null If set to true, if the object does not exist, return 0, else an exception is generated.
- Returns
- a pointer to a object.
C* GetObj | ( | const C * | obj, |
const R::RString & | name, | ||
bool | load = true , |
||
bool | null = false |
||
) |
Get an object based on its name.
- Parameters
-
obj Pseudo-parameter. name Name of the object. load If set to true, the object is eventually loaded into memory. null If set to true, if the object does not exist, return 0, else an exception is generated.
- Returns
- a pointer to a object.
void LoadIndex | ( | const C * | obj, |
GConcept * | concept, | ||
R::RNumContainer< size_t, true > & | refs | ||
) |
Load the identifiers of all objects described by a specific concept.
- Parameters
-
obj Pseudo-parameter. concept Concept to search for. refs Identifiers of the objects.
void BuildIndex | ( | const C * | obj | ) |
Build the index of all the objects from scratch. Since only the object descriptions are used, no occurrence information is available.
- Parameters
-
obj Pseudo-parameter.
void LoadTree | ( | const C * | obj, |
GConceptTree *& | tree, | ||
size_t | blockid, | ||
size_t | id | ||
) |
Load the concept tree of a given object. This method generates an exception for all objects excepted documents.
- Parameters
-
obj Pseudo-parameter. tree Concept tree. If null,it is created. blockid Identifier of the block of the document. id Identifier of the document.
void LoadTree | ( | const C * | obj, |
R::RContainer< GConceptRecord, false, true > & | records, | ||
size_t & | nbrecords, | ||
size_t & | nbtoprecords, | ||
size_t & | nbrefs | ||
) |
Load the tree as a container of records.
- Parameters
-
obj Obj for which the tree must be loaded. records Container of records (modified by the method). nbrecords Number of records used for the document tree (modified by the method). nbtoprecords Number of top records (modified by the method). nbrefs Number of concepts referenced (modified by the method).
|
private |
Initialize the parameters.
- Parameters
-
config Configuration structure.
|
privatevirtual |
Clear the list.
- Parameters
-
obj Pseudo-parameter. list Specify if the objects must be deleted or just their descriptions.
Reimplemented in GClasses.
|
private |
Open the files in a given directory.
- Parameters
-
config Configuration structure. subdir Sub-directory where the files will be stored.
|
private |
- Returns
- if an index is create.
- Parameters
-
obj Pseudo-parameter.
|
private |
- Returns
- if the concept trees are created.
- Parameters
-
obj Pseudo-parameter.
|
private |
Assign an identifier to an object.
- Parameters
-
obj Object.
|
private |
Load all the objects.
- Parameters
-
obj Pseudo-parameter.
|
private |
Load the description of a given object.
- Parameters
-
obj Pseudo-parameter. vectors Vectors. blockid Identifier of the block of the object. id Identifier of the object.
|
private |
Save the description of a given object.
- Parameters
-
obj Pseudo-parameter. vectors Vectors. blockid Identifier of the block of the object (0 means the block will be found). id Identifier of the object.
|
private |
Flush the descriptions of the objects.
- Parameters
-
obj Pseudo-parameter.
|
private |
Update the index of a given object that is only described by a description.
- Parameters
-
obj Pseudo-parameter. desc Description. id Identifier of the object. add Object must be added or removed from the index.
|
private |
Load the next node in the file into a given tree. The method loads first the node information and then the method is called for its children.
- Parameters
-
tree Tree that will contain the new node. parent Parent node of the one to load.
|
private |
Save a record in the file. The method saves first the node information and then calls the method for its children.
- Parameters
-
node Node to save.
|
private |
Save the concept tree of a given object. This method generates an exception except for documents.
- Parameters
-
obj Pseudo-parameter. records Container of records. nbrecords Number of records used for the document tree. nbtoprecords Number of top records. nbrefs Number of concepts referenced. blockid Identifier of the block of the document (0 means the block will be found). id Identifier of the document.
|
private |
Flush the file storing the concept trees of the objects.
- Parameters
-
obj Pseudo-parameter.
|
private |
Seek the store to the beginning of a record of an object.
- Parameters
-
obj Pointer to the object. idx Index of the object.
bool FindDepthFirstRecord | ( | const C * | obj, |
GConceptRecord & | rec, | ||
size_t | idx | ||
) |
Find the first record that correspond to a given object starting from a given index.
The first record is not necessary the highest in the hierarchy, since a depth-first search is used.
- Parameters
-
obj Pointer to the object. rec Record that will be filled with the result. The concept to be searched must be set. idx Index where to start the search.
- Returns
- true of a record was found.
bool FindRecord | ( | const C * | obj, |
GConceptRecord & | rec, | ||
size_t | synpos | ||
) |
Find a record at a given syntactic position.
- Parameters
-
obj Pointer to the object. rec Record that will be filled with the result. synpos Syntactic position.
- Returns
- true of a record was found.
bool FindParentRecord | ( | const C * | obj, |
const GConceptRecord & | search, | ||
GConceptRecord & | rec | ||
) |
Find the parent record of a given record.
- Parameters
-
obj Pointer to the object. search Record that contains the record for which the parent must be found. rec Record that will be filled with the result.
- Returns
- true of a parent record was found.
bool FindFirstChildRecord | ( | const C * | obj, |
const GConceptRecord & | search, | ||
GConceptRecord & | rec, | ||
size_t | idx | ||
) |
Find the first child record that correspond to a given record and starting from a given index.
- Parameters
-
obj Pointer to the object. search Record that contains the record for which the parent must be found. rec Record that will be filled with the result. idx Index where to start the search.
- Returns
- true of a record was found.
bool FindNearestRecord | ( | const C * | obj, |
GConceptRecord & | rec, | ||
size_t | synpos | ||
) |
Find the nearest record at a given syntactic position. In practice, the method searches alternatively before and after the given position.
- Parameters
-
obj Pointer to the object. rec Record that will be filled with the result. synpos Syntactic position.
- Returns
- true of a record was found.
bool FindNearestRecord | ( | const C * | obj, |
GConceptRecord & | rec, | ||
size_t | synpos, | ||
bool | after | ||
) |
Find the nearest record at a given syntactic position. In practice, the method searches the first record after or before the given position. If no record is found, it searches in the order direction.
- Parameters
-
obj Pointer to the object. rec Record that will be filled with the result. synpos Syntactic position. after Search after the position (true) or before it (false)?
- Returns
- true if a record was found.
bool FindRootRecord | ( | const C * | obj, |
const GConceptRecord & | rec1, | ||
const GConceptRecord & | rec2, | ||
GConceptRecord & | rec | ||
) |
Find the root record (the most common highest record) of two records. If at least one of the node doesn't have a parent, no root node can be found.
- Parameters
-
obj Pointer to the object. rec1 First record. rec2 Second record. rec Record that will be filled with the result.
- Returns
- true if a root node could be found.
size_t GetMinPosRecord | ( | const C * | obj, |
const GConceptRecord & | rec, | ||
size_t | nbbefore | ||
) |
Find the minimal position centred on a given record and a number of records before.
- Parameters
-
obj Pointer to the object. rec Record that contains the record for which the parent must be found. nbbefore Maximum number of concept node before.
- Returns
- a position.
size_t GetMaxPosRecord | ( | const C * | obj, |
const GConceptRecord & | rec, | ||
size_t | nbafter | ||
) |
Find the maximal position centred on a given record and a number of records after.
- Parameters
-
obj Pointer to the object. rec Record that contains the record for which the parent must be found. nbafter Maximum number of record after.
- Returns
- a position.
size_t GetMaxPosRecord | ( | const C * | obj | ) |
Compute the maximal position occupied by a record in an object.
- Parameters
-
obj Pointer to the object.
- Returns
- a position.
size_t GetMaxSyntacticPosRecord | ( | const C * | obj | ) |
Compute the maximal syntactic position occupied by a record in an object.
- Parameters
-
obj Pointer to the object.
- Returns
- a syntactic position.
size_t GetNbTotalChildRecords | ( | const C * | obj, |
const GConceptRecord & | rec | ||
) |
Get the total number of child records (including all the children) of a given record.
- Parameters
-
obj Pointer to the object. rec Record that contains the record for which the number must be found.
- Returns
- a number.
Member Data Documentation
|
private |
Name of the objects.
|
private |
Type of the objects.
|
private |
Maximum objects to managed in memory.
|
private |
Description of the objects.
|
private |
Create the index ?
|
private |
Index of the objects.
|
private |
Create the tree concepts?
|
private |
Tree concepts of the objects.
|
private |
Are the objects loaded.
|
private |
Temporary vector of references.
|
private |
Reader/writer lock on the objects.
|
private |
Reader/writer lock on the descriptions.
|
private |
Reader/writer lock on the index.
|
private |
Reader/writer lock on the trees.