Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1310)

Unified Diff: sandbox/linux/bpf_dsl/cons.h

Issue 299743002: Add domain-specific language for BPF policies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move bpf_dsl into its own top-level directory Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/bpf_dsl/bpf_dsl_unittest.cc ('k') | sandbox/linux/bpf_dsl/cons_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/bpf_dsl/cons.h
diff --git a/sandbox/linux/bpf_dsl/cons.h b/sandbox/linux/bpf_dsl/cons.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb9e3aa990def77ea9074acfb48b0d0dd587ae0a
--- /dev/null
+++ b/sandbox/linux/bpf_dsl/cons.h
@@ -0,0 +1,46 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SANDBOX_LINUX_BPF_DSL_CONS_H_
+#define SANDBOX_LINUX_BPF_DSL_CONS_H_
+
+#include "base/memory/ref_counted.h"
+#include "sandbox/sandbox_export.h"
+
+namespace sandbox {
+
+// Cons provides an immutable linked list abstraction as commonly
+// provided in functional programming languages like Lisp or Haskell.
+template <typename T>
+class Cons : public base::RefCounted<Cons<T> > {
+ public:
+ // List provides an abstraction for referencing a list of zero or
+ // more Cons nodes.
+ typedef scoped_refptr<const Cons<T> > List;
+
+ // Return this node's head element.
+ const T& head() const { return head_; }
+
+ // Return this node's tail element.
+ List tail() const { return tail_; }
+
+ // Construct a new List using |head| and |tail|.
+ static List Make(const T& head, List tail) {
+ return make_scoped_refptr(new const Cons<T>(head, tail));
+ }
+
+ private:
+ Cons(const T& head, List tail) : head_(head), tail_(tail) {}
+ virtual ~Cons() {}
+
+ T head_;
+ List tail_;
+
+ friend class base::RefCounted<Cons<T> >;
+ DISALLOW_COPY_AND_ASSIGN(Cons);
+};
+
+} // namespace sandbox
+
+#endif // SANDBOX_LINUX_BPF_DSL_CONS_H_
« no previous file with comments | « sandbox/linux/bpf_dsl/bpf_dsl_unittest.cc ('k') | sandbox/linux/bpf_dsl/cons_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698