/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2012, Tomasz Sowa * All rights reserved. * */ #ifndef headerfile_winix_core_ipbancontainer #define headerfile_winix_core_ipbancontainer #include #include "ipban.h" class IPBanContainer { public: IPBanContainer(); IPBan & AddIP(int ip); IPBan * FindIP(int ip); void Sort(); size_t Size(); IPBan & GetIPBan(size_t index); void SetMaxSize(size_t soft_size, size_t size); private: std::vector ipban_tab; bool is_ipban_tab_sorted; size_t soft_max_size, max_size; std::vector sort_helper_tab; static bool SortIPBansFunction(const IPBan & ip1, const IPBan & ip2); void RemoveOldRecords(); void PrintTab(); void PrintTab2(); struct SortByLastUsedHelper { IPBanContainer * container; SortByLastUsedHelper(IPBanContainer * c) : container(c) {} bool operator()(size_t index1, size_t index2); }; }; #endif