#ifndef SYNC_SYNCABLE_MUTABLE_ENTRY_H_
#define SYNC_SYNCABLE_MUTABLE_ENTRY_H_
#include "sync/syncable/entry.h"
#include "sync/syncable/metahandle_set.h"
namespace syncer {
class WriteNode;
namespace syncable {
class WriteTransaction;
enum Create {
CREATE
};
enum CreateNewUpdateItem {
CREATE_NEW_UPDATE_ITEM
};
class MutableEntry : public Entry {
void Init(WriteTransaction* trans, const Id& parent_id,
const std::string& name);
public:
MutableEntry(WriteTransaction* trans, Create, const Id& parent_id,
const std::string& name);
MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id);
MutableEntry(WriteTransaction* trans, GetByHandle, int64);
MutableEntry(WriteTransaction* trans, GetById, const Id&);
MutableEntry(WriteTransaction* trans, GetByClientTag, const std::string& tag);
MutableEntry(WriteTransaction* trans, GetByServerTag, const std::string& tag);
inline WriteTransaction* write_transaction() const {
return write_transaction_;
}
bool Put(Int64Field field, const int64& value);
bool Put(TimeField field, const base::Time& value);
bool Put(IdField field, const Id& value);
void PutParentIdPropertyOnly(const Id& parent_id);
bool Put(StringField field, const std::string& value);
bool Put(BaseVersion field, int64 value);
bool Put(ProtoField field, const sync_pb::EntitySpecifics& value);
bool Put(BitField field, bool value);
inline bool Put(IsDelField field, bool value) {
return PutIsDel(value);
}
bool Put(IndexedBitField field, bool value);
bool PutPredecessor(const Id& predecessor_id);
bool Put(BitTemp field, bool value);
protected:
syncable::MetahandleSet* GetDirtyIndexHelper();
bool PutIsDel(bool value);
private:
friend class Directory;
friend class WriteTransaction;
friend class syncer::WriteNode;
void* operator new(size_t size) { return (::operator new)(size); }
bool PutUniqueClientTag(const std::string& value);
bool UnlinkFromOrder();
WriteTransaction* const write_transaction_;
protected:
MutableEntry();
DISALLOW_COPY_AND_ASSIGN(MutableEntry);
};
bool MarkForSyncing(syncable::MutableEntry* e);
}
}
#endif