amino  1.0-beta2
Lightweight Robot Utility Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
amino.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 4 -*- */
2 /* ex: set shiftwidth=4 tabstop=4 expandtab: */
3 /*
4  * Copyright (c) 2010-2011, Georgia Tech Research Corporation
5  * All rights reserved.
6  *
7  * Author(s): Neil T. Dantam <ntd@gatech.edu>
8  * Georgia Tech Humanoid Robotics Lab
9  * Under Direction of Prof. Mike Stilman <mstilman@cc.gatech.edu>
10  *
11  *
12  * This file is provided under the following "BSD-style" License:
13  *
14  *
15  * Redistribution and use in source and binary forms, with or
16  * without modification, are permitted provided that the following
17  * conditions are met:
18  *
19  * * Redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer.
21  *
22  * * Redistributions in binary form must reproduce the above
23  * copyright notice, this list of conditions and the following
24  * disclaimer in the documentation and/or other materials provided
25  * with the distribution.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
28  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
29  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
35  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
36  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39  * POSSIBILITY OF SUCH DAMAGE.
40  *
41  */
42 
43 #ifndef AMINO_HPP
44 #define AMINO_HPP
45 
50 #include "amino.h"
51 #include "amino/mem.hpp"
52 #include "amino/tf.hpp"
53 
54 
55 //namespace amino {
56 //#include "amino/mat.hpp"
57 //}
58 
60 namespace amino {
61 
63 class ScopedMutex {
64 public:
66  ScopedMutex( pthread_mutex_t *m ) :
67  mutex(m)
68  {
69  pthread_mutex_lock(mutex);
70  }
72  ScopedMutex( pthread_mutex_t &m ) :
73  mutex(&m)
74  {
75  pthread_mutex_lock(mutex);
76  }
79  pthread_mutex_unlock(mutex);
80  }
81 
82 private:
84  pthread_mutex_t *mutex;
85 };
86 
87 
88 
89 template<typename T>
90 T next( T p )
91 {
92  T q = p;
93  q++;
94  return q;
95 }
96 
97 
98 template<typename T>
99 T prev( T p )
100 {
101  T q = p;
102  q--;
103  return q;
104 }
105 
106 }
107 
108 #endif //AMINO_HPP
ScopedMutex(pthread_mutex_t &m)
costruct this and lock m
Definition: amino.hpp:72
Top-level include file.
amino namespace
Definition: amino.hpp:60
Locks mutex on construction, unlocks on destruction.
Definition: amino.hpp:63
C++ Memory Management.
~ScopedMutex()
destroy this and unlock m
Definition: amino.hpp:78
ScopedMutex(pthread_mutex_t *m)
costruct this and lock m
Definition: amino.hpp:66
Object types for SE(3) representations.