ptt_ptr ptt::factory(const std::string& mode) { if (mode == "null") { return ptt_ptr(new ptt_dummy()); } else if (mode == "serial") { #ifdef __unix__ return ptt_ptr(new ptt_serial_unix()); #endif #ifdef _MSC_VER return ptt_ptr(new ptt_serial_windows()); #endif } else if (mode == "parallel") { #ifdef __unix__ return ptt_ptr(new ptt_parallel_unix()); #endif #ifdef _MSC_VER throw extexception("ptt::factory unsupported mode '" + mode + "'"); /* return ptt_ptr(new ptt_parallel_windows()); */ #endif } else if (mode == "gpio") { #ifdef __unix__ return ptt_ptr(new ptt_gpio_unix()); #endif #ifdef _MSC_VER throw extexception("ptt::factory unsupported mode '" + mode + "'"); #endif } throw extexception("ptt::factory unknown mode '" + mode + "'"); //return ptt_ptr(); }
ptt_ptr ptt::factory() { #ifdef __unix__ return ptt_ptr(new ptt_serial_unix()); #endif #ifdef _MSC_VER return ptt_ptr(new ptt_serial_windows()); #endif return ptt_ptr(); }