A registry is a global association from keys to objects, allowing the objects to be reached from anywhere. It involves two methods: one that takes a key and an object and add objects to the registry and one that takes a key and returns the object for the key. It's similar to the MultitonPattern, but doesn't restrict instances to only those in the registry.
Questions tagged [registry-pattern]
5 questions
1
vote
1 answer
Registry pattern with __init_subclass__ and sub-classable registry
I want to create a settings registry. I also want to be able to group settings in macro-categories.
The following simplified example works with a single registry:
class RegistryHolder:
registry = {}
def __init_subclass__(cls,…

Oleg
- 10,406
- 3
- 29
- 57
0
votes
0 answers
mvc - cannot get database instance in model
I have a basic MVC framework set up.
Problem is I have to pass the registry in the view to the Controller in order to call the database which is set in the registry. This does not seem to be the proper way.
Question how can I get the database…

stomperDev
- 19
- 6
0
votes
3 answers
How to apply registry pattern to make "select class depend on input" obey open closed principle?
for example, I have some Fruits:
Fruit.h
#ifndef __Fruit__
#define __Fruit__
#include
class Fruit{
public:
virtual void hi(std::string username)=0;
};
#endif
Apple.h
#include "Fruit.h"
#include
class Apple : public…

ggrr
- 7,737
- 5
- 31
- 53
0
votes
1 answer
Registry pattern - the difference with reference and without
Following this guide, but it is always difficult for me to understand references in PHP. What is the purpose of using reference in the params below?
public function register($name, &$object)
{
$this->registries[$name] =& $object;
}
public…

Run
- 54,938
- 169
- 450
- 748
0
votes
1 answer
Segment fault 11 in registry pattern
I'm trying to create a class Animal, with some subclasses that have a interface method newObject() return new instance of self:
Animal.h
class Animal{
public:
virtual Animal* newObject()=0;
};
and I am trying to implement registry pattern, with…

ggrr
- 7,737
- 5
- 31
- 53