File: ActionQueue.h

package info (click to toggle)
pinot 1.05-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,848 kB
  • ctags: 3,572
  • sloc: cpp: 39,255; sh: 10,481; ansic: 3,049; makefile: 620; xml: 379
file content (70 lines) | stat: -rw-r--r-- 2,071 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 *  Copyright 2005-2010 Fabrice Colin
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _ACTION_QUEUE_H
#define _ACTION_QUEUE_H

#include <time.h>
#include <string>

#include "DocumentInfo.h"
#include "SQLiteBase.h"

/// Handles the ActionQueue table.
class ActionQueue : public SQLiteBase
{
	public:
		ActionQueue(const std::string &database, const std::string queueId);
		virtual ~ActionQueue();

		/// Creates the ActionQueue table in the database.
		static bool create(const std::string &database);

		typedef enum { INDEX = 0, UNINDEX } ActionType;

		/// Pushes an item.
		bool pushItem(ActionType type, const DocumentInfo &docInfo);

		/// Pops and deletes the oldest item.
		bool popItem(ActionType &type, DocumentInfo &docInfo);

		/// Returns the number of items of a particular type.
		unsigned int getItemsCount(ActionType type);

		/// Deletes all items under a given URL.
		bool deleteItems(const std::string &url);

		/// Expires items older than the given date.
		bool expireItems(time_t expiryDate);

        protected:
		std::string m_queueId;

		bool getOldestItem(ActionType &type, DocumentInfo &docInfo);

		static std::string typeToText(ActionType type);

		static ActionType textToType(const std::string &text);

        private:
		ActionQueue(const ActionQueue &other);
		ActionQueue &operator=(const ActionQueue &other);

};

#endif // _ACTION_QUEUE_H