~ubuntu-branches/ubuntu/trusty/plee-the-bear/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/ptb-signals-v2.diff/bear-engine/core/src/engine/variable/var_map.hpp

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng, Evgeni Golov, Gonéri Le Bouder, Julien Jorge, Vincent Cheng
  • Date: 2014-01-23 13:20:52 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140123132052-r0kg74mh6egto11t
Tags: 0.6.0-2
* Team upload.

[ Evgeni Golov ]
* Correct Vcs-* URLs to point to anonscm.debian.org

[ Gonéri Le Bouder ]
* import patches by Julien Jorge to fix a FTBFS  with the current
  Boost.FileSystem (closes: #720819)
* Add myself in Uploaders
* Indent the B-D

[ Julien Jorge ]
* Add mipsn32el mips64 mips64el in the architecures (closes: #726176)
* Add a patch to use the full path to the icon in the menu files
  (closes: #726853)

[ Vincent Cheng ]
* Refresh patches.
* Update to Standards version 3.9.5.
* Update to source format "3.0 (quilt)".

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Bear Engine
 
3
 
 
4
  Copyright (C) 20052011 Julien Jorge, Sebastien Angibaud
 
5
 
 
6
  This program is free software; you can redistribute it and/or modify it
 
7
  under the terms of the GNU General Public License as published by the
 
8
  Free Software Foundation; either version 2 of the License, or (at your
 
9
  option) any later version.
 
10
 
 
11
  This program is distributed in the hope that it will be useful, but WITHOUT
 
12
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
13
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
14
  more details.
 
15
 
 
16
  You should have received a copy of the GNU General Public License along
 
17
  with this program; if not, write to the Free Software Foundation, Inc.,
 
18
  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 
 
20
  contact: plee-the-bear@gamned.org
 
21
 
 
22
  Please add the tag [Bear] in the subject of your mails.
 
23
*/
 
24
/**
 
25
 * \file var_map.hpp
 
26
 * \brief The structure in which we store the level variables or game variables.
 
27
 * \author Julien Jorge
 
28
 */
 
29
#ifndef __ENGINE_VAR_MAP_HPP__
 
30
#define __ENGINE_VAR_MAP_HPP__
 
31
 
 
32
#include "engine/class_export.hpp"
 
33
 
 
34
#include <claw/multi_type_map.hpp>
 
35
#include <claw/multi_type_map_visitor.hpp>
 
36
#include <claw/meta/type_list.hpp>
 
37
 
 
38
#include <string>
 
39
#include <boost/signal.hpp>
 
40
 
 
41
namespace bear
 
42
{
 
43
  namespace engine
 
44
  {
 
45
    /** \brief The types supported by the engine. */
 
46
    typedef claw::meta::type_list_maker
 
47
    <int, unsigned int, bool, double, std::string>::result var_types;
 
48
 
 
49
    /**
 
50
     * \brief The structure in which we store the level variables or game
 
51
     *        variables.
 
52
     */
 
53
    class ENGINE_EXPORT var_map:
 
54
      public claw::multi_type_map<std::string, var_types>
 
55
    {
 
56
    private:
 
57
      /** \brief The type of the parent map. */
 
58
      typedef claw::multi_type_map<std::string, var_types> super;
 
59
 
 
60
      /** \brief The types of the signals used to observe the variables. */
 
61
      typedef claw::meta::type_list_maker
 
62
      < boost::signal<void (int)>*, boost::signal<void (unsigned int)>*,
 
63
        boost::signal<void (bool)>*, boost::signal<void (double)>*,
 
64
        boost::signal<void (std::string)>* >::result signal_types;
 
65
 
 
66
      /**
 
67
       * \brief The map containing the signals associated with the variables.
 
68
       */
 
69
      typedef claw::multi_type_map<std::string, signal_types> signal_map;
 
70
 
 
71
      /**
 
72
       * \brief A function object that deletes the signal associated with a
 
73
       *        variable.
 
74
       * \author Julien Jorge
 
75
       */
 
76
      class delete_signal
 
77
      {
 
78
      public:
 
79
        template<typename T>
 
80
        void operator()
 
81
        ( const std::string& name, boost::signal<void (T)>* value ) const;
 
82
 
 
83
      }; // class delete_signal
 
84
 
 
85
      /**
 
86
       * \brief A function object that triggers the signal associated with a
 
87
       *        variable.
 
88
       * \author Julien Jorge
 
89
       */
 
90
      class trigger_signal
 
91
      {
 
92
      public:
 
93
        trigger_signal( const signal_map& m );
 
94
 
 
95
        template<typename T>
 
96
        void operator()
 
97
        ( const std::string& name, const T& value ) const;
 
98
 
 
99
      private:
 
100
        /** \brief The map in which the signals are searched. */
 
101
        const signal_map& m_signals;
 
102
 
 
103
      }; // class trigger_signal
 
104
 
 
105
      /**
 
106
       * \brief A function object that deletes the the signals for the variables
 
107
       *        not declared in a given var_map.
 
108
       * \author Julien Jorge
 
109
       */
 
110
      class delete_signal_not_in
 
111
      {
 
112
      public:
 
113
        delete_signal_not_in( const var_map& m, signal_map& s );
 
114
 
 
115
        template<typename T>
 
116
        void operator()
 
117
        ( const std::string& name, const T& value ) const;
 
118
 
 
119
      private:
 
120
        /** \brief The var_map in which the variables are searched. */
 
121
        const var_map& m_map;
 
122
 
 
123
        /** \brief The map in which the signals are searched. */
 
124
        signal_map& m_signals;
 
125
 
 
126
      }; // class delete_signal_not_in()
 
127
 
 
128
    public:
 
129
      var_map();
 
130
      ~var_map();
 
131
      var_map( const var_map& that );
 
132
 
 
133
      var_map& operator=( const var_map& that );
 
134
 
 
135
      template<typename T>
 
136
      boost::signal<void (T)>& variable_changed( const std::string& name );
 
137
 
 
138
      template<typename T>
 
139
      void set( const std::string& k, const T& v );
 
140
 
 
141
      void set( const var_map& m );
 
142
 
 
143
      template<typename Function>
 
144
      void for_each( Function f );
 
145
 
 
146
    private:
 
147
      /** \brief The signals triggered when the value of a variable change. */
 
148
      signal_map m_signals;
 
149
 
 
150
    }; // class var_map
 
151
 
 
152
  } // namespace engine
 
153
} // namespace bear
 
154
 
 
155
#include "engine/variable/impl/var_map.tpp"
 
156
 
 
157
#endif // __ENGINE_VAR_MAP_HPP__