WvStreams
unitransaction.h
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 2005 Net Integration Technologies, Inc.
00004  *
00005  * Allows one to wrap a UniConf tree with a transaction model.  Use
00006  * UniTransaction::commit() to commit, and
00007  * UniTransaction::refresh() to rollback.
00008  */
00009 #ifndef _UNITRANSACTION_H
00010 #define _UNITRANSACTION_H
00011 
00012 #include "unibachelorgen.h"
00013 #include "uniconfroot.h"
00014 #include "unitransactiongen.h"
00015 #include "uniunwrapgen.h"
00016 
00020 class UniTransaction : public UniConfRoot
00021 {
00022     friend class UniConf;
00023     friend class UniConf::Iter;
00024     friend class UniConf::RecursiveIter;
00025 
00026 public:
00027     UniTransaction(const UniConf &base)
00028         : UniConfRoot(new UniTransactionGen(new UniBachelorGen(
00029                       new UniUnwrapGen(base))), false)
00030     {
00031     }
00032     
00033     // C++ would auto-generate a "copy constructor" for this function, but
00034     // what we really want is just to wrap a new transaction around the
00035     // base, just like any other UniConf object.
00036     UniTransaction(const UniTransaction &base)
00037         : UniConfRoot(new UniTransactionGen(new UniBachelorGen(
00038                       new UniUnwrapGen(base))), false)
00039     {
00040     }
00041 };
00042 
00043 #endif /* _UNITRANSACTION_H */