summaryrefslogtreecommitdiff
path: root/indra/test/manageapr.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-02-12 21:59:51 -0500
committerNat Goodspeed <nat@lindenlab.com>2012-02-12 21:59:51 -0500
commit6da3f0907cea3748adb6be9a7c393835109adf3b (patch)
tree8a569f192a49913db7365c97548c1227a123127e /indra/test/manageapr.h
parent8804fa524c084edb9f49f4122e2c7330a80c79b5 (diff)
parent90a1b67cc43792e1ca0047eaca51530aa14e134c (diff)
Automated merge with ssh://hg.lindenlab.com/nat/viewer-new-apr
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) */