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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -30,7 +30,8 @@ var protected AcediaObject resultObject;
protected function DBReadingHandler( protected function DBReadingHandler(
Database.DBQueryResult result, Database.DBQueryResult result,
AcediaObject data) AcediaObject data,
Database source)
{ {
default.resultType = result; default.resultType = result;
default.resultObject = data; default.resultObject = data;
@ -39,7 +40,8 @@ protected function DBReadingHandler(
protected function DBKeysHandler( protected function DBKeysHandler(
Database.DBQueryResult result, Database.DBQueryResult result,
DynamicArray keys) DynamicArray keys,
Database source)
{ {
default.resultType = result; default.resultType = result;
default.resultKeys = keys; default.resultKeys = keys;
@ -47,7 +49,8 @@ protected function DBKeysHandler(
protected function DBCheckHandler( protected function DBCheckHandler(
Database.DBQueryResult result, Database.DBQueryResult result,
Database.DataType type) Database.DataType type,
Database source)
{ {
default.resultType = result; default.resultType = result;
default.resultDataType = type; default.resultDataType = type;
@ -55,23 +58,30 @@ protected function DBCheckHandler(
protected function DBSizeHandler( protected function DBSizeHandler(
Database.DBQueryResult result, Database.DBQueryResult result,
int size) int size,
Database source)
{ {
default.resultType = result; default.resultType = result;
default.resultSize = size; default.resultSize = size;
} }
protected function DBWritingHandler(Database.DBQueryResult result) protected function DBWritingHandler(
Database.DBQueryResult result,
Database source)
{ {
default.resultType = result; default.resultType = result;
} }
protected function DBIncrementHandler(Database.DBQueryResult result) protected function DBIncrementHandler(
Database.DBQueryResult result,
Database source)
{ {
default.resultType = result; default.resultType = result;
} }
protected function DBRemoveHandler(Database.DBQueryResult result) protected function DBRemoveHandler(
Database.DBQueryResult result,
Database source)
{ {
default.resultType = result; default.resultType = result;
} }

Loading…
Cancel
Save