mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Use typed queries
This commit is contained in:
parent
fa82a8bcce
commit
1e2236afdc
@ -17,14 +17,18 @@ public:
|
|||||||
m_queriesNew.push_back(query);
|
m_queriesNew.push_back(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
QofFakeQuery* requestQuery()
|
QofFakeQuery* requestQuery(QofIdTypeConst obj_type)
|
||||||
{
|
{
|
||||||
QofFakeQuery* query = nullptr;
|
QofFakeQuery* query = nullptr;
|
||||||
|
|
||||||
if (!m_queriesNew.empty())
|
auto it = std::find_if(m_queriesNew.begin(), m_queriesNew.end(),
|
||||||
|
[obj_type](QofFakeQuery const* query) {
|
||||||
|
return (g_strcmp0(query->m_obj_type, obj_type) == 0);
|
||||||
|
});
|
||||||
|
if (it != m_queriesNew.end())
|
||||||
{
|
{
|
||||||
query = m_queriesNew.front();
|
query = *it;
|
||||||
m_queriesNew.pop_front();
|
m_queriesNew.erase(it);
|
||||||
m_queriesUsed.push_back(query);
|
m_queriesUsed.push_back(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +76,8 @@ private:
|
|||||||
|
|
||||||
/* class QofFakeQuery */
|
/* class QofFakeQuery */
|
||||||
|
|
||||||
QofFakeQuery::QofFakeQuery()
|
QofFakeQuery::QofFakeQuery(QofIdTypeConst obj_type) :
|
||||||
|
m_obj_type(obj_type)
|
||||||
{
|
{
|
||||||
queryPool.addQuery(this);
|
queryPool.addQuery(this);
|
||||||
}
|
}
|
||||||
@ -89,7 +94,7 @@ QofFakeQuery::~QofFakeQuery()
|
|||||||
QofQuery *
|
QofQuery *
|
||||||
qof_query_create_for (QofIdTypeConst obj_type)
|
qof_query_create_for (QofIdTypeConst obj_type)
|
||||||
{
|
{
|
||||||
return (QofQuery*)queryPool.requestQuery();
|
return (QofQuery*)queryPool.requestQuery(obj_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -15,14 +15,15 @@ extern "C"
|
|||||||
class QofFakeQuery
|
class QofFakeQuery
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QofFakeQuery();
|
QofFakeQuery(QofIdTypeConst obj_type);
|
||||||
~QofFakeQuery();
|
~QofFakeQuery();
|
||||||
|
|
||||||
MOCK_METHOD1(setBook, void(QofBook*));
|
MOCK_METHOD1(setBook, void(QofBook*));
|
||||||
MOCK_METHOD5(addDateMatchTT, void(gboolean, time64, gboolean, time64, QofQueryOp));
|
MOCK_METHOD5(addDateMatchTT, void(gboolean, time64, gboolean, time64, QofQueryOp));
|
||||||
MOCK_METHOD2(addSingleAccountMatch, void(Account*, QofQueryOp));
|
MOCK_METHOD2(addSingleAccountMatch, void(Account*, QofQueryOp));
|
||||||
MOCK_METHOD0(run, std::vector<void*>());
|
MOCK_METHOD0(run, std::vector<void*>());
|
||||||
|
|
||||||
|
QofIdTypeConst m_obj_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user