| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * Registry<Action>.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Jan 7, 2010
|
|---|
| 12 | * Author: crueger
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include "Actions/ActionRegistry.hpp"
|
|---|
| 23 | #include "CodePatterns/Singleton_impl.hpp"
|
|---|
| 24 | #include "CodePatterns/Registry_impl.hpp"
|
|---|
| 25 |
|
|---|
| 26 | using namespace MoleCuilder;
|
|---|
| 27 |
|
|---|
| 28 | /** Constructor for class ActionRegistry.
|
|---|
| 29 | */
|
|---|
| 30 | ActionRegistry::ActionRegistry()
|
|---|
| 31 | {}
|
|---|
| 32 |
|
|---|
| 33 | /** Destructor for class ActionRegistry.
|
|---|
| 34 | */
|
|---|
| 35 | ActionRegistry::~ActionRegistry()
|
|---|
| 36 | {
|
|---|
| 37 | cleanup();
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | /** Just passes on call to Registry<Action>::getByName().
|
|---|
| 41 | * \param name name of Action
|
|---|
| 42 | * \return pointer to Action
|
|---|
| 43 | */
|
|---|
| 44 | Action* ActionRegistry::getActionByName(const std::string name)
|
|---|
| 45 | {
|
|---|
| 46 | return getByName(name);
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | /** Just passes on call to Registry<Action>::isPresentByName().
|
|---|
| 50 | * \param name name of Action
|
|---|
| 51 | * \return true - Action instance present, false - not
|
|---|
| 52 | */
|
|---|
| 53 | bool ActionRegistry::isActionPresentByName(const std::string name) const
|
|---|
| 54 | {
|
|---|
| 55 | return isPresentByName(name);
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | /** Returns the last present action position in the requested menu.
|
|---|
| 59 | * \param &token token of the menu
|
|---|
| 60 | * \return last used position
|
|---|
| 61 | */
|
|---|
| 62 | int ActionRegistry::getLastPosition(const std::string &token) const
|
|---|
| 63 | {
|
|---|
| 64 | int position = 0;
|
|---|
| 65 | for (const_iterator iter = getBeginIter();
|
|---|
| 66 | iter != getEndIter();
|
|---|
| 67 | ++iter) {
|
|---|
| 68 | const std::string &MenuName = (iter->second)->Traits.getMenuName();
|
|---|
| 69 | const int &MenuPosition = (iter->second)->Traits.getMenuPosition();
|
|---|
| 70 | if ((MenuName == token) && (position < MenuPosition))
|
|---|
| 71 | position = MenuPosition;
|
|---|
| 72 | }
|
|---|
| 73 | return position;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | CONSTRUCT_SINGLETON(ActionRegistry)
|
|---|
| 78 | CONSTRUCT_REGISTRY(Action)
|
|---|