SNAP Library 3.0, Developer Reference  2016-07-20 17:56:49
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
TAttrPair Class Reference

#include <attr.h>

Collaboration diagram for TAttrPair:

Public Member Functions

 TAttrPair ()
 
 TAttrPair (const TAttrPair &Attrs)
 
 TAttrPair (TSIn &SIn)
 Constructor for loading attributes from a (binary) stream SIn. 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...
 
int AddSAttrDat (const TIntPr &Id, const TStr &AttrName, const TInt &Val)
 Add Int attribute with name AttrName for the given id Id. More...
 
int AddSAttrDat (const TIntPr &Id, const TInt &AttrId, const TInt &Val)
 Add Int attribute with attribute id AttrId for the given id Id. More...
 
int AddSAttrDat (const TIntPr &Id, const TStr &AttrName, const TFlt &Val)
 Add Flt attribute with name AttrName for the given id Id. More...
 
int AddSAttrDat (const TIntPr &Id, const TInt &AttrId, const TFlt &Val)
 Add Flt attribute with attribute id AttrId for the given id Id. More...
 
int AddSAttrDat (const TIntPr &Id, const TStr &AttrName, const TStr &Val)
 Add Str attribute with name AttrName for the given id Id. More...
 
int AddSAttrDat (const TIntPr &Id, const TInt &AttrId, const TStr &Val)
 Add Str attribute with attribute id AttrId for the given id Id. More...
 
