![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
Classes | |
struct | Entry |
struct | TypeEntry |
Public Types | |
typedef v8::Local< v8::Object >(* | ConstructWrapperFunction )(void *, const void *) |
typedef void(* | UnwrapFunction )(const v8::Handle< v8::Value > &, void *, const std::type_info &) |
Public Member Functions | |
const v8::Persistent < v8::FunctionTemplate > & | operator[] (const std::string &name) const |
void | init (v8::Handle< v8::Object > target, const std::string &module) |
void | import (const Registry &other, const std::string &name) |
bool | empty () const |
v8::Local< v8::Function > | getConstructor (const std::string &cls) const |
v8::Local< v8::Object > | constructInstance (const std::string &cls, OnConstructorError e=THROW_ON_ERROR) const |
v8::Local< v8::Object > | constructInstance (const std::string &cls, const v8::Arguments &args, OnConstructorError e=THROW_ON_ERROR) const |
v8::Local< v8::Object > | constructInstance (const std::string &cls, int argc, v8::Handle< v8::Value > *argv, OnConstructorError e=THROW_ON_ERROR) const |
void | introduce (const std::string &name, const std::string &module, const InitFunction init, const std::string &base="") |
void | get_to_know (const std::string &name, const std::string &module, const v8::Persistent< v8::FunctionTemplate > &tmpl, SetupFunction setup) |
template<typename Shared , typename Wrapper > | |
void | isWrapper (ConstructWrapperFunction construct, UnwrapFunction unwrap) |
template<typename Base , typename Derived > | |
void | isBase () |
template<typename Base > | |
v8::Local< v8::Object > | getWrapper (const std::shared_ptr< Base > &object) const |
template<typename Object > | |
std::shared_ptr< Object > | getObject (v8::Local< v8::Value > wrapped) const |
template<typename Object > | |
std::shared_ptr< Object > | getObject (v8::Handle< v8::Value > wrapped) const |
Definition at line 45 of file js_registry.h.
typedef v8::Local<v8::Object>(* Datacratic::JS::Registry::ConstructWrapperFunction)(void *, const void *) |
Type for a factory function that constructs an instance from a) a pointer to a smart pointer to a base class, and b) an adjusted pointer to the derived object.
Definition at line 99 of file js_registry.h.
std::shared_ptr<Object> Datacratic::JS::Registry::getObject | ( | v8::Local< v8::Value > | wrapped | ) | const [inline] |
Convert a wrapped object into its underlying value. Uses the type info system to figure out where it comes from.
Definition at line 233 of file js_registry.h.
v8::Local<v8::Object> Datacratic::JS::Registry::getWrapper | ( | const std::shared_ptr< Base > & | object | ) | const [inline] |
Return the maximally specific Javascript wrapper object for the given base class.
For example, in the following class hierarchy:
Base <- Derived1 <- Derived2 <- Derived1A wrapped with the following JS class hierarchy:
BaseJS <- Derived1JS <- Derived2JS <- Derived1AJS
then calling getWrapper with a shared pointer to Base would return the Derived1JS if the object was Derived1, Derived2JS if the object was Derived2, etc. If the object was another class derived from Base (that wasn't wrapped), then the BaseJS wrapper object would be returned.
This works by making wrapper objects register themselves using the isWrapper() call, and recording the type information necessary to do so.
A null pointer or a pointer to a class that wasn't actually convertible will throw an exception.
Definition at line 176 of file js_registry.h.
void Datacratic::JS::Registry::import | ( | const Registry & | other, |
const std::string & | name | ||
) |
Bring in an object from another registry without actually causing it to be instantiated.
Definition at line 57 of file js_registry.cc.
void Datacratic::JS::Registry::init | ( | v8::Handle< v8::Object > | target, |
const std::string & | module | ||
) |
Initialize the given target by instantiating all of the objects that are specified in the registry.
Definition at line 128 of file js_registry.cc.
void Datacratic::JS::Registry::isBase | ( | ) | [inline] |
Notify that the given base is the base class for the derived type. This is used to determine which objects might wrap a given wrapper class.
Definition at line 139 of file js_registry.h.
void Datacratic::JS::Registry::isWrapper | ( | ConstructWrapperFunction | construct, |
UnwrapFunction | unwrap | ||
) | [inline] |
Indicate that the given wrapper class wraps the given object.
Definition at line 106 of file js_registry.h.