BioDynaMo  v1.05.120-25dc9790
jit.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef CORE_UTIL_JIT_H_
16 #define CORE_UTIL_JIT_H_
17 
18 #include <functional>
19 #include <string>
20 #include <vector>
21 
22 #include <TClass.h>
23 #include <TDataMember.h>
24 
25 namespace bdm {
26 
27 class Agent;
28 
36 std::vector<TClass*> FindClassSlow(const std::string& class_name);
37 
45 std::vector<TDataMember*> FindDataMemberSlow(TClass* tclass,
46  const std::string& data_member);
47 
48 // -----------------------------------------------------------------------------
50  public:
52  TClass* tclass, const std::vector<std::string>& dm_names,
53  const std::string& functor_name,
54  const std::function<std::string(const std::string&,
55  const std::vector<TDataMember*>&)>&
56  code_generation);
57 
58  void Compile() const;
59 
60  void* New(const std::string& parameter = "");
61 
62  template <typename TFunctor>
63  TFunctor* New(const std::string& parameter = "") {
64  return static_cast<TFunctor*>(New(parameter));
65  }
66 
67  private:
69  static std::atomic<int> counter_;
70  std::string functor_name_;
71  std::vector<TDataMember*> data_members_;
72  std::function<std::string(const std::string&,
73  const std::vector<TDataMember*>&)>
75 };
76 
77 // -----------------------------------------------------------------------------
78 class JitHeaders {
79  public:
82  static void Register(const std::string& header);
85  static void IncludeIntoCling();
86 
87  private:
88  static std::vector<std::string> headers_;
89 };
90 
91 } // namespace bdm
92 
93 #endif // CORE_UTIL_JIT_H_
bdm::JitHeaders::IncludeIntoCling
static void IncludeIntoCling()
Definition: jit.cc:184
bdm::JitHeaders::Register
static void Register(const std::string &header)
Definition: jit.cc:145
bdm::JitForEachDataMemberFunctor::functor_name_
std::string functor_name_
Definition: jit.h:70
bdm
Definition: agent.cc:39
bdm::JitForEachDataMemberFunctor::JitForEachDataMemberFunctor
JitForEachDataMemberFunctor(TClass *tclass, const std::vector< std::string > &dm_names, const std::string &functor_name, const std::function< std::string(const std::string &, const std::vector< TDataMember * > &)> &code_generation)
Definition: jit.cc:106
bdm::JitHeaders
Definition: jit.h:78
bdm::JitForEachDataMemberFunctor::code_generator_
std::function< std::string(const std::string &, const std::vector< TDataMember * > &)> code_generator_
Definition: jit.h:74
bdm::JitForEachDataMemberFunctor::New
void * New(const std::string &parameter="")
Definition: jit.cc:135
bdm::JitForEachDataMemberFunctor::counter_
static std::atomic< int > counter_
The counter value is appended to the functor_name to obtain unique names.
Definition: jit.h:69
bdm::JitHeaders::headers_
static std::vector< std::string > headers_
Definition: jit.h:88
bdm::FindClassSlow
std::vector< TClass * > FindClassSlow(const std::string &class_name)
Definition: jit.cc:31
bdm::JitForEachDataMemberFunctor::Compile
void Compile() const
Definition: jit.cc:129
bdm::JitForEachDataMemberFunctor
Definition: jit.h:49
bdm::JitForEachDataMemberFunctor::New
TFunctor * New(const std::string &parameter="")
Definition: jit.h:63
bdm::FindDataMemberSlow
std::vector< TDataMember * > FindDataMemberSlow(TClass *tclass, const std::string &data_member)
Definition: jit.cc:60
bdm::JitForEachDataMemberFunctor::data_members_
std::vector< TDataMember * > data_members_
Definition: jit.h:71