summaryrefslogtreecommitdiff
path: root/indra/test/manageapr.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-02-07 14:31:27 -0500
committerNat Goodspeed <nat@lindenlab.com>2012-02-07 14:31:27 -0500
commit2681d5403ca0cdf686077d7b14ffa9111f9e9f5d (patch)
tree1de7a70c9cf77417b893cdf8a163de315520a213 /indra/test/manageapr.h
parent33a42b32ca72031a79edca821966f6ebbdcddc93 (diff)
parent32e11494ffde368b2ac166e16dc294d66a18492f (diff)
Automated merge with file:C%3A%5CUsers%5CNat%5Clinden%5Cviewer-tut-fix
Diffstat (limited to 'indra/test/manageapr.h')
-rw-r--r--indra/test/manageapr.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/indra/test/manageapr.h b/indra/test/manageapr.h
new file mode 100644
index 0000000000..2452fb6ae4
--- /dev/null
+++ b/indra/test/manageapr.h
@@ -0,0 +1,46 @@
+/**
+ * @file manageapr.h
+ * @author Nat Goodspeed
+ * @date 2012-01-13
+ * @brief ManageAPR class for simple test programs
+ *
+ * $LicenseInfo:firstyear=2012&license=viewerlgpl$
+ * Copyright (c) 2012, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+#if ! defined(LL_MANAGEAPR_H)
+#define LL_MANAGEAPR_H
+
+#include "llapr.h"
+#include <boost/noncopyable.hpp>
+
+/**
+ * Declare a static instance of this class for dead-simple ll_init_apr() at
+ * program startup, ll_cleanup_apr() at termination. This is recommended for
+ * use only with simple test programs. Once you start introducing static
+ * instances of other classes that depend on APR already being initialized,
+ * the indeterminate static-constructor-order problem rears its ugly head.
+ */
+class ManageAPR: public boost::noncopyable
+{
+public:
+ ManageAPR()
+ {
+ ll_init_apr();
+ }
+
+ ~ManageAPR()
+ {
+ ll_cleanup_apr();
+ }
+
+ static std::string strerror(apr_status_t rv)
+ {
+ char errbuf[256];
+ apr_strerror(rv, errbuf, sizeof(errbuf));
+ return errbuf;
+ }
+};
+
+#endif /* ! defined(LL_MANAGEAPR_H) */