SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TAttr Class Reference

#include <attr.h>

Collaboration diagram for TAttr:

Public Member Functions

 TAttr ()
 
 TAttr (const TAttr &Attrs)
 
 TAttr (TSIn &SIn)
 Constructor for loading attributes from a (binary) stream SIn. More...
 
void Load (TSIn &SIn)
 Load attribute from input stream. More...
 
void Save (TSOut &SOut) const
 Saves the attributes to a (binary) stream SOut. More...
 
void Clr ()
 Clears the contents of the attribute map. More...
 
size_t GetMemUsed () const
 Returns the amount of memory used by sparse attributes. More...
 
int AddSAttrDat (const TInt &Id, const TStr &AttrName, const TInt &Val)
 Add Int attribute with name AttrName for the given id Id. More...
 
int AddSAttrDat (const TInt &Id, const TInt &AttrId, const TInt &Val)
 Add Int attribute with attribute id AttrId for the given id Id. More...
 
int AddSAttrDat (const TInt &Id, const TStr &AttrName, const TFlt &Val)
 Add Flt attribute with name AttrName for the given id Id. More...
 
int AddSAttrDat (const TInt &Id, const TInt &AttrId, const TFlt &Val)
 Add Flt attribute with attribute id AttrId for the given id Id. More...
 
int AddSAttrDat (const TInt &Id, const TStr &AttrName, const TStr &Val)
 Add Str attribute with name AttrName for the given id Id. More...
 
int AddSAttrDat (const TInt &Id, const TInt &AttrId, const TStr &Val)
 Add Str attribute with attribute id AttrId for the given id Id. More...
 
int GetSAttrDat (const TInt &Id, const TStr &AttrName, TInt &ValX) const
 Get Int attribute with name AttrName for the given id Id. More...
 
int GetSAttrDat (const TInt &Id, const TInt &AttrId, TInt &ValX) const
 Get Int attribute with attribute id AttrId for the given id Id. More...
 
int GetSAttrDat (const TInt &Id, const TStr &AttrName, TFlt &ValX) const
 Get Flt attribute with name AttrName for the given id Id. More...
 
int GetSAttrDat (const TInt &Id, const TInt &AttrId, TFlt &ValX) const
 Get Flt attribute with attribute id AttrId for the given id Id. More...
 
int GetSAttrDat (const TInt &Id, const TStr &AttrName, TStr &ValX) const
 Get Str attribute with name AttrName for the given id Id. More...
 
int GetSAttrDat (const TInt &Id, const TInt &AttrId, TStr &ValX) const
 Get Str attribute with attribute id AttrId for the given id Id. More...
 
int DelSAttrDat (const TInt &Id, const TStr &AttrName)
 Delete attribute with name AttrName for the given id Id. More...
 
int DelSAttrDat (const TInt &Id, const TInt &AttrId)
 Delete attribute with attribute id AttrId for the given id Id. More...
 
void DelSAttrId (const TInt &Id)
 Delete all attributes for the given id Id. More...
 
void GetSAttrV (const TInt &Id, const TAttrType AttrType, TAttrPrV &AttrV) const
 Get a list of all attributes of type AttrType for the given id Id. More...
 
int GetIdVSAttr (const TStr &AttrName, TIntV &IdV) const
 Get a list of all ids that have an attribute with name AttrName. More...
 
int GetIdVSAttr (const TInt &AttrId, TIntV &IdV) const
 Get a list of all ids that have an attribute with attribute id AttrId. More...
 
