Can code duplication be avoided here?
<p>I have a class called TableManager. It reads a file that has informtion that gets turned into TableData (a struct) and stored in an array of TableData. It then reads the TableData to load Tables. Tables have 2 bitmaps and a few string attributes.</p>

<p>I then have a BackgroundManager that almost does the same thing, but it is different enough where an abstract or template class does not seem possible. The backgrounds also load from file, but their attributes are different. They also only have 1 bitmap, and a few more float attributes. It uses a BackgroundData struct.</p>

<p>Is there something I'm overlooking or is it okay to duplicate code in this situation?</p>

<p>Thanks</p>

<pre><code>    struct BackgroundData
    {
        Sprite* m_thumbnail;
        std::string m_backgroundPath;
        std::string m_name;
        float m_scale;
        float m_offsetX;
        float m_offsetY;

        BackgroundData(Sprite* thumbnail, std::string backgroundPath, 
            float offsetX, float offsetY, float scale,
            std::string name)
            : m_thumbnail(thumbnail), m_backgroundPath(backgroundPath), 
            m_offsetX(offsetX), m_offsetY(offsetY), m_scale(scale),
            m_name(name)
        {
        }
    };

    class BackgroundManager
    {
        std::list&lt;BackgroundData&gt; m_backgrounds;
        bool _loadBackgrounds(const std::string&amp; path, const std::string&amp; bgFile);
        Sprite* m_currentBackground;
        BackgroundData* m_currentBackgroundData;
        void _cleanBackground();
        void _cleanBackgrounds();
    public:
        BackgroundManager(const std::string&amp; path, const std::string&amp; tableFile);
        bool loadBackground(BackgroundData* data);
        bool isBackgroundLoaded() const;
        BackgroundData* getCurrentBackgroundData() const;
        Sprite* getCurrentBackground() const;
        BackgroundData* getBackgroundByName(const std::string&amp; name);
        int getBackgroundCount() const;
        std::list&lt;BackgroundData&gt;::iterator begin();
        std::list&lt;BackgroundData&gt;::iterator end();
        BackgroundData* getBackgroundAt(int index);
        virtual ~BackgroundManager(void);
    };

struct TableData
    {
        Sprite* m_thumbnail;
        std::string m_tablePath;
        std::string m_tableShadowPath;
        std::string m_name;

        TableData(Sprite* thumbnail, std::string tablePath, 
            std::string tableShadowPath, std::string name)
            : m_thumbnail(thumbnail), m_tablePath(tablePath),
            m_tableShadowPath(tableShadowPath), m_name(name)
        {

        }
    };

    class TableManager
    {
        std::list&lt;TableData&gt; m_tables;
        bool _loadTables(const std::string&amp; path, const std::string&amp; tableFile);
        Sprite* m_currentTable;
        Sprite* m_currentTableShadow;
        TableData* m_currentTableData;
        void _cleanTable();
        void _cleanTables();
    public:
        TableManager(const std::string&amp; path, const std::string&amp; tableFile);
        bool loadTable(TableData* data);
        bool isTableLoaded() const;
        TableData* getCurrentTableData() const;
        Sprite* getCurrentTable() const;
        Sprite* getCurrentTableShadow() const;
        TableData* getTableByName(const std::string&amp; name);
        int getTableCount() const;
        std::list&lt;TableData&gt;::iterator begin();
        std::list&lt;TableData&gt;::iterator end();
        TableData* getTableAt(int index);
        virtual ~TableManager(void);
    };
</code></pre>
