]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_utilities/lib/CSPDLTransaction.h
Security-59306.61.1.tar.gz
[apple/security.git] / OSX / libsecurity_utilities / lib / CSPDLTransaction.h
index 2a5adce393674cb21fd34716068b6614c856e9e7..b93c8a872968c530a02b38c2ad6544dfe45eccf8 100644 (file)
 #ifndef _H_CSPDLTRANSACTION
 #define _H_CSPDLTRANSACTION
 
 #ifndef _H_CSPDLTRANSACTION
 #define _H_CSPDLTRANSACTION
 
+#include <TargetConditionals.h>
+
+#if TARGET_OS_OSX
+
 #include <security_cdsa_client/dlclient.h>
 
 //
 // This class performs a transaction on a CSPDL database.
 //
 #include <security_cdsa_client/dlclient.h>
 
 //
 // This class performs a transaction on a CSPDL database.
 //
-// It will commit when:
-//
-// 1) success() has been called
-// 2) the object goes out of scope OR finalize() is called
+// If commit() has not yet been called when the object goes out of scope, the transaction will roll back instead (exceptions will be swallowed).
 //
 //
-// if success() has not been called, the transaction will roll back instead.
-//
-// You can nest transaction objects, but I don't really suggest it...
+// Nesting transactions will likely work, but isn't recommended.
 //
 class DLTransaction {
 public:
 //
 class DLTransaction {
 public:
@@ -45,18 +44,22 @@ public:
     ~DLTransaction();
 
     // Everything has gone right; this transaction will commit.
     ~DLTransaction();
 
     // Everything has gone right; this transaction will commit.
-    // If you don't call this, the transaction will roll back.
-    void success();
-
-    // Commit or rollback as appropriate
-    void finalize();
+    // If you don't call this, the transaction will roll back when the object goes out of scope.
+    // Might throw on error.
+    void commit();
 
 protected:
     DLTransaction();
 
 
 protected:
     DLTransaction();
 
-    // Actually toggle autocommit using the dldbh
+    // Note: disables autocommit using the dldbh
     void initialize();
 
     void initialize();
 
+    // Call rollback if necessary. Never throws.
+    void finalize();
+
+    // Rolls back database transactions. Might throw.
+    void rollback();
+
     CSSM_DL_DB_HANDLE mDldbh;
 
     bool mSuccess;
     CSSM_DL_DB_HANDLE mDldbh;
 
     bool mSuccess;
@@ -74,4 +77,6 @@ private:
     Security::CssmClient::Db& mDb;
 };
 
     Security::CssmClient::Db& mDb;
 };
 
+#endif //TARGET_OS_OSX
+
 #endif // _H_CSPDLTRANSACTION
 #endif // _H_CSPDLTRANSACTION