b'\n_START_ARTICLE_\nEgyszer haszn\xc3\xa1latos l\xc3\xa1togat\xc3\xb3 programtervez\xc3\xa9si minta\n_START_PARAGRAPH_\nAz egyszer haszn\xc3\xa1latos l\xc3\xa1togat\xc3\xb3 programtervez\xc3\xa9si minta a sz\xc3\xa1m\xc3\xadt\xc3\xb3g\xc3\xa9p-programoz\xc3\xa1s egyik tervmint\xc3\xa1ja. C\xc3\xa9lja a l\xc3\xa1togat\xc3\xb3 programtervez\xc3\xa9si minta optimaliz\xc3\xa1l\xc3\xa1sa: a l\xc3\xa1togat\xc3\xb3t allok\xc3\xa1lja, felhaszn\xc3\xa1lja, majd deallok\xc3\xa1lja.\n_START_SECTION_\nAlkalmazhat\xc3\xb3s\xc3\xa1ga\n_START_PARAGRAPH_\nA minta akkor alkalmazhat\xc3\xb3, ha nincs sz\xc3\xbcks\xc3\xa9g arra, hogy a l\xc3\xa1togat\xc3\xb3 megmaradjon a mem\xc3\xb3ri\xc3\xa1ban. Gyakran ez az eset, ha egyszer kell egy m\xc5\xb1veletet v\xc3\xa9grehajtani egy hierarchia objektumain (l\xc3\xa1sd \xc3\xb6sszet\xc3\xa9tel programtervez\xc3\xa9si minta), p\xc3\xa9ld\xc3\xa1ul megsz\xc3\xa1molni a kamer\xc3\xa1kat._NEWLINE_Vannak esetek, amikor a l\xc3\xa1togat\xc3\xb3nak sok\xc3\xa1ig meg kell maradnia a mem\xc3\xb3ri\xc3\xa1ban. Ez \xc3\xa1ltal\xc3\xa1ban akkor fordul el\xc5\x91, ha parametriz\xc3\xa1lva van, \xc3\xa9s az adatokhoz k\xc3\xa9s\xc5\x91bb is hozz\xc3\xa1 kell f\xc3\xa9rni. P\xc3\xa9ld\xc3\xa1ul az \xc3\xb6sszegy\xc5\xb1jt\xc3\xb6tt renderel\xc3\xa9si opci\xc3\xb3kat t\xc3\xa1rolja._NEWLINE_Ha a l\xc3\xa1togat\xc3\xb3b\xc3\xb3l csak egy p\xc3\xa9ld\xc3\xa1ny kell, akkor van \xc3\xa9rtelme annak, hogy egyke legyen, \xc3\xa9s az egyszer haszn\xc3\xa1latos l\xc3\xa1togat\xc3\xb3hoz hasonl\xc3\xb3an legyen megval\xc3\xb3s\xc3\xadtva. Ekkor az egyszer haszn\xc3\xa1latos l\xc3\xa1togat\xc3\xb3 k\xc3\xa9s\xc5\x91bb is megh\xc3\xadvhat\xc3\xb3 ugyanazokkal a param\xc3\xa9terekkel.\n_START_SECTION_\nHaszn\xc3\xa1lati p\xc3\xa9ld\xc3\xa1k\n_START_PARAGRAPH_\nAz egyszer haszn\xc3\xa1latos l\xc3\xa1togat\xc3\xb3 oszt\xc3\xa1lymet\xc3\xb3dusok k\xc3\xb6zvet\xc3\xadt\xc3\xa9s\xc3\xa9vel h\xc3\xadvhat\xc3\xb3_NEWLINE_Param\xc3\xa9ter n\xc3\xa9lk\xc3\xbcl:_NEWLINE__NEWLINE_ Element* elem;_NEWLINE_ SingleServingVisitor::apply_to(elem);_NEWLINE_Param\xc3\xa9teresen:_NEWLINE__NEWLINE_ Element* elem;_NEWLINE_ TYPE param1, param2;_NEWLINE_ SingleServingVisitor::apply_to(elem, param1, param2);_NEWLINE_Egykek\xc3\xa9nt:_NEWLINE__NEWLINE_ Element* elem;_NEWLINE_ TYPE param1, param2;_NEWLINE_ SingleServingVisitor::set_param1(param1);_NEWLINE_ SingleServingVisitor::set_param2(param2);_NEWLINE_ SingleServingVisitor::apply_to(elem);\n_START_SECTION_\nMegval\xc3\xb3s\xc3\xadt\xc3\xa1sok\n_START_PARAGRAPH_\nAz al\xc3\xa1bbi megval\xc3\xb3s\xc3\xadt\xc3\xa1sok C++-ban \xc3\xadr\xc3\xb3dtak:\n_START_SECTION_\nParam\xc3\xa9terek n\xc3\xa9lk\xc3\xbcl\n_START_PARAGRAPH_\n// Declarationclass Element;class ElementA;class ElementB;class SingleServingVisitor;... // Same as with the [[visitor pattern]].// Definitionclass SingleServingVisitor {protected:_NEWLINE_    SingleServingVisitor();public:_NEWLINE_    ~SingleServingVisitor();_NEWLINE__NEWLINE_    static void apply_to(Element*);_NEWLINE_    virtual void visit_ElementA(ElementA*) = 0;_NEWLINE_    virtual void visit_ElementB(ElementB*) = 0;}// Implementationvoid SingleServingVisitor::apply_to(Element* elem) _NEWLINE_{_NEWLINE_    SingleServingVisitor ssv;_NEWLINE_    elem.accept(ssv);}\n_START_SECTION_\nParam\xc3\xa9teres\n_START_PARAGRAPH_\nHa a l\xc3\xa1togat\xc3\xb3 konstrukci\xc3\xb3j\xc3\xa1hoz param\xc3\xa9terek kellenek, azokat az oszt\xc3\xa1lymet\xc3\xb3dus veszi \xc3\xa1t:_NEWLINE_void SingleServingVisitor::apply_to(Element* elem, TYPE param1, TYPE param2, ...) _NEWLINE_{_NEWLINE_    SingleServingVisitor ssv(param1, param2, ...);_NEWLINE_    elem.accept(&ssv);}\n_START_SECTION_\nEgykek\xc3\xa9nt\n_START_PARAGRAPH_\nAz al\xc3\xa1bbi megval\xc3\xb3s\xc3\xadt\xc3\xa1s biztos\xc3\xadtja, hogy egy p\xc3\xa9ld\xc3\xa1ny legyen, \xc3\xa9s a l\xc3\xa1togat\xc3\xb3 k\xc3\xa9s\xc5\x91bb is hozz\xc3\xa1f\xc3\xa9rhet\xc5\x91 legyen:_NEWLINE_// Definitionclass SingleServingVisitor {protected:_NEWLINE_    static SingleServingVisitor* instance_;_NEWLINE_    TYPE param1_;_NEWLINE_    TYPE param2_;_NEWLINE__NEWLINE_    SingleServingVisitor();_NEWLINE__NEWLINE_    static SingleServingVisitor* get_instance();_NEWLINE_    // Note: get_instance method does not need to be publicpublic:_NEWLINE_    ~SingleServingVisitor();_NEWLINE__NEWLINE_    static void apply_to(Element*);_NEWLINE__NEWLINE_    // static methods to access parameters_NEWLINE_    static void set_param1(TYPE);_NEWLINE_    static void set_param2(TYPE);_NEWLINE__NEWLINE_    virtual void visit_ElementA(ElementA*) = 0;_NEWLINE_    virtual void visit_ElementB(ElementB*) = 0;}// ImplementationSingleServingVisitor* SingleServingVisitor::instance_ = NULL;SingleServingVisitor* SingleServingVisitor::get_instance() _NEWLINE_{_NEWLINE_    if (this->instance_ == NULL)_NEWLINE_        this->instance_ = new SingleServingVisitor();_NEWLINE_    return this->instance_;}void SingleServingVisitor::apply_to(Element* elem) _NEWLINE_{_NEWLINE_    elem->accept(get_instance());}void SingleServingVisitor::set_param1(TYPE param1) _NEWLINE_{_NEWLINE_    getInstance()->param1_ = param1;}void SingleServingVisitor::set_param2(TYPE param2) _NEWLINE_{_NEWLINE_    getInstance()->param2_ = param2;}'