//
//  main.cpp
//  Exercise 12.19
//
//  Created by Steven Wiseman on 19/03/2025.
//

#include <iostream>
#include <vector>
#include <memory>

class StrBlob {
    
    friend class StrBlobPtr;
    
public:
    
    std::vector<std::string> word;
    
    // constructor
    
    StrBlob (std::vector <std::string> input) {
        
        for (auto i : input)
            word.push_back(i);
    }
    
    void write () {
        
        for (auto i : word)
            std::cout << i << std::endl;
    }
    
    // size operations
    
    size_t size () {
        
        return word.size();
        
    }
    
    // add and remove elements
    
    void push_back (std::string more) {
        
        word.push_back(more);
        
    }
    
    void pop_back () {}
    
    // element access
    
    std::string front ();
    std::string back ();
    
private:
    // interface to StrBlobPtr
        
};

class StrBlobPtr {
    
public:
    
    StrBlobPtr () {}
    
    void push_back (StrBlob* b) {
        
        blobContainer.push_back(b);
        
    }
    
    //std::weak_ptr<std::vector<std::string>> wptr;
    
    std::vector <StrBlob*> blobContainer;
    
};


int main(int argc, const char * argv[]) {
    
    std::vector <std::string> Wiseman_1;
    Wiseman_1.push_back("Sabbath");
    Wiseman_1.push_back("Bloody");
    Wiseman_1.push_back("Sabbath");
    Wiseman_1.push_back("You");
    Wiseman_1.push_back("Ozzy");
    
    StrBlob* Kay = new StrBlob (Wiseman_1);
    
    //auto Kay = std::make_shared<StrBlob>(Wiseman_1);
    
    //Kay->write();
       
    std::cout << Kay->size() << std::endl;
    
    Kay->push_back("love");
    
    //Kay->write();
    
    // StrBlobPtr
       
    //StrBlob* b = new StrBlob (Wiseman);
    
    //StrBlobPtr* wisey = new StrBlobPtr (b);
    
    std::vector <std::string> Wiseman_2;
    Wiseman_2.push_back("Hallowed");
    Wiseman_2.push_back("Be");
    Wiseman_2.push_back("Thy");
    Wiseman_2.push_back("Name");
    
    StrBlob* b1 = new StrBlob (Wiseman_2);
    
    //auto b1 = std::make_shared<StrBlob>(Wiseman_2);
    
    //b1->write();
    
    std::vector <std::string> Wiseman_3;
    Wiseman_3.push_back("The");
    Wiseman_3.push_back("Trooper");
    
    StrBlob* b2 = new StrBlob (Wiseman_3);
    
    //auto b2 = std::make_shared<StrBlob>(Wiseman_3);
    
    //b2->write();
    
    //auto wisey = std::make_shared<StrBlobPtr>();
    
    auto wisey = std::make_shared<StrBlobPtr>();
    
    wisey->push_back(Kay);
    wisey->push_back(b1);
    wisey->push_back(b2);
    
    for (auto i : wisey->blobContainer) {
        
        i->write();
        
    }
    
    
    
    return 0;
}
