replicode
space.h
Go to the documentation of this file.
1 /*
2 * HUMANOBS - mBrane
3 *
4 * Eric Nivel
5 * Center for Analysis and Design of Intelligent Agents
6 * Reykjavik University, Menntavegur 1, 101 Reykjavik, Iceland
7 * http://cadia.ru.is
8 * Copyright(c)2012
9 *
10 * This software was developed by the above copyright holder as part of
11 * the HUMANOBS EU research project, in collaboration with the
12 * following parties:
13 *
14 * Autonomous Systems Laboratory
15 * Technical University of Madrid, Spain
16 * http://www.aslab.org/
17 *
18 * Communicative Machines
19 * Edinburgh, United Kingdom
20 * http://www.cmlabs.com/
21 *
22 * Istituto Dalle Molle di Studi sull'Intelligenza Artificiale
23 * University of Lugano and SUPSI, Switzerland
24 * http://www.idsia.ch/
25 *
26 * Institute of Cognitive Sciences and Technologies
27 * Consiglio Nazionale delle Ricerche, Italy
28 * http://www.istc.cnr.it/
29 *
30 * Dipartimento di Ingegneria Informatica
31 * University of Palermo, Italy
32 * http://roboticslab.dinfo.unipa.it/index.php/Main/HomePage
33 *
34 *
35 * --- HUMANOBS Open-Source BSD License, with CADIA Clause v 1.0 ---
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, is permitted provided that the following conditions
39 * are met:
40 *
41 * - Redistributions of source code must retain the above copyright
42 * and collaboration notice, this list of conditions and the
43 * following disclaimer.
44 *
45 * - Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following
47 * disclaimer in the documentation and/or other materials provided
48 * with the distribution.
49 *
50 * - Neither the name of its copyright holders nor the names of its
51 * contributors may be used to endorse or promote products
52 * derived from this software without specific prior written permission.
53 *
54 * - CADIA Clause: The license granted in and to the software under this
55 * agreement is a limited-use license. The software may not be used in
56 * furtherance of:
57 * (i) intentionally causing bodily injury or severe emotional distress
58 * to any person;
59 * (ii) invading the personal privacy or violating the human rights of
60 * any person; or
61 * (iii) committing or preparing for any act of war.
62 *
63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
64 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
65 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
66 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
67 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
68 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
69 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
70 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
71 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
72 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
73 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74 */
75 
76 #ifndef mBrane_space_h
77 #define mBrane_space_h
78 
79 #include <CoreLibrary/xml_parser.h>
80 
81 #include "module_descriptor.h"
82 
83 
84 using namespace mBrane::sdk;
85 
86 namespace mBrane
87 {
88 
89 class Space:
90  public Projectable<Space>
91 {
92 private:
94  {
95  public:
98  };
100  const char *name;
101  float _activationThreshold; // in [0,1]
103  void applyInitialProjections(uint8_t hostID);
104 public:
105  static Space *Get(const char *name); // in Config.
106  static Array<P<Space>, 16> Config; // indexed by space ID; 0 is the root space; see ModuleDescriptor.h
107  static Array<Array<P<Space>, 16>, 8> Main; // indexed by space ID; 0 is the root space
108  static Space *New(XMLNode &n);
109  static void Init(uint8_t hostID); // resolves hostID for each space, copies Config in Main, apply initial projections.
110  static void InitRoot(); // creates root space.
111  static uint16_t GetID(uint8_t hostID); // returns the first available slot in Main[hostID].
114  Space(uint8_t hostID, const char *name = NULL);
115  ~Space();
116  const char *getName();
117  void setActivationThreshold(float thr);
118  float getActivationThreshold();
119  void _activate(); // update children activation; called upon changing the space threshold or the space activation level
120  void _deactivate(); // deactivate children
122  List<P<Projection<Space>>, 16>::Iterator project(Projection<Space> *p);
123 };
124 }
125 
126 
127 #endif
Array< _Projection, 32 > initialProjections
Definition: space.h:102
void Init(const std::vector< int32_t > &numbers, const std::vector< std::string > &strings)
Definition: Perf.cpp:93
List< P< Projection< ModuleDescriptor > >, 16 > moduleDescriptors
Definition: space.h:112
static Array< Array< P< Space >, 16 >, 8 > Main
Definition: space.h:107
Definition: array.h:84
Definition: projection.h:114
Definition: list.h:94
float activationLevel
Definition: space.h:97
Definition: module_descriptor.h:133
uint16_t spaceID
Definition: space.h:96
Definition: space.h:93
Definition: array.h:86
Definition: xml_parser.h:172
const char * name
Definition: space.h:100
List< P< Projection< Space > >, 16 > spaces
Definition: space.h:113
static Array< P< Space >, 16 > Config
Definition: space.h:106
Definition: projection.h:102
Definition: array.h:162
float _activationThreshold
Definition: space.h:101
Definition: space.h:89
float initialActivationThreshold
Definition: space.h:99