void c4_Property::operator = (const c4_Property &prop_) { c4_ThreadLock::Hold lock; prop_.Refs( + 1); Refs( - 1); _id = prop_.GetId(); _type = prop_.Type(); }
c4_Property::c4_Property(const c4_Property &prop_): _id(prop_.GetId()), _type (prop_.Type()) { c4_ThreadLock::Hold lock; d4_assert(sPropCounts != 0); d4_assert(sPropCounts->GetAt(_id) > 0); Refs( + 1); }
unsigned Resource::GetUseTimer() { // If more references than the resource cache, return always 0 & reset the timer if (Refs() > 1) { useTimer_.Reset(); return 0; } else return useTimer_.GetMSec(false); }
c4_Property::c4_Property (char type_, const char* name_) : _type (type_) { if (sThreadLock == 0) sThreadLock = d4_new c4_ThreadLock; c4_ThreadLock::Hold lock; // grabs the lock until end of scope if (sPropNames == 0) sPropNames = d4_new c4_StringArray; if (sPropCounts == 0) sPropCounts = d4_new c4_DWordArray; c4_String temp = name_; _id = sPropNames->GetSize(); while (-- _id >= 0) { const char* p = sPropNames->GetAt(_id); // optimize for first char case-insensitive match if (((*p ^ *name_) & ~0x20) == 0 && temp.CompareNoCase(p) == 0) break; } if (_id < 0) { int size = sPropCounts->GetSize(); for (_id = 0; _id < size; ++_id) if (sPropCounts->GetAt(_id) == 0) break; if (_id >= size) { sPropCounts->SetSize(_id + 1); sPropNames->SetSize(_id + 1); } sPropCounts->SetAt(_id, 0); sPropNames->SetAt(_id, name_); } Refs(+1); }
void HashExtensible::load() { ifstream *file=new ifstream(this->filename.c_str()); std:string aux; Key_Node auxk= Key_Node(); while(!file->eof()) { getline(*file,aux); if ( aux.compare("Bucket_Capacity")==0) { getline(*file,aux); stringstream ssBucketcap(aux); ssBucketcap>>this->bucketCapacity; this->buckets= Buckets(this->bucketCapacity); } if ( aux.compare("Begin_Key_Node")==0) { auxk.DesSerialize(file); } if ( aux.compare("Value")==0) { getline(*file,aux); stringstream ss(aux); Refs auxRef= Refs(ss.str()); add(auxk,auxRef); auxk= Key_Node(); } }
c4_Property::~c4_Property () { c4_ThreadLock::Hold lock; Refs(-1); }
int Index::PutRef(std::vector<Field> inFields,ref Value){ Key_Node K= Key_Node(); for (int i=0; i<inFields.size();i++){ Field FAux=inFields.at(i); K.AddField(FAux); } bool Primario= (this->tIndexType==GRIEGO); if (IndexType==HASH) { HashExtensible Hash= HashExtensible(GetFileNameHash(this->IndexName,this->TableName)); Refs * auxRefs= Hash.get(K); if (!Primario) { (*auxRefs).vRefs.push_back(Value); } else { if (auxRefs==NULL) { Refs addRef= Refs(); addRef.vRefs.push_back(Value); Hash.add(K,addRef); } else return 1; } Hash.save(); } if (IndexType==BPTREE) { Bp_Tree btree= Bp_Tree(GetFileNameBtree(this->IndexName,this->TableName)); int ret; Key_Node *auxKey = new Key_Node(); *auxKey=K; ret = btree.get_key(*auxKey); if (!Primario) { (*auxKey).ref.vRefs.push_back(Value); } else { if (ret==1) { Refs addRef= Refs(); addRef.vRefs.push_back(Value); *auxKey=K; (*auxKey).ref=addRef; btree.add_key(*auxKey,true); } else return 1; } btree.save(); } return 0; }