summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2016-08-24 21:46:03 +1000
committer Vas Crabb <vas@vastheman.com>2016-08-24 21:46:03 +1000
commit411ef56a8652e3565776fdac67249d2eb26fdb6a (patch)
tree1e151c6143f3b383acec9ca083297420cfd50bd7 /src
parent0a58a5a05e7ada5e1ba1d3c688468581ca4359d9 (diff)
shared_ptr arrays need love, too
Diffstat (limited to 'src')
-rw-r--r--src/emu/devfind.h54
1 files changed, 30 insertions, 24 deletions
diff --git a/src/emu/devfind.h b/src/emu/devfind.h
index 5b48ad04862..d4a7a7defa9 100644
--- a/src/emu/devfind.h
+++ b/src/emu/devfind.h
@@ -503,46 +503,52 @@ public:
// ======================> shared_ptr_array_finder
// shared pointer array finder template
-template<typename _PointerType, int _Count, bool _Required>
-class shared_ptr_array_finder
+template <typename PointerType, unsigned Count, bool Required>
+class shared_ptr_array_finder : public array_finder_base<shared_ptr_finder<PointerType, Required>, Count>
{
- typedef shared_ptr_finder<_PointerType, _Required> shared_ptr_type;
-
public:
- // construction/destruction
- shared_ptr_array_finder(device_t &base, const char *basetag, UINT8 width = sizeof(_PointerType) * 8)
+ template <typename F>
+ shared_ptr_array_finder(device_t &base, F const &fmt, unsigned start)
+ : array_finder_base<shared_ptr_finder<PointerType, Required>, Count>(base, fmt, start)
+ {
+ }
+
+ shared_ptr_array_finder(device_t &base, const char *basetag)
+ : array_finder_base<shared_ptr_finder<PointerType, Required>, Count>(base, basetag)
{
- for (int index = 0; index < _Count; index++)
- {
- m_tag[index] = string_format("%s.%d", basetag, index);
- m_array[index] = std::make_unique<shared_ptr_type>(base, m_tag[index].c_str(), width);
- }
}
- // array accessors
- const shared_ptr_type &operator[](int index) const { assert(index < _Count); return *m_array[index]; }
- shared_ptr_type &operator[](int index) { assert(index < _Count); return *m_array[index]; }
+ shared_ptr_array_finder(device_t &base, char const *const tags[])
+ : array_finder_base<shared_ptr_finder<PointerType, Required>, Count>(base, tags)
+ {
+ }
-protected:
- // internal state
- std::unique_ptr<shared_ptr_type> m_array[_Count];
- std::string m_tag[_Count];
+ shared_ptr_array_finder(device_t &base, std::array<char const *, Count> const &tags)
+ : array_finder_base<shared_ptr_finder<PointerType, Required>, Count>(base, tags)
+ {
+ }
};
// optional shared pointer array finder
-template<class _PointerType, int _Count>
-class optional_shared_ptr_array : public shared_ptr_array_finder<_PointerType, _Count, false>
+template <typename PointerType, unsigned Count>
+class optional_shared_ptr_array : public shared_ptr_array_finder<PointerType, Count, false>
{
public:
- optional_shared_ptr_array(device_t &base, const char *tag, UINT8 width = sizeof(_PointerType) * 8) : shared_ptr_array_finder<_PointerType, _Count, false>(base, tag, width) { }
+ template <typename F> optional_shared_ptr_array(device_t &base, F const &fmt, unsigned start) : shared_ptr_array_finder<PointerType, Count, false>(base, fmt, start) { }
+ optional_shared_ptr_array(device_t &base, char const *basetag) : shared_ptr_array_finder<PointerType, Count, false>(base, basetag) { }
+ optional_shared_ptr_array(device_t &base, char const *const tags[]) : shared_ptr_array_finder<PointerType, Count, false>(base, tags) { }
+ optional_shared_ptr_array(device_t &base, std::array<char const *, Count> const &tags) : shared_ptr_array_finder<PointerType, Count, false>(base, tags) { }
};
// required shared pointer array finder
-template<class _PointerType, int _Count>
-class required_shared_ptr_array : public shared_ptr_array_finder<_PointerType, _Count, true>
+template <typename PointerType, unsigned Count>
+class required_shared_ptr_array : public shared_ptr_array_finder<PointerType, Count, true>
{
public:
- required_shared_ptr_array(device_t &base, const char *tag, UINT8 width = sizeof(_PointerType) * 8) : shared_ptr_array_finder<_PointerType, _Count, true>(base, tag, width) { }
+ template <typename F> required_shared_ptr_array(device_t &base, F const &fmt, unsigned start) : shared_ptr_array_finder<PointerType, Count, true>(base, fmt, start) { }
+ required_shared_ptr_array(device_t &base, char const *basetag) : shared_ptr_array_finder<PointerType, Count, true>(base, basetag) { }
+ required_shared_ptr_array(device_t &base, char const *const tags[]) : shared_ptr_array_finder<PointerType, Count, true>(base, tags) { }
+ required_shared_ptr_array(device_t &base, std::array<char const *, Count> const &tags) : shared_ptr_array_finder<PointerType, Count, true>(base, tags) { }
};