AtomicSharp.cpp 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "CSEventHelper.h"
  2. #include "CSComponent.h"
  3. #include "AtomicSharp.h"
  4. namespace Atomic
  5. {
  6. /// Register AtomicSharp library objects.
  7. void ATOMIC_API RegisterAtomicSharpLibrary(Context* context);
  8. WeakPtr<Context> AtomicSharp::csContext_;
  9. WeakPtr<AtomicSharp> AtomicSharp::instance_;
  10. AtomicSharp::AtomicSharp(Context* context) :
  11. Object(context)
  12. {
  13. RegisterAtomicSharpLibrary(context_);
  14. assert(!instance_);
  15. instance_ = this;
  16. csContext_ = context;
  17. SharedPtr<CSEventDispatcher> dispatcher(new CSEventDispatcher(context_));
  18. context_->RegisterSubsystem(dispatcher);
  19. context_->AddGlobalEventListener(dispatcher);
  20. }
  21. AtomicSharp::~AtomicSharp()
  22. {
  23. context_->RemoveGlobalEventListener(context_->GetSubsystem<CSEventDispatcher>());
  24. context_->RemoveSubsystem(CSEventDispatcher::GetTypeStatic());
  25. instance_ = NULL;
  26. }
  27. void RegisterAtomicSharpLibrary(Context* context)
  28. {
  29. CSComponent::RegisterObject(context);
  30. }
  31. }