• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // We don't know about the user's annotations, only the base annotations
2 #include "mocktuningfork.h"
3 #include "gameengine.h"
4 #include <iostream>
5 
6 namespace gameengine {
7 
8 namespace {
9 Annotation current_annotation;
10 }
11 
12 using namespace com::google::tuningfork;
13 
init(const Settings & s,const std::function<void (const FidelityParams &)> & callback)14 void init(const Settings& s,
15           const std::function<void(const FidelityParams&)>& callback ) {
16   mocktuningfork::init(s,callback);
17   current_annotation.SetExtension(loading_state, LoadingState::LOADING);
18   current_annotation.SetExtension(level, 0);
19 }
init(const std::string & settings,const std::function<void (const std::string &)> & callback)20 void init(const std::string& settings,
21           const std::function<void(const std::string&)>& callback ) {
22   Settings s;
23   s.ParseFromString(settings);
24   mocktuningfork::init(s, [&](const FidelityParams& p) {
25                             std::string fp_ser;
26                             p.SerializeToString(&fp_ser);
27                             callback(fp_ser); }
28     );
29   current_annotation.SetExtension(loading_state, LoadingState::LOADING);
30   current_annotation.SetExtension(level, 0);
31 }
set(const std::string & s)32 void set(const std::string& s) {
33   Annotation t;
34   t.ParseFromString(s);
35   current_annotation.MergeFrom(t);
36 }
set(const Annotation & a)37 void set(const Annotation& a) {
38   current_annotation.MergeFrom(a);
39 }
tick()40 void tick() {
41   // Some logic for updating the annotation - it usually wouldn't happen every
42   //  tick
43   auto l = current_annotation.GetExtension(level);
44   current_annotation.SetExtension(level, l+1);
45   if(l>0)
46     current_annotation.SetExtension(loading_state, LoadingState::NOT_LOADING);
47   mocktuningfork::set(current_annotation);
48   mocktuningfork::tick(SYS_CPU);
49 }
50 
51 } // namespace gamengine
52