| 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 | /** Constructor for class ActionRegistry.
|
|---|
| 27 | */
|
|---|
| 28 | ActionRegistry::ActionRegistry()
|
|---|
| 29 | {}
|
|---|
| 30 |
|
|---|
| 31 | /** Destructor for class ActionRegistry.
|
|---|
| 32 | */
|
|---|
| 33 | ActionRegistry::~ActionRegistry()
|
|---|
| 34 | {
|
|---|
| 35 | cleanup();
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | /** Just passes on call to Registry<Action>::getByName().
|
|---|
| 39 | * \param name name of Action
|
|---|
| 40 | * \return pointer to Action
|
|---|
| 41 | */
|
|---|
| 42 | Action* ActionRegistry::getActionByName(const std::string name)
|
|---|
| 43 | {
|
|---|
| 44 | return getByName(name);
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | /** Just passes on call to Registry<Action>::isPresentByName().
|
|---|
| 48 | * \param name name of Action
|
|---|
| 49 | * \return true - Action instance present, false - not
|
|---|
| 50 | */
|
|---|
| 51 | bool ActionRegistry::isActionPresentByName(const std::string name) const
|
|---|
| 52 | {
|
|---|
| 53 | return isPresentByName(name);
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | /** Returns the last present action position in the requested menu.
|
|---|
| 57 | * \param &token token of the menu
|
|---|
| 58 | * \return last used position
|
|---|
| 59 | */
|
|---|
| 60 | int ActionRegistry::getLastPosition(const std::string &token) const
|
|---|
| 61 | {
|
|---|
| 62 | int position = 0;
|
|---|
| 63 | for (const_iterator iter = getBeginIter();
|
|---|
| 64 | iter != getEndIter();
|
|---|
| 65 | ++iter) {
|
|---|
| 66 | const std::string &MenuName = (iter->second)->Traits.getMenuName();
|
|---|
| 67 | const int &MenuPosition = (iter->second)->Traits.getMenuPosition();
|
|---|
| 68 | if ((MenuName == token) && (position < MenuPosition))
|
|---|
| 69 | position = MenuPosition;
|
|---|
| 70 | }
|
|---|
| 71 | return position;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 | CONSTRUCT_SINGLETON(ActionRegistry)
|
|---|
| 76 | CONSTRUCT_REGISTRY(Action)
|
|---|