Enable NAT in VB machine network settings, set port mapping e.g. SOME_HOST_PORT->3389 (remote desktop) and SOME_HOST_PORT->22(ssh)
To start VB as windows service use vboxvmservice.
References
http://vboxvmservice.sourceforge.net/
http://support.microsoft.com/kb/304304/
http://code.google.com/p/phpvirtualbox/
http://code.google.com/p/virtualboxservice/
http://www.techques.com/question/2-188105/Virtualbox-Start-VM-Headless-on-Windows
http://www2.ece.ohio-state.edu/computing/rdpssh.html
https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding
piątek, 20 lutego 2015
poniedziałek, 9 lutego 2015
non-intrusive compile-time types registration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
// here is non-intrusive (no need for explicit types list specification) | |
// solution for compile-time types registration | |
// based on idea from http://stackoverflow.com/questions/6399804 | |
// mixin class to register statically - general - context defined with Flavor | |
template<class Derived, class Flavor> | |
class StaticRegistrar{ | |
static char _enforce_registration; // will be instantiated upon program start | |
// trick to force static member initialization | |
// found at http://stackoverflow.com/questions/6420985 | |
template<typename T, T> struct kind_of_magic { }; | |
typedef kind_of_magic<char&, _enforce_registration> __enforce_registration; | |
}; | |
// template declaration for Registry | |
template<class RegistryFlavor> | |
class Registry | |
{}; | |
// function wrapper for static field to avoid "static initialization order fiasco" | |
template<class Flavor> | |
Registry<Flavor>& GetRegistry(){ | |
static Registry<Flavor> _registry; | |
return _registry; | |
} | |
// static member initializer, but really is registration invoker | |
template<class T, class Flavor> | |
char RegisterType(){ | |
GetRegistry<Flavor>().template doRegistration<T>(); | |
return 0; // doesn't matter, never used. | |
} | |
// static member field definition and initialization | |
template<class Derived, class Flavor> | |
char StaticRegistrar<Derived, Flavor>::_enforce_registration = RegisterType<Derived, Flavor>(); | |
// different contexts - no detailed definition needed here - only marker classes | |
class IntFlavorRegistry | |
{}; | |
class CharFlavorRegistry | |
{}; | |
// some concrete base class perhaps abstract, normal base stuff... | |
class EntityBase{ | |
//... | |
}; | |
// base class with required contexts specified | |
// note CRTP required for registrars | |
template<class Derived> | |
class Entity | |
: public EntityBase, | |
public StaticRegistrar<Derived, IntFlavorRegistry>, | |
public StaticRegistrar<Derived, CharFlavorRegistry> | |
{}; | |
// actual type 1 | |
// required contexts definitions | |
class EntityType1 : public Entity<EntityType1>{ | |
public: | |
static int helloint(){ | |
return 1; | |
} | |
static int hellochar(){ | |
return 'a'; | |
} | |
}; | |
// actual type 2 | |
// required contexts definitions | |
class EntityType2 : public Entity<EntityType2>{ | |
public: | |
static int helloint(){ | |
return 2; | |
} | |
static int hellochar(){ | |
return 'b'; | |
} | |
}; | |
// Registry for IntFlavor | |
template<> | |
class Registry<IntFlavorRegistry>{ | |
public: | |
int value; | |
template<class T> | |
void doRegistration(){ | |
value |= T::helloint(); | |
} | |
}; | |
// Registry for CharFlavor | |
template<> | |
class Registry<CharFlavorRegistry>{ | |
public: | |
string value; | |
template<class T> | |
void doRegistration(){ | |
value += T::hellochar(); | |
} | |
}; | |
int main(){ | |
// no even need for instances | |
// EntityType1 q; | |
cout << GetRegistry<IntFlavorRegistry>().value << endl; // 3 printed | |
cout << GetRegistry<CharFlavorRegistry>().value << endl; // 'ab' printed | |
return 0; | |
} |
Note - above does not work with VS compilers.
Generally this approach should be avoided, but nice to know:)
Subskrybuj:
Posty (Atom)