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

Side by Side Diff: sandbox/linux/seccomp-bpf-helpers/cons.h

Issue 299743002: Add domain-specific language for BPF policies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add explicit virtual destructors to test policies Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_HELPERS_CONST_LIST_H_
6 #define SANDBOX_LINUX_SECCOMP_BPF_HELPERS_CONST_LIST_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "sandbox/sandbox_export.h"
10
11 namespace sandbox {
12
13 // Cons provides an immutable linked list abstraction as commonly
14 // provided in functional programming languages like Lisp or Haskell.
15 template <typename T>
16 class Cons : public base::RefCounted<Cons<T> > {
17 public:
18 // List provides an abstraction for referencing a list of zero or
19 // more Cons nodes.
20 typedef scoped_refptr<const Cons<T> > List;
21
22 // Return this node's head element.
23 const T& head() const { return head_; }
24
25 // Return this node's tail element.
26 List tail() const { return tail_; }
27
28 // Construct a new List using |head| and |tail|.
29 static List Make(const T& head, List tail) {
30 return make_scoped_refptr(new const Cons<T>(head, tail));
31 }
32
33 private:
34 Cons(const T& head, List tail) : head_(head), tail_(tail) {}
35 virtual ~Cons() {}
36
37 T head_;
38 List tail_;
39
40 friend class base::RefCounted<Cons<T> >;
41 DISALLOW_COPY_AND_ASSIGN(Cons);
42 };
43
44 } // namespace sandbox
45
46 #endif // SANDBOX_LINUX_SECCOMP_BPF_HELPERS_CONST_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698