Browse Source

Add `Database` reference to db query replies

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
8e32e550bd
  1. 9
      sources/Data/Database/DBTask.uc
  2. 9
      sources/Data/Database/Tasks/DBCheckTask.uc
  3. 6
      sources/Data/Database/Tasks/DBIncrementTask.uc
  4. 9
      sources/Data/Database/Tasks/DBKeysTask.uc
  5. 9
      sources/Data/Database/Tasks/DBReadTask.uc
  6. 6
      sources/Data/Database/Tasks/DBRemoveTask.uc
  7. 6
      sources/Data/Database/Tasks/DBSizeTask.uc
  8. 6
      sources/Data/Database/Tasks/DBWriteTask.uc
  9. 32
      sources/Data/Database/Tests/TEST_LocalDatabase.uc

9
sources/Data/Database/DBTask.uc

@ -118,14 +118,17 @@ public final function SetResult(Database.DBQueryResult result)
* Since this base class does not itself have `connect()` delegate declared -
* this method cannot be implemented here.
*/
protected function CompleteSelf() {}
protected function CompleteSelf(Database source) {}
/**
* Attempts to complete this task.
* Can only succeed iff caller task both has necessary data to complete it's
* query and all previous tasks have completed.
*
* @param source Database that will be passed to `DBTask`'s delegate as
* its cause.
*/
public final function TryCompleting()
public final function TryCompleting(optional Database source)
{
local int i;
local array<DBTask> tasksQueue;
@ -136,7 +139,7 @@ public final function TryCompleting()
{
if (tasksQueue[i].isReadyToComplete)
{
tasksQueue[i].CompleteSelf();
tasksQueue[i].CompleteSelf(source);
_.memory.Free(tasksQueue[i]);
}
else {

9
sources/Data/Database/Tasks/DBCheckTask.uc

@ -21,7 +21,10 @@ class DBCheckTask extends DBTask;
var private Database.DataType queryTypeResponse;
delegate connect(Database.DBQueryResult result, Database.DataType type) {}
delegate connect(
Database.DBQueryResult result,
Database.DataType type,
Database source) {}
protected function Finalizer()
{
@ -35,9 +38,9 @@ public function SetDataType(Database.DataType type)
queryTypeResponse = type;
}
protected function CompleteSelf()
protected function CompleteSelf(Database source)
{
connect(GetResult(), queryTypeResponse);
connect(GetResult(), queryTypeResponse, source);
}
defaultproperties

6
sources/Data/Database/Tasks/DBIncrementTask.uc

@ -19,7 +19,7 @@
*/
class DBIncrementTask extends DBTask;
delegate connect(Database.DBQueryResult result) {}
delegate connect(Database.DBQueryResult result, Database source) {}
protected function Finalizer()
{
@ -27,9 +27,9 @@ protected function Finalizer()
connect = none;
}
protected function CompleteSelf()
protected function CompleteSelf(Database source)
{
connect(GetResult());
connect(GetResult(), source);
}
defaultproperties

9
sources/Data/Database/Tasks/DBKeysTask.uc

@ -21,7 +21,10 @@ class DBKeysTask extends DBTask;
var private DynamicArray queryKeysResponse;
delegate connect(Database.DBQueryResult result, DynamicArray keys) {}
delegate connect(
Database.DBQueryResult result,
DynamicArray keys,
Database source) {}
protected function Finalizer()
{
@ -35,9 +38,9 @@ public function SetDataKeys(DynamicArray keys)
queryKeysResponse = keys;
}
protected function CompleteSelf()
protected function CompleteSelf(Database source)
{
connect(GetResult(), queryKeysResponse);
connect(GetResult(), queryKeysResponse, source);
}
defaultproperties

9
sources/Data/Database/Tasks/DBReadTask.uc

@ -21,7 +21,10 @@ class DBReadTask extends DBTask;
var private AcediaObject queryDataResponse;
delegate connect(Database.DBQueryResult result, AcediaObject data) {}
delegate connect(
Database.DBQueryResult result,
AcediaObject data,
Database source) {}
protected function Finalizer()
{
@ -35,9 +38,9 @@ public function SetReadData(AcediaObject data)
queryDataResponse = data;
}
protected function CompleteSelf()
protected function CompleteSelf(Database source)
{
connect(GetResult(), queryDataResponse);
connect(GetResult(), queryDataResponse, source);
}
defaultproperties

6
sources/Data/Database/Tasks/DBRemoveTask.uc

@ -19,7 +19,7 @@
*/
class DBRemoveTask extends DBTask;
delegate connect(Database.DBQueryResult result) {}
delegate connect(Database.DBQueryResult result, Database source) {}
protected function Finalizer()
{
@ -27,9 +27,9 @@ protected function Finalizer()
connect = none;
}
protected function CompleteSelf()
protected function CompleteSelf(Database source)
{
connect(GetResult());
connect(GetResult(), source);
}
defaultproperties

6
sources/Data/Database/Tasks/DBSizeTask.uc

@ -21,7 +21,7 @@ class DBSizeTask extends DBTask;
var private int querySizeResponse;
delegate connect(Database.DBQueryResult result, int size) {}
delegate connect(Database.DBQueryResult result, int size, Database source) {}
protected function Finalizer()
{
@ -35,9 +35,9 @@ public function SetDataSize(int size)
querySizeResponse = size;
}
protected function CompleteSelf()
protected function CompleteSelf(Database source)
{
connect(GetResult(), querySizeResponse);
connect(GetResult(), querySizeResponse, source);
}
defaultproperties

6
sources/Data/Database/Tasks/DBWriteTask.uc

@ -19,7 +19,7 @@
*/
class DBWriteTask extends DBTask;
delegate connect(Database.DBQueryResult result) {}
delegate connect(Database.DBQueryResult result, Database source) {}
protected function Finalizer()
{
@ -27,9 +27,9 @@ protected function Finalizer()
connect = none;
}
protected function CompleteSelf()
protected function CompleteSelf(Database source)
{
connect(GetResult());
connect(GetResult(), source);
}
defaultproperties

32
sources/Data/Database/Tests/TEST_LocalDatabase.uc

@ -29,8 +29,9 @@ var protected AssociativeArray resultData;
var protected AcediaObject resultObject;
protected function DBReadingHandler(
Database.DBQueryResult result,
AcediaObject data)
Database.DBQueryResult result,
AcediaObject data,
Database source)
{
default.resultType = result;
default.resultObject = data;
@ -38,40 +39,49 @@ protected function DBReadingHandler(
}
protected function DBKeysHandler(
Database.DBQueryResult result,
DynamicArray keys)
Database.DBQueryResult result,
DynamicArray keys,
Database source)
{
default.resultType = result;
default.resultKeys = keys;
}
protected function DBCheckHandler(
Database.DBQueryResult result,
Database.DataType type)
Database.DBQueryResult result,
Database.DataType type,
Database source)
{
default.resultType = result;
default.resultDataType = type;
}
protected function DBSizeHandler(
Database.DBQueryResult result,
int size)
Database.DBQueryResult result,
int size,
Database source)
{
default.resultType = result;
default.resultSize = size;
}
protected function DBWritingHandler(Database.DBQueryResult result)
protected function DBWritingHandler(
Database.DBQueryResult result,
Database source)
{
default.resultType = result;
}
protected function DBIncrementHandler(Database.DBQueryResult result)
protected function DBIncrementHandler(
Database.DBQueryResult result,
Database source)
{
default.resultType = result;
}
protected function DBRemoveHandler(Database.DBQueryResult result)
protected function DBRemoveHandler(
Database.DBQueryResult result,
Database source)
{
default.resultType = result;
}

Loading…
Cancel
Save