namespace TP { /// /// This namespace provides the interfaces that define this project /// We also provide files implementing some limited functionality /// for these interfaces. You are welcome to write those yourself if you /// prefer so. /// [System.Serializable()] public class Transaction { /// /// Id for the transaction /// public System.Guid Id; /// /// Constructor /// public Transaction() { this.Id = System.Guid.NewGuid(); } } /// /// Class for the customer /// [System.Serializable()] public class Customer { public System.Guid Id; /// /// Constructor. Generates a new Id for the customer /// public Customer() { this.Id = new System.Guid(); } } /// /// Class for a reservable Item /// [System.Serializable()] public class Item { /// /// public string Name; public Item( string name ) { this.Name = name; } //flight number public Item(int name ) { this.Name = name.ToString(); } } /// /// interface for resources /// public interface RS{} /// /// Lock manager interface /// public interface LM { /// /// /// /// /// void LockForRead( Transaction context, RS resource); /// /// /// /// /// void LockForWrite( Transaction context, RS resource); /// /// /// /// void UnlockAll( Transaction context ); } /// /// Transaction manager interface /// public interface TM { Transaction Start(); /// /// /// /// void Commit( Transaction context ); /// /// /// /// void Abort( Transaction context ); /// /// /// /// void Enlist( Transaction context ); } /// /// Workflow controller interface /// public interface WC { /// /// /// /// /// /// /// /// /// success bool ReserveItinerary( TP.Customer c, int[] flights, string location, bool car, bool room ); //communication with the RM will happen through the WC...eventually void Commit(Transaction context); void Abort(Transaction context); //this would result in a call to Add to the RM that handles flights //the name of the item is usually the name of the location bool AddFlight(Transaction context, Item i, int count, int price ); bool DeleteFlight(Transaction context, Item i); bool AddRooms(Transaction context, Item i, int count, int price ); bool DeleteRooms(Transaction context, Item i); bool AddCars(Transaction context, Item i, int count, int price ); bool DeleteCars(Transaction context, Item i); int QueryFlight(Transaction context, Item i); int QueryFlightPrice(Transaction context, Item i); int QueryRooms(Transaction context, Item i); int QueryRoomsPrice(Transaction context, Item i); int QueryCars(Transaction context, Item i); int QueryCarsPrice(Transaction context, Item i); string QueryCustomerInfo(TP.Transaction context,TP.Customer c); int QueryCustomer(TP.Transaction context,TP.Customer c); } /// /// Resource Manager Interface /// public interface RM { /// /// Transaction Boundaries /// /// void Enlist( Transaction context ); /// /// /// /// void Commit( Transaction context ); /// /// /// /// void Abort( Transaction context ); /// /// Populate Database /// This method is equivalent to the addXXX in the Java Interface /// /// /// /// /// /// success bool Add( Transaction context, Item i, int count, int price ); bool Delete( Transaction context, Item i ); /// /// Query: equivalent to QueryCars, QueryFlights, QueryRooms in the Java interface /// /// /// /// int Query( Transaction context, Item i ); /// /// /// /// /// /// int QueryPrice( Transaction context, Item i ); string QueryCustomerInfo( Transaction context, Customer c ); /// /// /// /// /// /// int QueryCustomer( Transaction context, Customer c ); /// /// Reservation /// /// /// /// /// sucess bool Reserve( Transaction context, Customer c, Item i ); /// /// /// /// /// void DropReservations( Transaction context, Customer c ); // // technical/testing interface // /// /// Shutdown gracefully. /// When this RM restarts, it should not attempt to recover its state if /// the client called shutdown to terminate it. /// void Shutdown(); /// /// Call exit after a specified number of disk writes. ///Support for this method requires a wrapper around the system's /// write to disk command that decrements the counter set /// by this method. /// This counter should default to 0, which implies that the wrapper ///will do nothing. If the count is non-zero, the wrapper should decrement ///the counter, see if it becomes zero, and if so, call exit(), otherwise /// This method is not part of a transaction. /// /// void SelfDestruct(int diskWritesToWait); } }