acl/lib_acl_cpp/include/acl_cpp/stdlib/diff_manager.hpp

152 lines
3.8 KiB
C++
Raw Normal View History

#pragma once
#include "../acl_cpp_define.hpp"
#include <list>
#include <vector>
#include "noncopyable.hpp"
namespace acl
{
class diff_object;
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵIJ<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
class diff_manager : public noncopyable
{
public:
diff_manager(long long range_from = -1, long long range_to = -1);
~diff_manager(void);
/**
* <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>
*/
dbuf_guard& get_dbuf(void);
/**
* <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>
*/
void diff_changes(const std::vector<diff_object*>& curr_objs,
const std::vector<diff_object*>& old_olds);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>󼯺<EFBFBD>
* @return {std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_new(void) const
{
return objs_new_;
}
/**
* <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>
* @return {std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_deleted(void) const
{
return objs_del_;
}
/**
* <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>
* @return {std::vector<std::pair<diff_object*, diff_object*> >&}
* <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>
* @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_;
}
/**
* <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>
* @return {std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_same(void) const
{
return objs_equ_;
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD>ڵĶ<EFBFBD><EFBFBD>󼯺<EFBFBD>
* @return {const std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_extra_added(void) const
{
return objs_new_extra_;
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD>ڵĶ<EFBFBD><EFBFBD>󼯺<EFBFBD>
* @return {const std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_extra_deleted(void) const
{
return objs_del_extra_;
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĵIJ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD>ڵĶ<EFBFBD><EFBFBD>󼯺<EFBFBD>
* @return {const std::vector<diff_object*>&}
*/
const std::vector<std::pair<diff_object*, diff_object*> >&
get_extra_updated(void) const
{
return objs_upd_extra_;
}
/**
* <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>
*/
void reset(void);
private:
dbuf_guard dbuf_;
long long range_from_;
long long range_to_;
// <20><>ͬ<EFBFBD>Ķ<EFBFBD><C4B6>󼯺<EFBFBD>
std::vector<diff_object*> objs_equ_;
// <20><EFBFBD>Ķ<EFBFBD><C4B6>󼯺<EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6>󼯺<EFBFBD>
std::vector<diff_object*> objs_new_;
// ɾ<><C9BE><EFBFBD>Ķ<EFBFBD><C4B6>󼯺<EFBFBD>
std::vector<diff_object*> objs_del_;
// <20>޸ĵĶ<C4B5><C4B6>󼯺<EFBFBD>
std::vector<std::pair<diff_object*, diff_object*> > objs_upd_;
// <20><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6>󼯺<EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󼯺<EFBFBD>
std::vector<diff_object*> objs_new_extra_;
// ɾ<><C9BE><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󼯺<EFBFBD>
std::vector<diff_object*> objs_del_extra_;
// <20>޸ĵĶ<C4B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󼯺<EFBFBD>
std::vector<std::pair<diff_object*, diff_object*> > objs_upd_extra_;
};
} // namespace acl