Skip to content

Commit

Permalink
Small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
psyton committed Jun 26, 2012
1 parent 1055dac commit a660624
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 96 deletions.
1 change: 1 addition & 0 deletions xbmc/ack/include/ack/core/atomic_int.h
Expand Up @@ -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);
};
Expand Down
4 changes: 2 additions & 2 deletions 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
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/ack/include/ack/core/invoke_count.h
Expand Up @@ -19,7 +19,7 @@ class ACK_CORE_API InvokeCount
//! Invoke finished
void leave();
bool isLocked();
void waitFor();
bool waitFor();
};

} // namespace core
Expand Down
6 changes: 3 additions & 3 deletions xbmc/ack/include/ack/core/services/abstract_service_factory.h
Expand Up @@ -3,7 +3,7 @@

namespace boost {
namespace uuids {
class uuid;
struct uuid;
}
}

Expand All @@ -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() {}
};

Expand Down
180 changes: 90 additions & 90 deletions 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\
Expand Down

0 comments on commit a660624

Please sign in to comment.