int AddSAttr (const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
 Adds a mapping for an attribute with name Name and type AttrType. More...
 
int GetSAttrId (const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
 Given the attribute name Name, get the attribute id. More...
 
int GetSAttrName (const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
 Given the attribute id AttrId, get the attribute name. More...
 

Private Member Functions

int GetIdVSAttr (const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
 

Private Attributes

TStrIntPrH AttrNameToId
 
TIntIntStrPrH AttrIdToName
 
TIntPrIntH IntAttrVals
 
TIntPrFltH FltAttrVals
 
TIntPrStrH StrAttrVals
 

Detailed Description

Definition at line 4 of file attr.h.

Constructor & Destructor Documentation

TAttr::TAttr ( )
inline

Definition at line 16 of file attr.h.

17  FltAttrVals(), StrAttrVals() { }
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
TIntPrStrH StrAttrVals
Definition: attr.h:12
TIntPrFltH FltAttrVals
Definition: attr.h:11
TIntPrIntH IntAttrVals
Definition: attr.h:10
TStrIntPrH AttrNameToId
Definition: attr.h:7
TAttr::TAttr ( const TAttr Attrs)
inline

Definition at line 18 of file attr.h.

18  : AttrNameToId(Attrs.AttrNameToId),
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
TIntPrStrH StrAttrVals
Definition: attr.h:12
TIntPrFltH FltAttrVals
Definition: attr.h:11
TIntPrIntH IntAttrVals
Definition: attr.h:10
TStrIntPrH AttrNameToId
Definition: attr.h:7
TAttr::TAttr ( TSIn SIn)
inline

Constructor for loading attributes from a (binary) stream SIn.

Definition at line 22 of file attr.h.

22  : AttrNameToId(SIn), AttrIdToName(SIn),
23  IntAttrVals(SIn), FltAttrVals(SIn), StrAttrVals(SIn) { }
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
TIntPrStrH StrAttrVals
Definition: attr.h:12
TIntPrFltH FltAttrVals
Definition: attr.h:11
TIntPrIntH IntAttrVals
Definition: attr.h:10
TStrIntPrH AttrNameToId
Definition: attr.h:7

Member Function Documentation

int TAttr::AddSAttr ( const TStr Name,
const TAttrType AttrType,
TInt AttrIdX 
)

Adds a mapping for an attribute with name Name and type AttrType.

Definition at line 210 of file attr.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), atFlt, atInt, atStr, AttrIdToName, AttrNameToId, THash< TKey, TDat, THashFunc >::GetMxKeyIds(), and THash< TKey, TDat, THashFunc >::IsKey().

Referenced by AddSAttrDat(), TNEANet::AddSAttrE(), TUndirNet::AddSAttrE(), TDirNet::AddSAttrE(), TNEANet::AddSAttrN(), TUndirNet::AddSAttrN(), and TDirNet::AddSAttrN().

210  {
211  if (AttrType != atInt && AttrType != atFlt && AttrType != atStr) {
212  return -1; // type must be defined and can only have a single type
213  }
214  if (AttrNameToId.IsKey(Name)) { return -1; }
215  AttrId = AttrNameToId.GetMxKeyIds();
216  TIntPr TypeAndId(AttrType, AttrId);
217  AttrNameToId.AddDat(Name, TypeAndId);
218  TIntStrPr TypeAndName(AttrType, Name);
219  AttrIdToName.AddDat(AttrId, TypeAndName);
220  return 0;
221 }
Definition: gbase.h:23
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
int GetMxKeyIds() const
Definition: hash.h:231
Definition: ds.h:32
Definition: gbase.h:23
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttr::AddSAttrDat ( const TInt Id,
const TStr AttrName,
const TInt Val 
)

Add Int attribute with name AttrName for the given id Id.

Definition at line 2 of file attr.cpp.

References AddSAttr(), atInt, AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

Referenced by AddSAttrDat(), TNEANet::AddSAttrDatE(), TUndirNet::AddSAttrDatE(), TDirNet::AddSAttrDatE(), TNEANet::AddSAttrDatN(), TUndirNet::AddSAttrDatN(), and TDirNet::AddSAttrDatN().

2  {
3  TInt AttrId;
4  if (!AttrNameToId.IsKey(AttrName)) {
5  AddSAttr(AttrName, atInt, AttrId);
6  } else {
7  AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
8  }
9  return AddSAttrDat(Id, AttrId, Val);
10 }
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: gbase.h:23
Definition: dt.h:1134
bool IsKey(const TKey &Key) const
Definition: hash.h:258
int AddSAttr(const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
Adds a mapping for an attribute with name Name and type AttrType.
Definition: attr.cpp:210
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttr::AddSAttrDat ( const TInt Id,
const TInt AttrId,
const TInt Val 
)

Add Int attribute with attribute id AttrId for the given id Id.

Definition at line 11 of file attr.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), atInt, AttrIdToName, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal1(), IntAttrVals, and THash< TKey, TDat, THashFunc >::IsKey().

11  {
12  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
13  if (AttrIdToName.GetDat(AttrId).GetVal1() != atInt) { return -2; }
14  TIntPr Key(AttrId, Id);
15  IntAttrVals.AddDat(Key, Val);
16  return 0;
17 }
const TVal1 & GetVal1() const
Definition: ds.h:60
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: gbase.h:23
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
Definition: ds.h:32
TIntPrIntH IntAttrVals
Definition: attr.h:10
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

int TAttr::AddSAttrDat ( const TInt Id,
const TStr AttrName,
const TFlt Val 
)

Add Flt attribute with name AttrName for the given id Id.

Definition at line 19 of file attr.cpp.

References AddSAttr(), AddSAttrDat(), atFlt, AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

19  {
20  TInt AttrId;
21  if (!AttrNameToId.IsKey(AttrName)) {
22  AddSAttr(AttrName, atFlt, AttrId);
23  } else {
24  AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
25  }
26  return AddSAttrDat(Id, AttrId, Val);
27 }
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: dt.h:1134
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:258
int AddSAttr(const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
Adds a mapping for an attribute with name Name and type AttrType.
Definition: attr.cpp:210
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

int TAttr::AddSAttrDat ( const TInt Id,
const TInt AttrId,
const TFlt Val 
)

Add Flt attribute with attribute id AttrId for the given id Id.

Definition at line 28 of file attr.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), atFlt, AttrIdToName, FltAttrVals, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal1(), and THash< TKey, TDat, THashFunc >::IsKey().

28  {
29  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
30  if (AttrIdToName.GetDat(AttrId).GetVal1() != atFlt) { return -2; }
31  TIntPr Key(AttrId, Id);
32  FltAttrVals.AddDat(Key, Val);
33  return 0;
34 }
const TVal1 & GetVal1() const
Definition: ds.h:60
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
Definition: ds.h:32
Definition: gbase.h:23
TIntPrFltH FltAttrVals
Definition: attr.h:11
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

int TAttr::AddSAttrDat ( const TInt Id,
const TStr AttrName,
const TStr Val 
)

Add Str attribute with name AttrName for the given id Id.

Definition at line 36 of file attr.cpp.

References AddSAttr(), AddSAttrDat(), atStr, AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

36  {
37  TInt AttrId;
38  if (!AttrNameToId.IsKey(AttrName)) {
39  AddSAttr(AttrName, atStr, AttrId);
40  } else {
41  AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
42  }
43  return AddSAttrDat(Id, AttrId, Val);
44 }
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: dt.h:1134
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:258
int AddSAttr(const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
Adds a mapping for an attribute with name Name and type AttrType.
Definition: attr.cpp:210
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

int TAttr::AddSAttrDat ( const TInt Id,
const TInt AttrId,
const TStr Val 
)

Add Str attribute with attribute id AttrId for the given id Id.

Definition at line 45 of file attr.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), atStr, AttrIdToName, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal1(), THash< TKey, TDat, THashFunc >::IsKey(), and StrAttrVals.

45  {
46  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
47  if (AttrIdToName.GetDat(AttrId).GetVal1() != atStr) { return -2; }
48  TIntPr Key(AttrId, Id);
49  StrAttrVals.AddDat(Key, Val);
50  return 0;
51 }
const TVal1 & GetVal1() const
Definition: ds.h:60
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
TIntPrStrH StrAttrVals
Definition: attr.h:12
Definition: ds.h:32
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

void TAttr::Clr ( )
inline

Clears the contents of the attribute map.

Definition at line 37 of file attr.h.

References AttrIdToName, AttrNameToId, THash< TKey, TDat, THashFunc >::Clr(), FltAttrVals, IntAttrVals, and StrAttrVals.

TIntIntStrPrH AttrIdToName
Definition: attr.h:8
TIntPrStrH StrAttrVals
Definition: attr.h:12
TIntPrFltH FltAttrVals
Definition: attr.h:11
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:361
TIntPrIntH IntAttrVals
Definition: attr.h:10
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

int TAttr::DelSAttrDat ( const TInt Id,
const TStr AttrName 
)

Delete attribute with name AttrName for the given id Id.

Definition at line 103 of file attr.cpp.

References AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

Referenced by TNEANet::DelSAttrDatE(), TUndirNet::DelSAttrDatE(), TDirNet::DelSAttrDatE(), TNEANet::DelSAttrDatN(), TUndirNet::DelSAttrDatN(), and TDirNet::DelSAttrDatN().

103  {
104  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
105  TInt AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
106  return DelSAttrDat(Id, AttrId);
107 }
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:103
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: dt.h:1134
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttr::DelSAttrDat ( const TInt Id,
const TInt AttrId 
)

Delete attribute with attribute id AttrId for the given id Id.

Definition at line 108 of file attr.cpp.

References THash< TKey, TDat, THashFunc >::DelKey(), FltAttrVals, IntAttrVals, THash< TKey, TDat, THashFunc >::IsKey(), and StrAttrVals.

108  {
109  TIntPr Key(AttrId, Id);
110  if (IntAttrVals.IsKey(Key)) {
111  IntAttrVals.DelKey(Key);
112  return 0;
113  } else if (FltAttrVals.IsKey(Key)) {
114  FltAttrVals.DelKey(Key);
115  return 0;
116  } else if (StrAttrVals.IsKey(Key)) {
117  StrAttrVals.DelKey(Key);
118  return 0;
119  }
120  return -1;
121 }
void DelKey(const TKey &Key)
Definition: hash.h:404
TIntPrStrH StrAttrVals
Definition: attr.h:12
Definition: ds.h:32
TIntPrFltH FltAttrVals
Definition: attr.h:11
TIntPrIntH IntAttrVals
Definition: attr.h:10
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

void TAttr::DelSAttrId ( const TInt Id)

Delete all attributes for the given id Id.

Definition at line 124 of file attr.cpp.

References atFlt, atInt, atStr, AttrNameToId, THash< TKey, TDat, THashFunc >::BegI(), THash< TKey, TDat, THashFunc >::DelIfKey(), THash< TKey, TDat, THashFunc >::EndI(), FltAttrVals, IntAttrVals, and StrAttrVals.

Referenced by TNEANet::DelEdge(), TUndirNet::DelEdge(), TDirNet::DelEdge(), TNEANet::DelNode(), TUndirNet::DelNode(), and TDirNet::DelNode().

124  {
125  for (TStrIntPrH::TIter it = AttrNameToId.BegI(); it < AttrNameToId.EndI(); it++) {
126  TAttrType CurType = static_cast<TAttrType>(it.GetDat().GetVal1().Val);
127  TIntPr AttrKey(it.GetDat().GetVal2(), Id);
128  if (CurType == atInt) {
129  IntAttrVals.DelIfKey(AttrKey);
130  } else if (CurType == atFlt) {
131  FltAttrVals.DelIfKey(AttrKey);
132  } else if (CurType == atStr) {
133  StrAttrVals.DelIfKey(AttrKey);
134  }
135  }
136 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
TIter BegI() const
Definition: hash.h:213
TIter EndI() const
Definition: hash.h:218
Definition: gbase.h:23
TIntPrStrH StrAttrVals
Definition: attr.h:12
Definition: ds.h:32
Definition: gbase.h:23
bool DelIfKey(const TKey &Key)
Definition: hash.h:243
TIntPrFltH FltAttrVals
Definition: attr.h:11
Definition: gbase.h:23
TIntPrIntH IntAttrVals
Definition: attr.h:10
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttr::GetIdVSAttr ( const TInt AttrId,
const TAttrType  Type,
TIntV IdV 
) const
private

Definition at line 167 of file attr.cpp.

References TVec< TVal, TSizeTy >::Add(), atFlt, atInt, atStr, THash< TKey, TDat, THashFunc >::BegI(), THash< TKey, TDat, THashFunc >::EndI(), FltAttrVals, IntAttrVals, and StrAttrVals.

Referenced by GetIdVSAttr(), TNEANet::GetIdVSAttrE(), TUndirNet::GetIdVSAttrE(), TDirNet::GetIdVSAttrE(), TNEANet::GetIdVSAttrN(), TUndirNet::GetIdVSAttrN(), and TDirNet::GetIdVSAttrN().

167  {
168  if (Type == atInt) {
169  for (TIntPrIntH::TIter it = IntAttrVals.BegI(); it < IntAttrVals.EndI(); it++) {
170  if (it.GetKey().GetVal1() == AttrId) {
171  IdV.Add(it.GetKey().GetVal2());
172  }
173  }
174  } else if (Type == atFlt) {
175  for (TIntPrFltH::TIter it = FltAttrVals.BegI(); it < FltAttrVals.EndI(); it++) {
176  if (it.GetKey().GetVal1() == AttrId) {
177  IdV.Add(it.GetKey().GetVal2());
178  }
179  }
180  } else if (Type == atStr) {
181  for (TIntPrStrH::TIter it = StrAttrVals.BegI(); it < StrAttrVals.EndI(); it++) {
182  if (it.GetKey().GetVal1() == AttrId) {
183  IdV.Add(it.GetKey().GetVal2());
184  }
185  }
186  } else {
187  return -1;
188  }
189  return 0;
190 }
TIter BegI() const
Definition: hash.h:213
TIter EndI() const
Definition: hash.h:218
Definition: gbase.h:23
TIntPrStrH StrAttrVals
Definition: attr.h:12
Definition: gbase.h:23
TIntPrFltH FltAttrVals
Definition: attr.h:11
Definition: gbase.h:23
TIntPrIntH IntAttrVals
Definition: attr.h:10
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttr::GetIdVSAttr ( const TStr AttrName,
TIntV IdV 
) const

Get a list of all ids that have an attribute with name AttrName.

Definition at line 200 of file attr.cpp.

References AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), GetIdVSAttr(), TPair< TVal1, TVal2 >::GetVal1(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

200  {
201  IdV = TIntV();
202  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
203  TIntPr TypeAndId = AttrNameToId.GetDat(AttrName);
204  TAttrType Type = static_cast<TAttrType>(TypeAndId.GetVal1().Val);
205  TInt AttrId = TypeAndId.GetVal2();
206  return GetIdVSAttr(AttrId, Type, IdV);
207 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
const TVal1 & GetVal1() const
Definition: ds.h:60
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
Definition: attr.cpp:167
Definition: dt.h:1134
Definition: ds.h:32
TVec< TInt > TIntV
Definition: ds.h:1594
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

int TAttr::GetIdVSAttr ( const TInt AttrId,
TIntV IdV 
) const

Get a list of all ids that have an attribute with attribute id AttrId.

Definition at line 192 of file attr.cpp.

References AttrIdToName, THash< TKey, TDat, THashFunc >::GetDat(), GetIdVSAttr(), TPair< TVal1, TVal2 >::GetVal1(), and THash< TKey, TDat, THashFunc >::IsKey().

192  {
193  IdV = TIntV();
194  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
195  TIntStrPr TypeAndName = AttrIdToName.GetDat(AttrId);
196  TAttrType Type = static_cast<TAttrType>(TypeAndName.GetVal1().Val);
197  return GetIdVSAttr(AttrId, Type, IdV);
198 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
const TVal1 & GetVal1() const
Definition: ds.h:60
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
Definition: attr.cpp:167
Definition: ds.h:32
TVec< TInt > TIntV
Definition: ds.h:1594
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

size_t TAttr::GetMemUsed ( ) const
inline

Returns the amount of memory used by sparse attributes.

Definition at line 40 of file attr.h.

References AttrIdToName, AttrNameToId, FltAttrVals, THash< TKey, TDat, THashFunc >::GetMemUsed(), IntAttrVals, and StrAttrVals.

TIntIntStrPrH AttrIdToName
Definition: attr.h:8
::TSize GetMemUsed() const
Definition: hash.h:201
TIntPrStrH StrAttrVals
Definition: attr.h:12
TIntPrFltH FltAttrVals
Definition: attr.h:11
TIntPrIntH IntAttrVals
Definition: attr.h:10
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

int TAttr::GetSAttrDat ( const TInt Id,
const TStr AttrName,
TInt ValX 
) const

Get Int attribute with name AttrName for the given id Id.

Definition at line 54 of file attr.cpp.

References AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

Referenced by GetSAttrDat(), TNEANet::GetSAttrDatE(), TUndirNet::GetSAttrDatE(), TDirNet::GetSAttrDatE(), TNEANet::GetSAttrDatN(), TUndirNet::GetSAttrDatN(), and TDirNet::GetSAttrDatN().

54  {
55  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
56  TInt AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
57  return GetSAttrDat(Id, AttrId, Val);
58 }
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: dt.h:1134
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttr::GetSAttrDat ( const TInt Id,
const TInt AttrId,
TInt ValX 
) const

Get Int attribute with attribute id AttrId for the given id Id.

Definition at line 59 of file attr.cpp.

References atInt, AttrIdToName, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal1(), IntAttrVals, and THash< TKey, TDat, THashFunc >::IsKey().

59  {
60  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
61  if (AttrIdToName.GetDat(AttrId).GetVal1() != atInt) { return -2; }
62  TIntPr Key(AttrId, Id);
63  if (IntAttrVals.IsKey(Key)) {
64  Val = IntAttrVals.GetDat(Key);
65  return 0;
66  }
67  return -1;
68 }
const TVal1 & GetVal1() const
Definition: ds.h:60
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: gbase.h:23
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
Definition: ds.h:32
TIntPrIntH IntAttrVals
Definition: attr.h:10
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

int TAttr::GetSAttrDat ( const TInt Id,
const TStr AttrName,
TFlt ValX 
) const

Get Flt attribute with name AttrName for the given id Id.

Definition at line 70 of file attr.cpp.

References AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), GetSAttrDat(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

70  {
71  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
72  TInt AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
73  return GetSAttrDat(Id, AttrId, Val);
74 }
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: dt.h:1134
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

int TAttr::GetSAttrDat ( const TInt Id,
const TInt AttrId,
TFlt ValX 
) const

Get Flt attribute with attribute id AttrId for the given id Id.

Definition at line 75 of file attr.cpp.

References atFlt, AttrIdToName, FltAttrVals, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal1(), and THash< TKey, TDat, THashFunc >::IsKey().

75  {
76  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
77  if (AttrIdToName.GetDat(AttrId).GetVal1() != atFlt) { return -2; }
78  TIntPr Key(AttrId, Id);
79  if (FltAttrVals.IsKey(Key)) {
80  Val = FltAttrVals.GetDat(Key);
81  return 0;
82  }
83  return -1;
84 }
const TVal1 & GetVal1() const
Definition: ds.h:60
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
Definition: ds.h:32
Definition: gbase.h:23
TIntPrFltH FltAttrVals
Definition: attr.h:11
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

int TAttr::GetSAttrDat ( const TInt Id,
const TStr AttrName,
TStr ValX 
) const

Get Str attribute with name AttrName for the given id Id.

Definition at line 86 of file attr.cpp.

References AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), GetSAttrDat(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

86  {
87  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
88  TInt AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
89  return GetSAttrDat(Id, AttrId, Val);
90 }
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: dt.h:1134
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

int TAttr::GetSAttrDat ( const TInt Id,
const TInt AttrId,
TStr ValX 
) const

Get Str attribute with attribute id AttrId for the given id Id.

Definition at line 91 of file attr.cpp.

References atStr, AttrIdToName, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal1(), THash< TKey, TDat, THashFunc >::IsKey(), and StrAttrVals.

91  {
92  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
93  if (AttrIdToName.GetDat(AttrId).GetVal1() != atStr) { return -2; }
94  TIntPr Key(AttrId, Id);
95  if (StrAttrVals.IsKey(Key)) {
96  Val = StrAttrVals.GetDat(Key);
97  return 0;
98  }
99  return -1;
100 }
const TVal1 & GetVal1() const
Definition: ds.h:60
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
TIntPrStrH StrAttrVals
Definition: attr.h:12
Definition: ds.h:32
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

int TAttr::GetSAttrId ( const TStr Name,
TInt AttrIdX,
TAttrType AttrTypeX 
) const

Given the attribute name Name, get the attribute id.

Definition at line 224 of file attr.cpp.

References AttrNameToId, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal1(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

Referenced by TNEANet::GetSAttrIdE(), TUndirNet::GetSAttrIdE(), TDirNet::GetSAttrIdE(), TNEANet::GetSAttrIdN(), TUndirNet::GetSAttrIdN(), and TDirNet::GetSAttrIdN().

224  {
225  if (!AttrNameToId.IsKey(Name)) {
226  return -1;
227  }
228  TIntPr TypeAndId = AttrNameToId.GetDat(Name);
229  AttrType = static_cast<TAttrType>(TypeAndId.GetVal1().Val);
230  AttrId = TypeAndId.GetVal2();
231  return 0;
232 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
const TVal1 & GetVal1() const
Definition: ds.h:60
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttr::GetSAttrName ( const TInt AttrId,
TStr NameX,
TAttrType AttrTypeX 
) const

Given the attribute id AttrId, get the attribute name.

Definition at line 233 of file attr.cpp.

References AttrIdToName, THash< TKey, TDat, THashFunc >::GetDat(), TPair< TVal1, TVal2 >::GetVal1(), TPair< TVal1, TVal2 >::GetVal2(), and THash< TKey, TDat, THashFunc >::IsKey().

Referenced by TNEANet::GetSAttrNameE(), TUndirNet::GetSAttrNameE(), TDirNet::GetSAttrNameE(), TNEANet::GetSAttrNameN(), TUndirNet::GetSAttrNameN(), and TDirNet::GetSAttrNameN().

233  {
234  if (!AttrIdToName.IsKey(AttrId)) {
235  return -1;
236  }
237  TIntStrPr TypeAndName = AttrIdToName.GetDat(AttrId);
238  AttrType = static_cast<TAttrType>(TypeAndName.GetVal1().Val);
239  Name = TypeAndName.GetVal2();
240  return 0;
241 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
const TVal1 & GetVal1() const
Definition: ds.h:60
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

Here is the caller graph for this function:

void TAttr::GetSAttrV ( const TInt Id,
const TAttrType  AttrType,
TAttrPrV AttrV 
) const

Get a list of all attributes of type AttrType for the given id Id.

Definition at line 139 of file attr.cpp.

References TVec< TVal, TSizeTy >::Add(), atFlt, atInt, atStr, AttrNameToId, THash< TKey, TDat, THashFunc >::BegI(), THash< TKey, TDat, THashFunc >::EndI(), FltAttrVals, IntAttrVals, THash< TKey, TDat, THashFunc >::IsKey(), and StrAttrVals.

Referenced by TNEANet::GetSAttrVE(), TUndirNet::GetSAttrVE(), TDirNet::GetSAttrVE(), TNEANet::GetSAttrVN(), TUndirNet::GetSAttrVN(), and TDirNet::GetSAttrVN().

139  {
140  AttrV = TAttrPrV();
141  for (TStrIntPrH::TIter it = AttrNameToId.BegI(); it < AttrNameToId.EndI(); it++) {
142  TAttrType CurType = static_cast<TAttrType>(it.GetDat().GetVal1().Val);
143  if (CurType == AttrType) {
144  TIntPr AttrKey(it.GetDat().GetVal2(), Id);
145  if (CurType == atInt) {
146  if (IntAttrVals.IsKey(AttrKey)) {
147  TAttrPr Dat(it.GetKey(), CurType);
148  AttrV.Add(Dat);
149  }
150 
151  } else if (CurType == atFlt) {
152  if (FltAttrVals.IsKey(AttrKey)) {
153  TAttrPr Dat(it.GetKey(), CurType);
154  AttrV.Add(Dat);
155  }
156  } else if (CurType == atStr) {
157  if (StrAttrVals.IsKey(AttrKey)) {
158  TAttrPr Dat(it.GetKey(), CurType);
159  AttrV.Add(Dat);
160  }
161  }
162  }
163  }
164 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
TIter BegI() const
Definition: hash.h:213
TIter EndI() const
Definition: hash.h:218
Definition: gbase.h:23
TIntPrStrH StrAttrVals
Definition: attr.h:12
TVec< TAttrPr > TAttrPrV
Definition: attr.h:2
Definition: ds.h:32
Definition: gbase.h:23
TIntPrFltH FltAttrVals
Definition: attr.h:11
Definition: gbase.h:23
TIntPrIntH IntAttrVals
Definition: attr.h:10
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

Here is the caller graph for this function:

void TAttr::Load ( TSIn SIn)
inline

Load attribute from input stream.

Definition at line 25 of file attr.h.

References AttrIdToName, AttrNameToId, FltAttrVals, IntAttrVals, THash< TKey, TDat, THashFunc >::Load(), and StrAttrVals.

25  {
26  AttrNameToId.Load(SIn);
27  AttrIdToName.Load(SIn);
28  IntAttrVals.Load(SIn);
29  FltAttrVals.Load(SIn);
30  StrAttrVals.Load(SIn);
31  }
void Load(TSIn &SIn)
Definition: hash.h:177
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
TIntPrStrH StrAttrVals
Definition: attr.h:12
TIntPrFltH FltAttrVals
Definition: attr.h:11
TIntPrIntH IntAttrVals
Definition: attr.h:10
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

void TAttr::Save ( TSOut SOut) const
inline

Saves the attributes to a (binary) stream SOut.

Definition at line 33 of file attr.h.

References AttrIdToName, AttrNameToId, FltAttrVals, IntAttrVals, THash< TKey, TDat, THashFunc >::Save(), and StrAttrVals.

33  {
34  AttrNameToId.Save(SOut); AttrIdToName.Save(SOut);
35  IntAttrVals.Save(SOut); FltAttrVals.Save(SOut); StrAttrVals.Save(SOut); }
void Save(TSOut &SOut) const
Definition: hash.h:183
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
TIntPrStrH StrAttrVals
Definition: attr.h:12
TIntPrFltH FltAttrVals
Definition: attr.h:11
TIntPrIntH IntAttrVals
Definition: attr.h:10
TStrIntPrH AttrNameToId
Definition: attr.h:7

Here is the call graph for this function:

Member Data Documentation

TIntIntStrPrH TAttr::AttrIdToName
private

Definition at line 8 of file attr.h.

Referenced by AddSAttr(), AddSAttrDat(), Clr(), GetIdVSAttr(), GetMemUsed(), GetSAttrDat(), GetSAttrName(), Load(), and Save().

TStrIntPrH TAttr::AttrNameToId
private
TIntPrFltH TAttr::FltAttrVals
private
TIntPrIntH TAttr::IntAttrVals
private
TIntPrStrH TAttr::StrAttrVals
private

The documentation for this class was generated from the following files: