Overview of triggers extended with function name and arguments.
Did a lot of refactoring on the catalog to keep things clean.
This commit is contained in:
parent
35813ae926
commit
fcb191f2cc
44 changed files with 797 additions and 404 deletions
|
|
@ -11,25 +11,30 @@
|
|||
|
||||
class PgDatabaseCatalog;
|
||||
|
||||
class IPgContainter {
|
||||
class IPgContainer {
|
||||
public:
|
||||
virtual ~IPgContainter() = default;
|
||||
IPgContainer(PgDatabaseCatalog& cat);
|
||||
virtual ~IPgContainer() = default;
|
||||
|
||||
virtual std::string getLoadQuery() const = 0;
|
||||
virtual void load(const Pgsql::Result &res) = 0;
|
||||
|
||||
bool minimumVersion(int required_version) const;
|
||||
protected:
|
||||
PgDatabaseCatalog& m_catalog;
|
||||
};
|
||||
|
||||
template<typename T, typename K=Oid>
|
||||
class PgContainer: public IPgContainter {
|
||||
class PgContainer: public IPgContainer {
|
||||
public:
|
||||
using t_Container = std::vector<T>; ///< Do not assume it will stay a vector only expect bidirectional access
|
||||
|
||||
PgContainer() = default;
|
||||
|
||||
explicit PgContainer(std::weak_ptr<PgDatabaseCatalog> cat)
|
||||
: m_catalogue(cat)
|
||||
{}
|
||||
|
||||
explicit PgContainer(PgDatabaseCatalog& cat)
|
||||
: IPgContainer(cat)
|
||||
{
|
||||
}
|
||||
|
||||
typename t_Container::const_iterator begin() const
|
||||
{
|
||||
|
|
@ -46,30 +51,34 @@ public:
|
|||
m_container.clear();
|
||||
}
|
||||
|
||||
int count() const
|
||||
size_t count() const
|
||||
{
|
||||
return (int)m_container.size();
|
||||
return m_container.size();
|
||||
}
|
||||
|
||||
const T& getByKey(const K &key) const
|
||||
const T* getByKey(const K &key) const
|
||||
{
|
||||
auto lb_result = std::lower_bound(m_container.begin(), m_container.end(), key);
|
||||
if (lb_result != m_container.end() && *lb_result == key)
|
||||
return *lb_result;
|
||||
return &*lb_result;
|
||||
|
||||
return m_invalidInstance;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const T& getByName(const QString &name) const
|
||||
const T* getByName(const QString &name) const
|
||||
{
|
||||
auto find_res = std::find(m_container.begin(), m_container.end(), name);
|
||||
|
||||
if (find_res != m_container.end())
|
||||
return *find_res;
|
||||
return &*find_res;
|
||||
|
||||
return m_invalidInstance;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// Retrieve element by index
|
||||
///
|
||||
/// This function throws when idx is out of range
|
||||
/// otherwise it always returns a valid object.
|
||||
const T& getByIdx(int idx) const
|
||||
{
|
||||
return m_container.at(idx);
|
||||
|
|
@ -97,22 +106,19 @@ public:
|
|||
std::sort(m_container.begin(), m_container.end());
|
||||
}
|
||||
protected:
|
||||
std::weak_ptr<PgDatabaseCatalog> m_catalogue;
|
||||
t_Container m_container;
|
||||
|
||||
/** Override the implementation for this function to implement loading of single row.
|
||||
*
|
||||
* When overriding this function there is no need to override load.
|
||||
*/
|
||||
virtual T loadElem(const Pgsql::Row &) { return m_invalidInstance; }
|
||||
private:
|
||||
T m_invalidInstance;
|
||||
virtual T loadElem(const Pgsql::Row &) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<typename T, typename K=Oid>
|
||||
class PgSPtrContainer: public IPgContainter {
|
||||
class PgSPtrContainer: public IPgContainer {
|
||||
public:
|
||||
using t_Elem = std::shared_ptr<T>;
|
||||
using t_Container = std::vector<t_Elem>; ///< Do not assume it will stay a vector only expect bidirectional access
|
||||
|
|
@ -148,7 +154,7 @@ public:
|
|||
if (lb_result != m_container.end() && **lb_result == key)
|
||||
return *lb_result;
|
||||
|
||||
return m_invalidInstance;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const t_Elem getByName(const QString name) const
|
||||
|
|
@ -159,7 +165,7 @@ public:
|
|||
if (find_res != m_container.end())
|
||||
return *find_res;
|
||||
|
||||
return m_invalidInstance;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const t_Elem getByIdx(int idx) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue