2018-04-19 14:46:43 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "../acl_cpp_define.hpp"
|
|
|
|
|
#include <list>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "noncopyable.hpp"
|
|
|
|
|
|
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class diff_object;
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵIJ<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
*/
|
|
|
|
|
class diff_manager : public noncopyable
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
diff_manager(long long range_from = -1, long long range_to = -1);
|
|
|
|
|
~diff_manager(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {dbuf_guard&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ø<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>ش<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> diff_manager <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>٣<EFBFBD><EFBFBD><EFBFBD>Ϊ diff_manager <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>ػ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
*/
|
|
|
|
|
dbuf_guard& get_dbuf(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD>Ƚ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵIJ<EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>ϡ<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>Լ<EFBFBD><EFBFBD>仯<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param curr_objs {const std::vector<diff_object*>&} <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param old_olds {const std::list<diff_object*>&} <EFBFBD><EFBFBD>Ԫ<EFBFBD>ؼ<EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ڲ<EFBFBD>
|
|
|
|
|
* <EFBFBD>øü<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>þɼ<EFBFBD><EFBFBD>Ͻ<EFBFBD><EFBFBD>в<EFBFBD><EFBFBD>컯<EFBFBD>Ƚ<EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
*/
|
|
|
|
|
void diff_changes(const std::vector<diff_object*>& curr_objs,
|
|
|
|
|
const std::vector<diff_object*>& old_olds);
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
* @return {std::vector<diff_object*>&}
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<diff_object*>& get_new(void) const
|
|
|
|
|
{
|
|
|
|
|
return objs_new_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> diff_changes <EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD>컯<EFBFBD>Ƚϳɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھɼ<EFBFBD><EFBFBD>ϣ<EFBFBD>
|
|
|
|
|
* <EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>Ԫ<EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
* @return {std::vector<diff_object*>&}
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<diff_object*>& get_deleted(void) const
|
|
|
|
|
{
|
|
|
|
|
return objs_del_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> diff_changes <EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD>컯<EFBFBD>Ƚϳɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھɼ<EFBFBD><EFBFBD>ϣ<EFBFBD>
|
|
|
|
|
* <EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD>ı仯<EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
* @return {std::vector<std::pair<diff_object*, diff_object*> >&}
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pair <EFBFBD>е<EFBFBD> first Ϊ<EFBFBD>¶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>second
|
|
|
|
|
* Ϊ<EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
* @sample
|
|
|
|
|
* const std::vector<std::pair<diff_object*, diff_object*> >&
|
|
|
|
|
* results = manager.get_updated();
|
|
|
|
|
* std::vector<std::pair<diff_object*, diff_object*> >::const_iterator
|
|
|
|
|
* cit = results.begin();
|
|
|
|
|
* for (; cit != results.end(); ++cit)
|
|
|
|
|
* printf(">> key: %s, curr value:%s, old value: %s\r\n",
|
|
|
|
|
* (*cit).first->get_key(),
|
|
|
|
|
* (*cit).first->get_val(),
|
|
|
|
|
* (*cit).second->get_val());
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<std::pair<diff_object*, diff_object*> >&
|
|
|
|
|
get_updated(void) const
|
|
|
|
|
{
|
|
|
|
|
return objs_upd_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> diff_manger <EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD>컪<EFBFBD>Ƚϳɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
* @return {std::vector<diff_object*>&}
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<diff_object*>& get_same(void) const
|
|
|
|
|
{
|
|
|
|
|
return objs_equ_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䷶Χ<EFBFBD>ڵĶ<EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
* @return {const std::vector<diff_object*>&}
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<diff_object*>& get_extra_added(void) const
|
|
|
|
|
{
|
|
|
|
|
return objs_new_extra_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䷶Χ<EFBFBD>ڵĶ<EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
* @return {const std::vector<diff_object*>&}
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<diff_object*>& get_extra_deleted(void) const
|
|
|
|
|
{
|
|
|
|
|
return objs_del_extra_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵIJ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䷶Χ<EFBFBD>ڵĶ<EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
* @return {const std::vector<diff_object*>&}
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<std::pair<diff_object*, diff_object*> >&
|
|
|
|
|
get_extra_updated(void) const
|
|
|
|
|
{
|
|
|
|
|
return objs_upd_extra_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-04-19 15:33:16 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>ʹ<EFBFBD>ñ<EFBFBD> diff_manager <EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD>컯<EFBFBD>Ƚ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD>һ<EFBFBD>αȽϹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ڴ漰<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
*/
|
|
|
|
|
void reset(void);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
dbuf_guard dbuf_;
|
|
|
|
|
long long range_from_;
|
|
|
|
|
long long range_to_;
|
|
|
|
|
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// <20><>ͬ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
std::vector<diff_object*> objs_equ_;
|
|
|
|
|
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// <20>仯<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
std::vector<diff_object*> objs_new_;
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// ɾ<><C9BE><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
std::vector<diff_object*> objs_del_;
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// <20>ĵĶ<C4B5><C4B6><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
std::vector<std::pair<diff_object*, diff_object*> > objs_upd_;
|
|
|
|
|
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
std::vector<diff_object*> objs_new_extra_;
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// ɾ<><C9BE><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
std::vector<diff_object*> objs_del_extra_;
|
2018-04-19 15:33:16 +08:00
|
|
|
|
// <20>ĵĶ<C4B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-04-19 14:46:43 +08:00
|
|
|
|
std::vector<std::pair<diff_object*, diff_object*> > objs_upd_extra_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|