All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
IResourceBuilder.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Streaming.h"
7 #include "Resources.h"
8 #include <vector>
9 
10 namespace Eegeo
11 {
12  namespace Resources
13  {
14  typedef std::vector<IBuiltResource*> TBuiltResources;
15 
16  namespace BuilderTransitionOutput
17  {
18  enum BuilderTransitionOutputType
19  {
20  ERROR=0,
21  CANCELLED,
22  COMPLETE
23  };
24  }
25 
27  {
28  BuilderTransitionOutput::BuilderTransitionOutputType type;
29  TBuiltResources output;
30 
31  static BuilderTransition Success(TBuiltResources output)
32  {
33  BuilderTransition result;
34  result.output = output;
35  result.type = BuilderTransitionOutput::COMPLETE;
36  return result;
37  }
38 
39  static BuilderTransition Error()
40  {
41  BuilderTransition result;
42  result.type = BuilderTransitionOutput::ERROR;
43  return result;
44  }
45 
46  static BuilderTransition Cancelled()
47  {
48  BuilderTransition result;
49  result.type = BuilderTransitionOutput::CANCELLED;
50  return result;
51  }
52  };
53 
55  {
56  private:
57  long long currentClockStart;
58  long long millisBuilding;
59  int builds;
60 
61  public:
63  {
64  millisBuilding = 0;
65  builds = 0;
66  }
67 
68  virtual ~IResourceBuilder() { }
69  void StartClock();
70  void EndClock();
71  void ResetCounters();
72  int NumBuilds();
73  double AvgTimeTakenMs();
74 
75  virtual bool Flush(const Streaming::MortonKey& key, void* input, TBuiltResources& result)=0;
76  virtual void DestroyBuiltResource(const Streaming::MortonKey& key, void* input)=0;
77 
78  virtual void* BuildResource(const Streaming::MortonKey& key, const Byte* data, size_t length)=0;
79 
80  virtual bool AcceptsErroredRequests() = 0;
81  };
82  }
83 }