int GetSAttrDat (const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
 Get Int attribute with name AttrName for the given id Id. More...
 
int GetSAttrDat (const TIntPr &Id, const TInt &AttrId, TInt &ValX) const
 Get Int attribute with attribute id AttrId for the given id Id. More...
 
int GetSAttrDat (const TIntPr &Id, const TStr &AttrName, TFlt &ValX) const
 Get Flt attribute with name AttrName for the given id Id. More...
 
int GetSAttrDat (const TIntPr &Id, const TInt &AttrId, TFlt &ValX) const
 Get Flt attribute with attribute id AttrId for the given id Id. More...
 
int GetSAttrDat (const TIntPr &Id, const TStr &AttrName, TStr &ValX) const
 Get Str attribute with name AttrName for the given id Id. More...
 
int GetSAttrDat (const TIntPr &Id, const TInt &AttrId, TStr &ValX) const
 Get Str attribute with attribute id AttrId for the given id Id. More...
 
int DelSAttrDat (const TIntPr &Id, const TStr &AttrName)
 Delete attribute with name AttrName for the given id Id. More...
 
int DelSAttrDat (const TIntPr &Id, const TInt &AttrId)
 Delete attribute with attribute id AttrId for the given id Id. More...
 
void DelSAttrId (const TIntPr &Id)
 Delete all attributes for the given id Id. More...
 
void GetSAttrV (const TIntPr &Id, const TAttrType AttrType, TAttrPrV &AttrV) const
 Get a list of all attributes of the given type AttrType for the given id Id. More...
 
int GetIdVSAttr (const TStr &AttrName, TIntPrV &IdV) const
 Get a list of all ids that have an attribute with name AttrName. More...
 
int GetIdVSAttr (const TInt &AttrId, TIntPrV &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 and type. More...
 
int GetSAttrName (const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
 Given the attribute id AttrId, get the attribute name and type. More...
 

Private Member Functions

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

Private Attributes

TStrIntPrH AttrNameToId
 
TIntIntStrPrH AttrIdToName
 
TIntIntPrPrIntH IntAttrVals
 
TIntIntPrPrFltH FltAttrVals
 
TIntIntPrPrStrH StrAttrVals
 

Detailed Description

Definition at line 90 of file attr.h.

Constructor & Destructor Documentation

TAttrPair::TAttrPair ( )
inline

Definition at line 101 of file attr.h.

102  FltAttrVals(), StrAttrVals() { }
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TStrIntPrH AttrNameToId
Definition: attr.h:92
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
TAttrPair::TAttrPair ( const TAttrPair Attrs)
inline

Definition at line 103 of file attr.h.

103  : AttrNameToId(Attrs.AttrNameToId),
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TStrIntPrH AttrNameToId
Definition: attr.h:92
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
TAttrPair::TAttrPair ( TSIn SIn)
inline

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

Definition at line 107 of file attr.h.

107  : AttrNameToId(SIn), AttrIdToName(SIn),
108  IntAttrVals(SIn), FltAttrVals(SIn), StrAttrVals(SIn) { }
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TStrIntPrH AttrNameToId
Definition: attr.h:92
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97

Member Function Documentation

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

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

Definition at line 454 of file attr.cpp.

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

Referenced by AddSAttrDat().

454  {
455  if (AttrType != atInt && AttrType != atFlt && AttrType != atStr) {
456  return -1; // type must be defined and can only have a single type
457  }
458  AttrId = AttrNameToId.GetMxKeyIds();
459  TIntPr TypeAndId(AttrType, AttrId);
460  AttrNameToId.AddDat(Name, TypeAndId);
461  TIntStrPr TypeAndName(AttrType, Name);
462  AttrIdToName.AddDat(AttrId, TypeAndName);
463  return 0;
464 }
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
Definition: gbase.h:23
TStrIntPrH AttrNameToId
Definition: attr.h:92
int GetMxKeyIds() const
Definition: hash.h:189
Definition: ds.h:32
Definition: gbase.h:23
Definition: gbase.h:23
TDat & AddDat(const TKey &Key)
Definition: hash.h:196

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Definition at line 246 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().

246  {
247  TInt AttrId;
248  if (!AttrNameToId.IsKey(AttrName)) {
249  AddSAttr(AttrName, atInt, AttrId);
250  } else {
251  AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
252  }
253  return AddSAttrDat(Id, AttrId, Val);
254 }
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
Definition: gbase.h:23
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: dt.h:1044
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:454
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttrPair::AddSAttrDat ( const TIntPr Id,
const TInt AttrId,
const TInt Val 
)

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

Definition at line 255 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().

255  {
256  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
257  if (AttrIdToName.GetDat(AttrId).GetVal1() != atInt) { return -2; }
258  TIntIntPrPr Key(AttrId, Id);
259  IntAttrVals.AddDat(Key, Val);
260  return 0;
261 }
const TVal1 & GetVal1() const
Definition: ds.h:60
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
Definition: gbase.h:23
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196

Here is the call graph for this function:

int TAttrPair::AddSAttrDat ( const TIntPr Id,
const TStr AttrName,
const TFlt Val 
)

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

Definition at line 263 of file attr.cpp.

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

263  {
264  TInt AttrId;
265  if (!AttrNameToId.IsKey(AttrName)) {
266  AddSAttr(AttrName, atFlt, AttrId);
267  } else {
268  AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
269  }
270  return AddSAttrDat(Id, AttrId, Val);
271 }
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: dt.h:1044
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:454
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

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

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

Definition at line 272 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().

272  {
273  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
274  if (AttrIdToName.GetDat(AttrId).GetVal1() != atFlt) { return -2; }
275  TIntIntPrPr Key(AttrId, Id);
276  FltAttrVals.AddDat(Key, Val);
277  return 0;
278 }
const TVal1 & GetVal1() const
Definition: ds.h:60
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
Definition: ds.h:32
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196

Here is the call graph for this function:

int TAttrPair::AddSAttrDat ( const TIntPr Id,
const TStr AttrName,
const TStr Val 
)

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

Definition at line 280 of file attr.cpp.

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

280  {
281  TInt AttrId;
282  if (!AttrNameToId.IsKey(AttrName)) {
283  AddSAttr(AttrName, atStr, AttrId);
284  } else {
285  AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
286  }
287  return AddSAttrDat(Id, AttrId, Val);
288 }
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: dt.h:1044
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:454
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

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

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

Definition at line 289 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.

289  {
290  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
291  if (AttrIdToName.GetDat(AttrId).GetVal1() != atStr) { return -2; }
292  TIntIntPrPr Key(AttrId, Id);
293  StrAttrVals.AddDat(Key, Val);
294  return 0;
295 }
const TVal1 & GetVal1() const
Definition: ds.h:60
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
Definition: ds.h:32
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196

Here is the call graph for this function:

void TAttrPair::Clr ( )
inline

Clears the contents of the attribute map.

Definition at line 114 of file attr.h.

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

Referenced by TUndirNet::Clr(), and TDirNet::Clr().

TIntIntStrPrH AttrIdToName
Definition: attr.h:93
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TStrIntPrH AttrNameToId
Definition: attr.h:92
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:319

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttrPair::DelSAttrDat ( const TIntPr Id,
const TStr AttrName 
)

Delete attribute with name AttrName for the given id Id.

Definition at line 347 of file attr.cpp.

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

347  {
348  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
349  TInt AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
350  return DelSAttrDat(Id, AttrId);
351 }
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: dt.h:1044
int DelSAttrDat(const TIntPr &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:347
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

int TAttrPair::DelSAttrDat ( const TIntPr Id,
const TInt AttrId 
)

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

Definition at line 352 of file attr.cpp.

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

352  {
353  TIntIntPrPr Key(AttrId, Id);
354  if (IntAttrVals.IsKey(Key)) {
355  IntAttrVals.DelKey(Key);
356  return 0;
357  } else if (FltAttrVals.IsKey(Key)) {
358  FltAttrVals.DelKey(Key);
359  return 0;
360  } else if (StrAttrVals.IsKey(Key)) {
361  StrAttrVals.DelKey(Key);
362  return 0;
363  }
364  return -1;
365 }
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
void DelKey(const TKey &Key)
Definition: hash.h:362
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

void TAttrPair::DelSAttrId ( const TIntPr Id)

Delete all attributes for the given id Id.

Definition at line 368 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.

368  {
369  for (TStrIntPrH::TIter it = AttrNameToId.BegI(); it < AttrNameToId.EndI(); it++) {
370  TAttrType CurType = static_cast<TAttrType>(it.GetDat().GetVal1().Val);
371  TIntIntPrPr AttrKey(it.GetDat().GetVal2(), Id);
372  if (CurType == atInt) {
373  IntAttrVals.DelIfKey(AttrKey);
374  } else if (CurType == atFlt) {
375  FltAttrVals.DelIfKey(AttrKey);
376  } else if (CurType == atStr) {
377  StrAttrVals.DelIfKey(AttrKey);
378  }
379  }
380 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
TIter BegI() const
Definition: hash.h:171
TIter EndI() const
Definition: hash.h:176
Definition: gbase.h:23
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TStrIntPrH AttrNameToId
Definition: attr.h:92
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
Definition: ds.h:32
Definition: gbase.h:23
bool DelIfKey(const TKey &Key)
Definition: hash.h:201
Definition: gbase.h:23

Here is the call graph for this function:

int TAttrPair::GetIdVSAttr ( const TInt AttrId,
const TAttrType  Type,
TIntPrV IdV 
) const
private

Definition at line 411 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().

411  {
412  if (Type == atInt) {
413  for (TIntIntPrPrIntH::TIter it = IntAttrVals.BegI(); it < IntAttrVals.EndI(); it++) {
414  if (it.GetKey().GetVal1() == AttrId) {
415  IdV.Add(it.GetKey().GetVal2());
416  }
417  }
418  } else if (Type == atFlt) {
419  for (TIntIntPrPrFltH::TIter it = FltAttrVals.BegI(); it < FltAttrVals.EndI(); it++) {
420  if (it.GetKey().GetVal1() == AttrId) {
421  IdV.Add(it.GetKey().GetVal2());
422  }
423  }
424  } else if (Type == atStr) {
425  for (TIntIntPrPrStrH::TIter it = StrAttrVals.BegI(); it < StrAttrVals.EndI(); it++) {
426  if (it.GetKey().GetVal1() == AttrId) {
427  IdV.Add(it.GetKey().GetVal2());
428  }
429  }
430  } else {
431  return -1;
432  }
433  return 0;
434 }
TIter BegI() const
Definition: hash.h:171
TIter EndI() const
Definition: hash.h:176
Definition: gbase.h:23
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
Definition: gbase.h:23
Definition: gbase.h:23
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttrPair::GetIdVSAttr ( const TStr AttrName,
TIntPrV IdV 
) const

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

Definition at line 436 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().

436  {
437  IdV = TIntPrV();
438  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
439  TIntPr TypeAndId = AttrNameToId.GetDat(AttrName);
440  TAttrType Type = static_cast<TAttrType>(TypeAndId.GetVal1().Val);
441  TInt AttrId = TypeAndId.GetVal2();
442  return GetIdVSAttr(AttrId, Type, IdV);
443 }
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:220
TVec< TIntPr > TIntPrV
Definition: ds.h:1536
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: dt.h:1044
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntPrV &IdV) const
Definition: attr.cpp:411
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

int TAttrPair::GetIdVSAttr ( const TInt AttrId,
TIntPrV IdV 
) const

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

Definition at line 445 of file attr.cpp.

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

445  {
446  IdV = TIntPrV();
447  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
448  TIntStrPr TypeAndName = AttrIdToName.GetDat(AttrId);
449  TAttrType Type = static_cast<TAttrType>(TypeAndName.GetVal1().Val);
450  return GetIdVSAttr(AttrId, Type, IdV);
451 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
const TVal1 & GetVal1() const
Definition: ds.h:60
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntPr > TIntPrV
Definition: ds.h:1536
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntPrV &IdV) const
Definition: attr.cpp:411
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

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

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

Definition at line 298 of file attr.cpp.

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

Referenced by GetSAttrDat().

298  {
299  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
300  TInt AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
301  return GetSAttrDat(Id, AttrId, Val);
302 }
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: dt.h:1044
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

Here is the caller graph for this function:

int TAttrPair::GetSAttrDat ( const TIntPr Id,
const TInt AttrId,
TInt ValX 
) const

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

Definition at line 303 of file attr.cpp.

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

303  {
304  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
305  if (AttrIdToName.GetDat(AttrId).GetVal1() != atInt) { return -2; }
306  TIntIntPrPr Key(AttrId, Id);
307  if (IntAttrVals.IsKey(Key)) {
308  Val = IntAttrVals.GetDat(Key);
309  return 0;
310  }
311  return -1;
312 }
const TVal1 & GetVal1() const
Definition: ds.h:60
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
Definition: gbase.h:23
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

int TAttrPair::GetSAttrDat ( const TIntPr Id,
const TStr AttrName,
TFlt ValX 
) const

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

Definition at line 314 of file attr.cpp.

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

314  {
315  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
316  TInt AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
317  return GetSAttrDat(Id, AttrId, Val);
318 }
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: dt.h:1044
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

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

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

Definition at line 319 of file attr.cpp.

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

319  {
320  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
321  if (AttrIdToName.GetDat(AttrId).GetVal1() != atFlt) { return -2; }
322  TIntIntPrPr Key(AttrId, Id);
323  if (FltAttrVals.IsKey(Key)) {
324  Val = FltAttrVals.GetDat(Key);
325  return 0;
326  }
327  return -1;
328 }
const TVal1 & GetVal1() const
Definition: ds.h:60
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
Definition: ds.h:32
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

int TAttrPair::GetSAttrDat ( const TIntPr Id,
const TStr AttrName,
TStr ValX 
) const

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

Definition at line 330 of file attr.cpp.

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

330  {
331  if (!AttrNameToId.IsKey(AttrName)) { return -1; }
332  TInt AttrId = AttrNameToId.GetDat(AttrName).GetVal2();
333  return GetSAttrDat(Id, AttrId, Val);
334 }
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: dt.h:1044
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

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

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

Definition at line 335 of file attr.cpp.

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

335  {
336  if (!AttrIdToName.IsKey(AttrId)) { return -1; }
337  if (AttrIdToName.GetDat(AttrId).GetVal1() != atStr) { return -2; }
338  TIntIntPrPr Key(AttrId, Id);
339  if (StrAttrVals.IsKey(Key)) {
340  Val = StrAttrVals.GetDat(Key);
341  return 0;
342  }
343  return -1;
344 }
const TVal1 & GetVal1() const
Definition: ds.h:60
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
Definition: ds.h:32
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

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

Given the attribute name Name, get the attribute id and type.

Definition at line 467 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().

467  {
468  if (!AttrNameToId.IsKey(Name)) {
469  return -1;
470  }
471  TIntPr TypeAndId = AttrNameToId.GetDat(Name);
472  AttrType = static_cast<TAttrType>(TypeAndId.GetVal1().Val);
473  AttrId = TypeAndId.GetVal2();
474  return 0;
475 }
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:220
TStrIntPrH AttrNameToId
Definition: attr.h:92
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

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

Given the attribute id AttrId, get the attribute name and type.

Definition at line 477 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().

477  {
478  if (!AttrIdToName.IsKey(AttrId)) {
479  return -1;
480  }
481  TIntStrPr TypeAndName = AttrIdToName.GetDat(AttrId);
482  AttrType = static_cast<TAttrType>(TypeAndName.GetVal1().Val);
483  Name = TypeAndName.GetVal2();
484  return 0;
485 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
const TVal1 & GetVal1() const
Definition: ds.h:60
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
const TVal2 & GetVal2() const
Definition: ds.h:61
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
Definition: ds.h:32
bool IsKey(const TKey &Key) const
Definition: hash.h:216

Here is the call graph for this function:

void TAttrPair::GetSAttrV ( const TIntPr Id,
const TAttrType  AttrType,
TAttrPrV AttrV 
) const

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

Definition at line 383 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.

383  {
384  AttrV = TAttrPrV();
385  for (TStrIntPrH::TIter it = AttrNameToId.BegI(); it < AttrNameToId.EndI(); it++) {
386  TAttrType CurType = static_cast<TAttrType>(it.GetDat().GetVal1().Val);
387  if (CurType == AttrType) {
388  TIntIntPrPr AttrKey(it.GetDat().GetVal2(), Id);
389  if (CurType == atInt) {
390  if (IntAttrVals.IsKey(AttrKey)) {
391  TAttrPr Dat(it.GetKey(), CurType);
392  AttrV.Add(Dat);
393  }
394 
395  } else if (CurType == atFlt) {
396  if (FltAttrVals.IsKey(AttrKey)) {
397  TAttrPr Dat(it.GetKey(), CurType);
398  AttrV.Add(Dat);
399  }
400  } else if (CurType == atStr) {
401  if (StrAttrVals.IsKey(AttrKey)) {
402  TAttrPr Dat(it.GetKey(), CurType);
403  AttrV.Add(Dat);
404  }
405  }
406  }
407  }
408 }
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
TIter BegI() const
Definition: hash.h:171
TIter EndI() const
Definition: hash.h:176
Definition: gbase.h:23
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TStrIntPrH AttrNameToId
Definition: attr.h:92
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97
TVec< TAttrPr > TAttrPrV
Definition: attr.h:2
Definition: ds.h:32
Definition: gbase.h:23
Definition: gbase.h:23
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574

Here is the call graph for this function:

void TAttrPair::Save ( TSOut SOut) const
inline

Saves the attributes to a (binary) stream SOut.

Definition at line 110 of file attr.h.

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

Referenced by TUndirNet::Save(), and TDirNet::Save().

110  {
111  AttrNameToId.Save(SOut); AttrIdToName.Save(SOut);
112  IntAttrVals.Save(SOut); FltAttrVals.Save(SOut); StrAttrVals.Save(SOut); }
void Save(TSOut &SOut) const
Definition: hash.h:141
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:96
TStrIntPrH AttrNameToId
Definition: attr.h:92
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:97

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

TIntIntStrPrH TAttrPair::AttrIdToName
private

Definition at line 93 of file attr.h.

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

TStrIntPrH TAttrPair::AttrNameToId
private
TIntIntPrPrFltH TAttrPair::FltAttrVals
private

Definition at line 96 of file attr.h.

Referenced by AddSAttrDat(), Clr(), DelSAttrDat(), DelSAttrId(), GetIdVSAttr(), GetSAttrDat(), GetSAttrV(), and Save().

TIntIntPrPrIntH TAttrPair::IntAttrVals
private

Definition at line 95 of file attr.h.

Referenced by AddSAttrDat(), Clr(), DelSAttrDat(), DelSAttrId(), GetIdVSAttr(), GetSAttrDat(), GetSAttrV(), and Save().

TIntIntPrPrStrH TAttrPair::StrAttrVals
private

Definition at line 97 of file attr.h.

Referenced by AddSAttrDat(), Clr(), DelSAttrDat(), DelSAttrId(), GetIdVSAttr(), GetSAttrDat(), GetSAttrV(), and Save().


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