Commit f821f2c4 authored by claes's avatar claes

ClassListAttrRef and binary tree of subclass offsets added

parent dae91727
......@@ -47,6 +47,36 @@
gdb_sLocal *gdbroot = NULL;
#endif
/** Compare two keys in class attribute binary tree
*/
static int
compCatt( ptree_sTable *tp, ptree_sNode *x, ptree_sNode *y)
{
gdb_sClassAttrKey *xKey = (gdb_sClassAttrKey *) (tp->g->keyOffset + (char *) x);
gdb_sClassAttrKey *yKey = (gdb_sClassAttrKey *) (tp->g->keyOffset + (char *) y);
if ( xKey->subCid == yKey->subCid) {
if ( xKey->hostCid == yKey->hostCid) {
if ( xKey->idx == yKey->idx)
return 0;
else if ( xKey->idx < yKey->idx)
return -1;
else
return 1;
}
else if ( xKey->hostCid < yKey->hostCid)
return -1;
else
return 1;
}
else if ( xKey->subCid < yKey->subCid)
return -1;
else
return 1;
}
static void
evaluateInit (
......@@ -216,6 +246,9 @@ mapLocalDb (
gdbroot->sc_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.sc_ht, &gdbroot->db->h.sc_ht, NULL, NULL);
if (gdbroot->sc_ht == NULL) errh_Bugcheck(*sts, "initiating sub class object hash table");
gdbroot->catt_tt = ptree_Create(sts, gdbroot->pool, &gdbroot->t.catt_tt, &gdbroot->db->t.catt_tt,
compCatt);
if (gdbroot->catt_tt == NULL) errh_Bugcheck(*sts, "initiating class attribute tree table");
if (offsetof(sub_sClient, sid) != offsetof(sub_sServer, sid))
errh_Bugcheck(GDH__WEIRD, "offset id: client - server");
......@@ -711,6 +744,9 @@ gdb_CreateDb (
hash_Init(&gdbroot->db->h.sc_ht, ip->scObjects, sizeof(pwr_tObjid), sizeof(gdb_sScObject),
offsetof(gdb_sScObject, sc_htl), offsetof(gdb_sCclass, cclass_htl), hash_eKey_oid);
ptree_Init(gdbroot->pool, &gdbroot->db->t.catt_tt, sizeof(gdb_sClassAttrKey),
offsetof(gdb_sClassAttr, key), sizeof(gdb_sClassAttr), 100);
lp = mapLocalDb(sts);
if (lp == NULL) break;
......
......@@ -65,6 +65,10 @@
#include "rt_hash.h"
#endif
#ifndef rt_ptree_h
#include "rt_ptree.h"
#endif
#ifndef rt_net_h
#include "rt_net.h"
#endif
......@@ -560,7 +564,23 @@ typedef struct {
} gdb_sCclass;
/** Class attributes
*/
typedef struct {
pwr_tCid subCid; /**< Class Id for class attribute */
pwr_tCid hostCid; /**< Class Id for owner class */
pwr_tUInt32 idx; /**< Index of offset data */
} gdb_sClassAttrKey;
#define gdb_cCattOffsetSize 20
typedef struct {
ptree_sNode n;
gdb_sClassAttrKey key;
int numOffset;
pwr_tUInt32 offset[gdb_cCattOffsetSize];
} gdb_sClassAttr;
/** Object.
......@@ -807,7 +827,7 @@ typedef struct {
pwr_tUInt32 elem;
pwr_tUInt32 moffset; /**< Attribute maximum offset within body. */
pwr_tAix aix;
pwr_tClassId cid; /**< If class, Class Id */
pwr_tTid tid; /**< Type id or if class, Class Id */
pool_tRef cr; /**< If class, gdb_sClass reference */
} gdb_sAttribute;
......@@ -973,9 +993,11 @@ typedef struct {
hash_sGtable as_ht; /**< mount soid -> alias server hash table. */
hash_sGtable ccvol_ht; /**< nid + vid -> cached class volume */
hash_sGtable cclass_ht; /**< cid + cached voltime -> cached class */
hash_sGtable sc_ht; /**< oid -> Sub Class object hash table*/
hash_sGtable sc_ht; /**< oid -> Sub Class object hash table */
} h;
struct {
ptree_sGtable catt_tt; /**< cid and offset of class attributes tree table */
} t;
qcom_sQid nethandler; /**< local nethandler */
qcom_sQid neth_acp; /**< local neth acp */
qcom_sQid tmon; /**< local neth acp */
......@@ -1070,6 +1092,9 @@ typedef struct {
hash_sTable cclass_ht; /**< cid + cached voltime -> cached class hash table */
hash_sTable sc_ht; /**< oid -> sub class object hash table */
} h;
struct {
ptree_sTable catt_tt; /**< cid and offset of class attributes tree table*/
} t;
gdb_sGlobal *db; /**< Database Root, (in db_lock section) */
sect_sHead *sect; /**< Section header for global database. */
sect_sHead *lock; /**< Section header for . */
......@@ -1090,6 +1115,7 @@ typedef struct {
hash_sTable *ccvol_ht; /**< nid + vid -> cached class volume hash table */
hash_sTable *cclass_ht; /**< cid + cached voltime -> cached class hash table */
hash_sTable *sc_ht; /**< oid -> sub class object hash table */
ptree_sTable *catt_tt; /**< cid and offset of class attributes tree table */
gdb_sVolume *my_volume; /**< The local root volume. */
gdb_sVolume *no_volume; /**< The unknown volume with vid = 0.0.0.0. */
......
......@@ -1188,7 +1188,7 @@ gdh_GetRootList (
pwr_tStatus
gdh_GetClassList (
pwr_tClassId cid, /**< The object identity. */
pwr_tClassId cid, /**< The class identity. */
pwr_tObjid *oid /**< Receives the object identity. */
)
{
......@@ -1243,6 +1243,122 @@ gdh_GetNextObject (
return sts;
}
/**
* @brief Get the attribute reference of the first object
* in the list of objects of a specified class.
* The object can be a solitary object or an attribute object.
*
* The call shows only private volumes
* (of class $RootVolume, $SubVolume,
* $DynamicVolume, $ClassVolume and $SystemVolume),
* and shared volumes.
* @return pwr_tStatus
*/
pwr_tStatus
gdh_GetClassListAttrRef (
pwr_tClassId cid, /**< The class identity. */
pwr_sAttrRef *arp /**< Receives the attribute reference. */
)
{
pwr_tStatus sts = GDH__SUCCESS;
gdh_ScopeLock {
mvol_ClassListAttrRef(&sts, cid, NULL, arp, mvol_eList_first);
} gdh_ScopeUnlock;
return sts;
}
/**
* @brief Get the attrref of the next object
* in the list of objects of a certain class.
* The object can be a solitary object or an attribute object.
*
* The visibility of objects in the class list are
* restricted to objects in private volumes,
* (of class $RootVolume, $SubVolume,
* $DynamicVolume, $ClassVolume and $SystemVolume),
* and in shared volumes.
* @return pwr_tStatus
*/
pwr_tStatus
gdh_GetNextAttrRef (
pwr_tClassId cid, /**< The class identity. */
pwr_sAttrRef *arp, /**< The attribute reference. */
pwr_sAttrRef *new_arp /**< Receives the attribute reference */
)
{
pwr_tStatus sts = GDH__SUCCESS;
/* Check arguments. */
if (new_arp == NULL) return GDH__BADARG;
gdh_ScopeLock {
mvol_ClassListAttrRef(&sts, cid, arp, new_arp, mvol_eList_next);
} gdh_ScopeUnlock;
return sts;
}
/**
* @brief Get the attribute reference of the first attribute object
* of a specified class in the specified object.
* @return pwr_tStatus
*/
pwr_tStatus
gdh_GetObjectClassList (
pwr_tCid cid, /**< The class identity. */
pwr_tOid oid, /**< Host object. */
pwr_sAttrRef *arp /**< Receives the attribute reference. */
)
{
pwr_tStatus sts = GDH__SUCCESS;
pwr_sAttrRef ar;
gdh_ScopeLock {
ar.Objid = oid;
mvol_ClassListAttrRef(&sts, cid, &ar, arp, mvol_eList_objectfirst);
} gdh_ScopeUnlock;
return sts;
}
/**
* @brief Get the attrref of the next attribute object
* of a specified class in a specified object.
* @return pwr_tStatus
*/
pwr_tStatus
gdh_GetNextObjectAttrRef (
pwr_tClassId cid, /**< The class identity. */
pwr_sAttrRef *arp, /**< The attribute reference. */
pwr_sAttrRef *new_arp /**< Receives the attribute reference */
)
{
pwr_tStatus sts = GDH__SUCCESS;
/* Check arguments. */
if (new_arp == NULL) return GDH__BADARG;
gdh_ScopeLock {
mvol_ClassListAttrRef(&sts, cid, arp, new_arp, mvol_eList_objectnext);
} gdh_ScopeUnlock;
return sts;
}
/**
* @brief Return the objid of the node object for a node identified by a
* node identifier (of type pwr_tNodeId).
......
......@@ -383,7 +383,32 @@ gdh_GetPreviousObject (
pwr_tObjid *previousObject
);
pwr_tStatus
gdh_GetClassListAttrRef (
pwr_tClassId cid,
pwr_sAttrRef *arp
);
pwr_tStatus
gdh_GetNextAttrRef (
pwr_tClassId cid,
pwr_sAttrRef *arp,
pwr_sAttrRef *new_arp
);
pwr_tStatus
gdh_GetObjectClassList (
pwr_tCid cid, /**< The class identity. */
pwr_tOid oid, /**< Host object. */
pwr_sAttrRef *arp /**< Receives the attribute reference. */
);
pwr_tStatus
gdh_GetNextObjectAttrRef (
pwr_tClassId cid, /**< The class identity. */
pwr_sAttrRef *arp, /**< The attribute reference. */
pwr_sAttrRef *new_arp /**< Receives the attribute reference */
);
#define gdh_ClassNameToNumber gdh_ClassNameToId
pwr_tStatus
......
......@@ -464,6 +464,10 @@ ivol_BuildNode (
}
/* Build class attribute tree */
mvol_BuildCatt(sts);
convFctn = dvms_GetFctns(formatp);
if (convFctn != NULL)
decodeObjects(formatp->b.bo);
......
This diff is collapsed.
......@@ -35,6 +35,8 @@ typedef enum {
mvol_eList_last,
mvol_eList_next,
mvol_eList_prev,
mvol_eList_objectfirst,
mvol_eList_objectnext,
mvol_eList_
} mvol_eList;
......@@ -102,6 +104,15 @@ mvol_ClassList (
mvol_eList list
);
void
mvol_ClassListAttrRef (
pwr_tStatus *sts,
pwr_tClassId cid,
pwr_sAttrRef *iarp,
pwr_sAttrRef *oarp,
mvol_eList list
);
gdb_sClass *
mvol_LinkClass (
pwr_tStatus *sts,
......@@ -136,4 +147,9 @@ mvol_NameToClass (
char *name
);
void
mvol_BuildCatt (
pwr_tStatus *sts
);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment