Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SharedList.hpp
Go to the documentation of this file.
1 
2 #pragma once
3 
7 
8 
10 {
12 
13  void setonchangefunctions(int id)
14  {
15  //test.connect([id](int oldvalue, int newvalue)
16  //{
17  // Log.std->debug("init: ENet {}", id, value);
18  //});
19  }
20  sharedclasstest() : test(15) {}
21 
22  // TODO we should fire on = operator ein: adde + remove event f�rs parent oder onchange f�r jeden member! (Achtung overhead)
23  // vllt gibts schon iwie ne anleitung standardlisten zu modifizieren?
24 };
25 
27 {
29  const char *is_shared_list = "true";
30 };
31 
32 template<typename T>
34 {
35  int len = 0;
36  std::function<void(int, T &)> element_pushed_back_func;
37  std::function<void(int)> element_removed_func;
38  std::vector<T> container;
39 
41 
42  void push_back(T &&s)
43  {
44  int id = ++len;
45  container.push_back(std::move(s));
47  }
48 
49  void push_back(const T &s)
50  {
51  int id = ++len;
52  container.push_back(s);
54  }
55  // fehlt: emplace emplace back assign, insert, swap
56 
57  void erase(int i)
58  {
59  if(i >= container.size() || i < 0) return;
60  container.erase(container.begin() + i);
62  }
63 
64  T& operator[](size_t n)
65  {
66  return container[n];
67  }
68 
69  size_t size()
70  {
71  return container.size();
72  }
73 };
74 
void push_back(T &&s)
Definition: SharedList.hpp:42
sharedclasstest()
Definition: SharedList.hpp:20
void setonchangefunctions(int id)
Definition: SharedList.hpp:13
std::vector< T > container
Definition: SharedList.hpp:38
void push_back(const T &s)
Definition: SharedList.hpp:49
Definition: SharedList.hpp:26
SharedVar< int > test
Definition: SharedList.hpp:11
void erase(int i)
Definition: SharedList.hpp:57
Definition: SharedList.hpp:9
InternalSharedListMarker()
Definition: SharedList.hpp:28
std::function< void(int, T &)> element_pushed_back_func
Definition: SharedList.hpp:36
Definition: SharedList.hpp:33
SharedList()
Definition: SharedList.hpp:40
size_t size()
Definition: SharedList.hpp:69
bool move(physent *d, vec &dir)
Definition: physics.cpp:1342
All classes deriving from this class get detected by our reflection system InexorGlueGen.
Definition: SharedClass.hpp:6
int len
Definition: SharedList.hpp:35
T & operator[](size_t n)
Definition: SharedList.hpp:64
const char * is_shared_list
Definition: SharedList.hpp:29
SharedVar wrapper for primitive/immutable objects.
Definition: SharedVar.hpp:55
std::function< void(int)> element_removed_func
Definition: SharedList.hpp:37
Definition: SharedOptions.hpp:6