File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ class HasClassRegistry
6767 // / Return true if string is a registered string type or its alias.
6868 static bool isRegisteredType (const std::string& tp);
6969
70+ // / Return a map of string aliases to standard type strings.
71+ static std::map<std::string, std::string> getAliasedTypes ();
72+
7073 // / Return a set of all registered string types
7174 static std::set<std::string> getRegisteredTypes ();
7275
Original file line number Diff line number Diff line change @@ -105,6 +105,25 @@ HasClassRegistry<TBase>::isRegisteredType(const std::string& tp)
105105}
106106
107107
108+ template <class TBase >
109+ std::map<std::string, std::string>
110+ HasClassRegistry<TBase>::getAliasedTypes()
111+ {
112+ using namespace std ;
113+ map<string, string> rv;
114+ const RegistryStorage& reg = getRegistry ();
115+ typename RegistryStorage::const_iterator irg = reg.begin ();
116+ for (; irg != reg.end (); ++irg)
117+ {
118+ if (irg->first != irg->second ->type ())
119+ {
120+ rv[irg->first ] = irg->second ->type ();
121+ }
122+ }
123+ return rv;
124+ }
125+
126+
108127template <class TBase >
109128std::set<std::string>
110129HasClassRegistry<TBase>::getRegisteredTypes()
Original file line number Diff line number Diff line change @@ -51,6 +51,17 @@ class TestHasClassRegistry : public CxxTest::TestSuite
5151 TS_ASSERT_EQUALS (false , mpreg->isRegisteredType (" invalid" ));
5252 }
5353
54+
55+ void test_getAliasedTypes ()
56+ {
57+ std::map<std::string, std::string> atps;
58+ atps = ScatteringFactorTable::getAliasedTypes ();
59+ TS_ASSERT_EQUALS (4 , atps.size ());
60+ TS_ASSERT (atps.count (" X" ));
61+ TS_ASSERT_EQUALS (" xray" , atps[" X" ]);
62+ TS_ASSERT_EQUALS (" electronnumber" , atps[" EN" ]);
63+ }
64+
5465}; // class TestHasClassRegistry
5566
5667// End of file
You can’t perform that action at this time.
0 commit comments