diff options
author | Peng Wu <alexepico@gmail.com> | 2012-03-21 13:57:01 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-03-21 13:57:01 +0800 |
commit | da357461c31dc73724eaae962742a00c21bed2a4 (patch) | |
tree | 9b66e8892d09d4d3914b9d193bc5b8434b22a5f0 /src/storage/phrase_index_logger.h | |
parent | 1da6d4af67bd5c9793030e307adde1f0b49b4a83 (diff) | |
download | libpinyin-da357461c31dc73724eaae962742a00c21bed2a4.tar.gz libpinyin-da357461c31dc73724eaae962742a00c21bed2a4.tar.xz libpinyin-da357461c31dc73724eaae962742a00c21bed2a4.zip |
add comments
Diffstat (limited to 'src/storage/phrase_index_logger.h')
-rw-r--r-- | src/storage/phrase_index_logger.h | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/src/storage/phrase_index_logger.h b/src/storage/phrase_index_logger.h index 7052715..fe6070f 100644 --- a/src/storage/phrase_index_logger.h +++ b/src/storage/phrase_index_logger.h @@ -48,6 +48,13 @@ enum LOG_TYPE{ LOG_MODIFY_HEADER }; + +/** + * PhraseIndexLogger: + * + * The logger of phrase index changes. + * + */ class PhraseIndexLogger{ protected: MemoryChunk * m_chunk; @@ -61,35 +68,88 @@ protected: m_offset = 0; } public: + /** + * PhraseIndexLogger::PhraseIndexLogger: + * + * The constructor of the PhraseIndexLogger. + * + */ PhraseIndexLogger():m_offset(0){ m_chunk = new MemoryChunk; } + /** + * PhraseIndexLogger::~PhraseIndexLogger: + * + * The destructor of the PhraseIndexLogger. + * + */ ~PhraseIndexLogger(){ reset(); } + /** + * PhraseIndexLogger::load: + * @chunk: the memory chunk of the logs. + * @returns: whether the load operation is successful. + * + * Load the logs from the memory chunk. + * + */ bool load(MemoryChunk * chunk) { reset(); m_chunk = chunk; return true; } + /** + * PhraseIndexLogger::store: + * @new_chunk: the new memory chunk to store the logs. + * @returns: whether the store operation is successful. + * + * Store the logs to the new memory chunk. + * + */ bool store(MemoryChunk * new_chunk){ new_chunk->set_content(0, m_chunk->begin(), m_chunk->size()); return true; } + /** + * PhraseIndexLogger::has_next_record: + * @returns: whether this logger has next record. + * + * Whether this logger has next record. + * + */ bool has_next_record(){ return m_offset < m_chunk->size(); } + /** + * PhraseIndexLogger::rewind: + * @returns: whether the rewind operation is successful. + * + * Rewind this logger to the begin of logs. + * + */ bool rewind(){ m_offset = 0; return true; } - /* prolog: has_next_record() returned true. */ + /** + * PhraseIndexLogger::next_record: + * @log_type: the type of this log record. + * @token: the token of this log record. + * @oldone: the original content of the phrase item. + * @newone: the new content of the phrase item. + * + * Read the next log record. + * + * Prolog: has_next_record() returned true. + * + */ bool next_record(LOG_TYPE & log_type, phrase_token_t & token, MemoryChunk * oldone, MemoryChunk * newone){ size_t offset = m_offset; @@ -151,6 +211,16 @@ public: return true; } + /** + * PhraseIndexLogger::append_record: + * @log_type: the type of this log record. + * @token: the token of this log record. + * @oldone: the original content of the phrase item. + * @newone: the new content of the phrase item. + * + * Append one log record to the logger. + * + */ bool append_record(LOG_TYPE log_type, phrase_token_t token, MemoryChunk * oldone, MemoryChunk * newone){ |