本文整理汇总了C++中Version::GetMajor方法的典型用法代码示例。如果您正苦于以下问题:C++ Version::GetMajor方法的具体用法?C++ Version::GetMajor怎么用?C++ Version::GetMajor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Version
的用法示例。
在下文中一共展示了Version::GetMajor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadModule
ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
{
if (modname.empty())
return MOD_ERR_PARAMS;
if (FindModule(modname))
return MOD_ERR_EXISTS;
Log(LOG_DEBUG) << "trying to load [" << modname << "]";
/* Generate the filename for the temporary copy of the module */
Anope::string pbuf = services_dir + "/modules/runtime/" + modname + ".so.XXXXXX";
/* Don't skip return value checking! -GD */
ModuleReturn ret = moduleCopyFile(modname, pbuf);
if (ret != MOD_ERR_OK)
return ret;
dlerror();
void *handle = dlopen(pbuf.c_str(), RTLD_LAZY);
const char *err = dlerror();
if (!handle && err && *err)
{
Log() << err;
return MOD_ERR_NOLOAD;
}
dlerror();
Module *(*func)(const Anope::string &, const Anope::string &) = function_cast<Module *(*)(const Anope::string &, const Anope::string &)>(dlsym(handle, "AnopeInit"));
err = dlerror();
if (!func && err && *err)
{
Log() << "No init function found, not an Anope module";
dlclose(handle);
return MOD_ERR_NOLOAD;
}
if (!func)
throw CoreException("Couldn't find constructor, yet moderror wasn't set?");
/* Create module. */
Anope::string nick;
if (u)
nick = u->nick;
Module *m;
try
{
m = func(modname, nick);
}
catch (const ModuleException &ex)
{
Log() << "Error while loading " << modname << ": " << ex.GetReason();
return MOD_ERR_EXCEPTION;
}
m->filename = pbuf;
m->handle = handle;
Version v = m->GetVersion();
if (v.GetMajor() < Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() < Anope::VersionMinor()))
{
Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionMajor() << "." << Anope::VersionMinor();
DeleteModule(m);
return MOD_ERR_VERSION;
}
else if (v.GetMajor() > Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() > Anope::VersionMinor()))
{
Log() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionMajor() << "." << Anope::VersionMinor();
DeleteModule(m);
return MOD_ERR_VERSION;
}
else if (v.GetBuild() < Anope::VersionBuild())
Log() << "Module " << modname << " is compiled against an older revision of Anope " << v.GetBuild() << ", this is " << Anope::VersionBuild();
else if (v.GetBuild() > Anope::VersionBuild())
Log() << "Module " << modname << " is compiled against a newer revision of Anope " << v.GetBuild() << ", this is " << Anope::VersionBuild();
else if (v.GetBuild() == Anope::VersionBuild())
Log(LOG_DEBUG) << "Module " << modname << " compiled against current version of Anope " << v.GetBuild();
if (m->type == PROTOCOL && ModuleManager::FindFirstOf(PROTOCOL) != m)
{
DeleteModule(m);
Log() << "You cannot load two protocol modules";
return MOD_ERR_UNKNOWN;
}
FOREACH_MOD(I_OnModuleLoad, OnModuleLoad(u, m));
return MOD_ERR_OK;
}
示例2: OpenVersion
Bool OpenGLGraphicDeviceLinux::OpenVersion( const RenderWindow & p_RenderOutput,
const Version & p_Version )
{
// Make sure the graphic device is not already open
if( m_Open )
{
std::cout << "[OpenGLGraphicDeviceLinux::Open] Already open.\n";
return false;
}
// Make sure the window is open
if( !p_RenderOutput.IsOpen( ) )
{
std::cout << "[OpenGLGraphicDeviceLinux::Open] The window is not open.\n";
return false;
}
// Get the Linux window by casting the Window class
/* const WindowLinux * pWindow = reinterpret_cast<const WindowLinux *>( &p_Window );
m_pWindowLinux = const_cast<WindowLinux *>( pWindow );
*/
// Get the window and display devices
::Display * pDisplay = p_RenderOutput.GetDisplayDevice( );
::Window window = p_RenderOutput.GetWindowDevice( );
int screen = p_RenderOutput.GetScreenDevice( );
// Error check the window and display devices.
if( pDisplay == NULL )
{
std::cout << "[OpenGLGraphicDeviceLinux::Open] The display from the renderOutput is NULL.\n";
return false;
}
if( window == 0 )
{
std::cout << "[OpenGLGraphicDeviceLinux::Open] The window from the renderOutput is 0.\n";
return false;
}
// Create the visual information
GLint Att[] =
{
GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 16,
GLX_STENCIL_SIZE, 8,
0L, 0L
};
int fbElements = 0;
::GLXFBConfig *fbc = glXChooseFBConfig( pDisplay, screen, 0, &fbElements);
::XVisualInfo * pVisualInfo = NULL;
if( (pVisualInfo = glXChooseVisual( pDisplay, 0, Att ) ) == NULL )
{
std::cout << "[OpenGLGraphicDeviceLinux::Open] Can not choose visual information.\n";
return false;
}
// Create the color map and set it
if( !(m_Colormap = XCreateColormap( pDisplay, RootWindow( pDisplay, screen), pVisualInfo->visual, AllocNone ) ) )
{
std::cout << "[OpenGLGraphicDeviceLinux::Open] Can not create the colormap.\n";
XFree( pVisualInfo );
return false;
}
// Set the new color map
XSetWindowColormap( pDisplay, window, m_Colormap );
// Create a temporary context.
::GLXContext temporaryContext = glXCreateContext( pDisplay, pVisualInfo, NULL, GL_TRUE );
if( !temporaryContext )
{
std::cout << "[OpenGLGraphicDeviceLinux::Open] Can not create a regual OpenGL context.\n";
XFree( pVisualInfo );
return false;
}
// Make the temporary context to the current one.
glXMakeCurrent( pDisplay, window, temporaryContext );
// Clear the visual info since we are done with it.
XFree( pVisualInfo );
// Attributes for the OGL 3.3 context
int attribs[ ] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, static_cast<int>( p_Version.GetMajor( ) ),
GLX_CONTEXT_MINOR_VERSION_ARB, static_cast<int>( p_Version.GetMinor( ) ),
0
};
// We need the proc address for the function
//.........这里部分代码省略.........