File: VCard.h

package info (click to toggle)
granule 1.4.0-7-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 5,236 kB
  • ctags: 2,144
  • sloc: cpp: 16,030; makefile: 353
file content (114 lines) | stat: -rw-r--r-- 3,070 bytes parent folder | download | duplicates (5)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// -*- c++ -*-
//------------------------------------------------------------------------------
//                              VCard.h
//------------------------------------------------------------------------------
// $Id: VCard.h,v 1.13 2008/01/14 03:41:00 vlg Exp $
//
// Date: Apr 24 2004
//------------------------------------------------------------------------------
#ifndef VCARD_H
#define VCARD_H

#include <string>
using std::string;

#include <glibmm/ustring.h>
using Glib::ustring;

#include <assa/TimeVal.h>

#include "Granule-main.h"

class VCard 
{
public:
	VCard () : m_dirty (false), m_reversed (false) { /* no-op */ }
	virtual ~VCard () { /* no-op */ }

	virtual void set_question     (const ustring& q_) = 0;
	virtual void set_image_path   (const ustring& p_) = 0;
	virtual void set_answer       (const ustring& a_) = 0;
	virtual void set_example      (const ustring& e_) = 0;
	virtual void set_example_image_path   (const ustring& p_) = 0;
	virtual void set_alt_spelling (SideSelection side_,
								   const ustring& a_) = 0;

	virtual ustring  get_question     () const = 0;
	virtual ustring  get_image_path   () const = 0;
	virtual ustring  get_deck_path    () const = 0;
	virtual ustring  get_answer       () const = 0;
	virtual ustring  get_example      () const = 0;
	virtual ustring  get_example_image_path   () const = 0;
	virtual ustring  get_alt_spelling (SideSelection side_) const = 0;
	virtual long     get_id           () const = 0;

	virtual PathMode image_path_mode  () const = 0;

	void set_reversed (bool r_) { m_reversed = r_;   }
	bool get_reversed () const  { return m_reversed; }

	virtual void set_expiration (const ASSA::TimeVal&) { /* no-op */ }
	virtual ASSA::TimeVal get_expiration () const;

	void mark_dirty   () { m_dirty = true; }
	void mark_clean   () { m_dirty = false; }
	bool is_dirty     () const { return m_dirty; }
	string get_id_str ();
	
	/** For CardRef only, reschedule based on answer.
	 */
	virtual void reschedule (AnswerQuality answer_quality_) { /* no-op */ }

	/** CardRef returns scheduled interval.
	 */
	virtual int get_interval () const { return 0; }

	/**
	 * @param cw_ratio_ Success/Fail ratio expressed in numbers. 
	 * @return succcess ratio based on its statistics in percent form.
	 */
	virtual string get_success_ratio (string& cw_ratio_) const 
	{ 
		cw_ratio_ = "0/0"; 
		return "n/a"; 
	}

	virtual void dump () const = 0;

	/** Comparison by the expiration date
	 */
	bool operator<  (const VCard& rhs_);
	bool operator== (const VCard& rhs_);

protected:
	virtual bool less_then_expiration (const VCard& rhs_) = 0;
	virtual bool equal_expiration (const VCard& rhs_) = 0;

protected:
	/// Has the card being modified?
	bool m_dirty;

	/// Is this card backward-oriented?
	bool m_reversed;
};

inline bool
VCard::
operator< (const VCard& rhs_)
{
	return (less_then_expiration (rhs_));
}

inline bool
VCard::
operator== (const VCard& rhs_)
{
	return (equal_expiration (rhs_));
}

inline ASSA::TimeVal VCard::get_expiration () const
{
	return (ASSA::TimeVal (0));
}

#endif /* VCARD_H */