Permalink
Browse files

Small fixes.

  • Loading branch information...
1 parent 1055dac commit a6606249fe18c646fe0f8dcceb9d5e74be2fd3a4 psyton committed Jun 26, 2012
View
1 xbmc/ack/include/ack/core/atomic_int.h
@@ -20,6 +20,7 @@ class ACK_CORE_API AtomicInt
bool ref();
bool deref();
bool testAndSet(long expectedValue, long newValue);
+ long fetchAndStore(long newValue);
long add(long valueToAdd);
long sub(long valueToSub);
};
View
4 xbmc/ack/include/ack/core/core.h
@@ -1,14 +1,14 @@
#pragma once
#include "ack/core/core_global.h"
#include "ack/core/abstract_core.h"
+#include "ack/core/services/abstract_service_factory.h"
#include "ack/pointer/pointer.h"
#include <list>
namespace ack {
namespace core {
class AbstractService;
-class AbstractServiceFactory;
class ACK_CORE_API Core
: public AbstractCore
@@ -18,7 +18,7 @@ class ACK_CORE_API Core
private:
bool m_initialized;
bool m_shutdown;
- //typedef std::list<FactoryPtr> ServiceFactories;
+ typedef std::list<FactoryPtr> ServiceFactories;
public:
Core();
virtual ~Core();
View
2 xbmc/ack/include/ack/core/invoke_count.h
@@ -19,7 +19,7 @@ class ACK_CORE_API InvokeCount
//! Invoke finished
void leave();
bool isLocked();
- void waitFor();
+ bool waitFor();
};
} // namespace core
View
6 xbmc/ack/include/ack/core/services/abstract_service_factory.h
@@ -3,7 +3,7 @@
namespace boost {
namespace uuids {
-class uuid;
+struct uuid;
}
}
@@ -19,8 +19,8 @@ class AbstractServiceFactory
public:
virtual AbstractService* create(const boost::uuids::uuid& aUuid) = 0;
virtual void destroy(AbstractService* servicePtr) = 0;
- UuidList uuidsList() const = 0;
- bool canCreate(const boost::uuids::uuid& aUuid) const = 0;
+ virtual UuidsList uuidsList() const = 0;
+ virtual bool canCreate(const boost::uuids::uuid& aUuid) const = 0;
virtual ~AbstractServiceFactory() {}
};
View
180 xbmc/ack/include/ack/core/services/service_factory.h
@@ -1,93 +1,93 @@
-#pragma once
-#include "ack/for_each_type.h"
-#include "ack/pointer/pointer.h"
-#include "ack/core/services/detail/service_creator.h"
-
-#include <boost/unordered/unordered_map.hpp>
-#include <boost/uuid/uuid.hpp>
-
-
-namespace ack {
-namespace core {
-
-template <class ClassesList>
-class ServiceFactory
-{
-private:
- typedef Pointer<detail::AbstractServiceCreator> CreatorPtr;
- typedef boost::unordered_map<boost::uuids::uuid, CreatorPtr> Creators;
-
- class Generator
- {
- Creators& m_creators;
- public:
- Generator(Creators& aCreators)
- : m_creators(aCreators)
- {
- }
- template<class Type>
- void operator()()
- {
- m_creators.insert( std::make_pair( Type::rootUuid()
- , CreatorPtr( new DefaultServiceCreator<Type>() ) ) );
- }
- };
-
- explicit BaseServiceFactory(const BaseServiceFactory &);
- Creators m_creators;
-private:
- AbstractServiceCreator* find(const boost::uuids::uuid& aUuid)
- {
- Creators::iterator it = m_creators.find(servicePtr->rootUuid());
- if (it != m_creators.end())
- return it->second.get();
- return 0;
- }
-protected:
- inline Creators& creators()
- {
- return m_creators;
- }
-public:
- ServiceFactory()
- {
- ::algorithm::for_each_type<ClassesList>(Generator(creators()));
- }
- virtual ~ServiceFactory() {}
- virtual AbstractService* createService(const boost::uuids::uuid& aUuid)
- {
- AbstractServiceCreator* cPtr = find(servicePtr->rootUuid());
- if (cPtr)
- return cPtr->create();
- return 0;
- }
- virtual void destroy(AbstractService* servicePtr)
- {
- if (servicePtr)
- {
- AbstractServiceCreator* cPtr = find(servicePtr->rootUuid());
- if (cPtr)
- cPtr->destroy(servicePtr);
- servicePtr = 0;
- }
- }
- UuidList uuidsList() const
- {
- UuidList list;
- for (Creators::const_iterator it = m_creators.begin(); it != m_creators.end(); ++it)
- list.push_back(it->first);
- return list;
- }
- bool canCreate(const boost::uuids::uuid& aUuid) const
- {
- return (m_creators.find(aUuid) != m_creators.end());
- }
-};
-
-} // namespace core
-} // namespace ack
-
-
+#pragma once
+#include "ack/for_each_type.h"
+#include "ack/pointer/pointer.h"
+#include "ack/core/services/detail/service_creator.h"
+
+#include <boost/unordered/unordered_map.hpp>
+#include <boost/uuid/uuid.hpp>
+
+
+namespace ack {
+namespace core {
+
+template <class ClassesList>
+class ServiceFactory
+{
+private:
+ typedef Pointer<detail::AbstractServiceCreator> CreatorPtr;
+ typedef boost::unordered_map<boost::uuids::uuid, CreatorPtr> Creators;
+
+ class Generator
+ {
+ Creators& m_creators;
+ public:
+ Generator(Creators& aCreators)
+ : m_creators(aCreators)
+ {
+ }
+ template<class Type>
+ void operator()()
+ {
+ m_creators.insert( std::make_pair( Type::rootUuid()
+ , CreatorPtr( new DefaultServiceCreator<Type>() ) ) );
+ }
+ };
+
+ explicit BaseServiceFactory(const BaseServiceFactory &);
+ Creators m_creators;
+private:
+ AbstractServiceCreator* find(const boost::uuids::uuid& aUuid)
+ {
+ Creators::iterator it = m_creators.find(servicePtr->rootUuid());
+ if (it != m_creators.end())
+ return it->second.get();
+ return 0;
+ }
+protected:
+ inline Creators& creators()
+ {
+ return m_creators;
+ }
+public:
+ ServiceFactory()
+ {
+ ::algorithm::for_each_type<ClassesList>(Generator(creators()));
+ }
+ virtual ~ServiceFactory() {}
+ virtual AbstractService* createService(const boost::uuids::uuid& aUuid)
+ {
+ AbstractServiceCreator* cPtr = find(servicePtr->rootUuid());
+ if (cPtr)
+ return cPtr->create();
+ return 0;
+ }
+ virtual void destroy(AbstractService* servicePtr)
+ {
+ if (servicePtr)
+ {
+ AbstractServiceCreator* cPtr = find(servicePtr->rootUuid());
+ if (cPtr)
+ cPtr->destroy(servicePtr);
+ servicePtr = 0;
+ }
+ }
+ virtual UuidsList uuidsList() const
+ {
+ UuidsList list;
+ for (Creators::const_iterator it = m_creators.begin(); it != m_creators.end(); ++it)
+ list.push_back(it->first);
+ return list;
+ }
+ virtual bool canCreate(const boost::uuids::uuid& aUuid) const
+ {
+ return (m_creators.find(aUuid) != m_creators.end());
+ }
+};
+
+} // namespace core
+} // namespace ack
+
+
#define IMPLEMENT_SERVICE_FACTORY(FactoryClassName, ServicesTypeList) \
\
class FactoryClassName\

0 comments on commit a660624

Please sign in to comment.