#pragma once 
#include <vector>
#include <string>
#include <sstream>
#include <netdb.h>

#include <iostream>
#include <thread>
#include <atomic>


namespace SimCore {


    class UtilFunctions
    {
        public:
            static std::vector<std::string> explode(std::string const & s, char delim);
            static std::string implode(const std::vector<std::string> &v , char delim);

            static bool isNumber(const std::string& s);
            static void check_host_name(int hostname);
            static void check_host_entry(struct hostent * hostentry);
            static void IP_formatter(char *IPbuffer);
            static std::string getOwnIP();
            static double DegToRad(double deg);
            static double RadToDeg(double rad);

    };


class AsyncWorker {
	std::atomic<bool> active{true};
	
    public:
        ~AsyncWorker(){
            stop();
        }

        void work(auto function)
        {
           active = true;
        std::thread t([=,this]() {
            while(active.load()) {
            function();
        }
        });
        t.detach();
        }
        void stop()
        {
            active = false;

        }

};



}