本文整理汇总了C++中CModule类的典型用法代码示例。如果您正苦于以下问题:C++ CModule类的具体用法?C++ CModule怎么用?C++ CModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tscGetVersion
tsc_result TSC_CALLTYPE
tscGetVersion( TSC_VERSION_DATA* pData )
{
tsc_func_init();
CModule* pM = CModule::GetInstance();
if (!pM)
return Error_Internal_NullModulePtr();
if (!pData)
return Error_ParamWasNull();
if (pData->cbSize != sizeof(TSC_VERSION_DATA))
return Error_StructSizeInvalid();
CVersionData d(*pData);
tsc_result r = TSC_E_FAIL;
r = pM->GetVersion(d);
if (TSC_SUCCEEDED(r))
{
*pData << d;
}
return r;
}
示例2: CreateModule
IModule * CreateModule(const IRepository *rep, const std::_tstring &label, const ECLModule * data)
{
CModule * mod = CreateModuleRaw(rep, label.c_str(), false);
ATLASSERT(mod);
mod->Update(data);
return mod;
}
示例3: UpdateModule
bool CUser::UpdateModule(const CString &sModule) {
const map<CString,CUser*>& Users = CZNC::Get().GetUserMap();
map<CString,CUser*>::const_iterator it;
map<CUser*, CString> Affected;
map<CUser*, CString>::iterator it2;
bool error = false;
for (it = Users.begin(); it != Users.end(); ++it) {
CModule *pMod = it->second->GetModules().FindModule(sModule);
if (pMod) {
Affected[it->second] = pMod->GetArgs();
it->second->GetModules().UnloadModule(pMod->GetModName());
}
}
CString sErr;
for (it2 = Affected.begin(); it2 != Affected.end(); ++it2) {
if (!it2->first->GetModules().LoadModule(sModule, it2->second, it2->first, sErr)) {
error = true;
DEBUG("Failed to reload [" << sModule << "] for [" << it2->first->GetUserName()
<< "]: " << sErr);
}
}
return !error;
}
示例4: MGetMsg
const char *WINAPI MGetMsg(int PluginNumber,int MsgId)
{
CModule *module = (CModule *)PluginNumber;
if (!module)
return "";
return module->GetMsg(MsgId);
}
示例5: FindModule
bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
CString sMod = sModule; // Make a copy incase the reference passed in is from CModule::GetModName()
CModule* pModule = FindModule(sMod);
sRetMsg = "";
if (!pModule) {
sRetMsg = "Module [" + sMod + "] not loaded.";
return false;
}
bool bSuccess;
GLOBALMODULECALL(OnModuleUnloading(pModule, bSuccess, sRetMsg), pModule->GetUser(), NULL, return bSuccess);
ModHandle p = pModule->GetDLL();
if (p) {
delete pModule;
for (iterator it = begin(); it != end(); ++it) {
if (*it == pModule) {
erase(it);
break;
}
}
dlclose(p);
sRetMsg = "Module [" + sMod + "] unloaded";
return true;
}
sRetMsg = "Unable to unload module [" + sMod + "]";
return false;
}
示例6: if
void CWell::HandleCollision(IEntity* other)
{
SGD::Vector dir;
if ( tier >= 3 && (duration - timer) < 0.1f)
{
dir = other->GetPosition() - position;
dir.Normalize();
other->AddGravity(dir * strength * 2);
EntityType type = (EntityType)other->GetType();
if (type == EntityType::Asteroid)
{
CAsteroid* ast = dynamic_cast<CAsteroid*>(other);
ast->TakeDamage(int(strength * 0.075f));
}
else if (type >= EntityType::Player && type <= EntityType::Coordinator)
{
CShip* ship = dynamic_cast<CShip*>(other);
ship->TakeDamage(int(strength * 0.075f));
}
else if (type >= EntityType::BaseModule && type <= EntityType::WarpModule)
{
CModule* mod = dynamic_cast<CModule*>(other);
mod->TakeDamage(int(strength * 0.075f));
}
return;
}
dir = position - other->GetPosition();
if (dir.ComputeLength() < 1)
dir.y += 1;
dir.Normalize();
//float mass = other->GetSize().width * other->GetSize().height;
other->AddGravity(dir * strength);
}
示例7: main
int main(int argc, char *argv[])
{
int i = 1;
while (i < argc) {
// scanning, parsing & semantical analysis
CScanner *s = new CScanner(new ifstream(argv[i]));
CParser *p = new CParser(s);
cout << "parsing '" << argv[i] << "'..." << endl;
CAstNode *ast = p->Parse();
if (p->HasError()) {
const CToken *error = p->GetErrorToken();
cout << "parse error : at " << error->GetLineNumber() << ":"
<< error->GetCharPosition() << " : "
<< p->GetErrorMessage() << endl;
} else {
// AST to TAC conversion
cout << "converting to TAC..." << endl;
CModule *m = new CModule(ast);
// print TAC to console
cout << m << endl;
cout << endl;
// output TAC as .dot and generate a PDF file from it
ofstream out(string(argv[i]) + ".dot");
out << "digraph IR {" << endl
<< " graph [fontname=\"Times New Roman\",fontsize=10];" << endl
<< " node [fontname=\"Courier New\",fontsize=10];" << endl
<< " edge [fontname=\"Times New Roman\",fontsize=10];" << endl
<< endl;
m->toDot(out, 2);
const vector<CScope*> &proc = m->GetSubscopes();
for (size_t p=0; p<proc.size(); p++) {
proc[p]->toDot(out, 2);
}
out << "}" << endl;
out.flush();
ostringstream cmd;
cmd << "dot -Tpdf -o" << argv[i] << ".pdf " << argv[i] << ".dot";
cout << "run the following command to convert the .dot file into a PDF:" << endl
<< " " << cmd.str() <<
endl;
delete m;
}
cout << endl << endl;
i++;
}
cout << "Done." << endl;
return EXIT_SUCCESS;
}
示例8: tsc_func_init
void tsc_func_init()
{
s_szLastError = s_szErrNoErr;
CModule* pM = CModule::GetInstance();
if (pM)
pM->ClearLastError();
}
示例9: EnterCriticalSection
void CAppSignal::OnWorkspace(class CUIWorkspace* pUIWorkspace, const POINT& pt)
{
EnterCriticalSection(&m_csControls);
{
if ( pUIWorkspace == m_pUIWorkspace )
{
POINT ptScreen = { pt.x, pt.y };
ClientToScreen(pUIWorkspace->GetHwnd(), &ptScreen);
HMENU hMenu = CreatePopupMenu();
map<string, CFactory<CModule>::FACTORYSTRUCT*>& mapFactory = CFactory<CModule>::GetFactoryMap();
for ( map<string, CFactory<CModule>::FACTORYSTRUCT*>::iterator iter = mapFactory.begin() ; iter != mapFactory.end() ; ++iter )
{
MODULEFACTORYDATA* pmfd = ((MODULEFACTORYDATA*)iter->second->pvData);
if ( !pmfd ) continue;
AppendMenu(hMenu, MF_STRING, (uint32)iter->second, pmfd->m_sCategory.c_str());
}
uint32 nResult = TrackPopupMenu(hMenu, TPM_RETURNCMD|TPM_LEFTALIGN|TPM_LEFTBUTTON, ptScreen.x, ptScreen.y, 0, GetHwnd(), NULL);
if ( nResult != 0 )
{
CFactory<CModule>::FACTORYSTRUCT* pfs = (CFactory<CModule>::FACTORYSTRUCT*)nResult;
MODULEFACTORYDATA* pmfd = ((MODULEFACTORYDATA*)pfs->pvData);
CUIModule* pUIModule = (CUIModule*)CFactory<CUIWindow>::Create("CUIModule");
CModule* pModule = (CModule*)pfs->fnCreate();
pUIModule->SetModule(pModule);
pModule->SetUIModule(pUIModule);
pUIModule->SetParent(m_pUIWorkspace);
m_pUIWorkspace->AddChild(pUIModule);
MODULEINITSTRUCT mis;
mis.pApp = this;
pModule->Init(mis);
pModule->PostInit();
CUIWindow::CREATESTRUCT cs;
cs.x = pt.x;
cs.y = pt.y;
cs.hWndParent = m_pUIWorkspace->GetHwnd();
cs.pUIHost = pModule;
cs.dict.SetString("title", pmfd->m_sCategory);
pUIModule->Create(cs);
m_listModules.push_back(pModule);
m_listUIModules.push_back(pUIModule);
}
DestroyMenu(hMenu);
}
}
LeaveCriticalSection(&m_csControls);
}
示例10: catch
// Why MODHALTCHK works only with functions returning EModRet ? :(
bool CModules::OnServerCapAvailable(const CString& sCap) {
bool bResult = false;
for (unsigned int a = 0; a < size(); ++a) {
try {
CModule* pMod = (*this)[a];
CClient* pOldClient = pMod->GetClient();
pMod->SetClient(m_pClient);
if (m_pUser) {
CUser* pOldUser = pMod->GetUser();
pMod->SetUser(m_pUser);
bResult |= pMod->OnServerCapAvailable(sCap);
pMod->SetUser(pOldUser);
} else {
// WTF? Is that possible?
bResult |= pMod->OnServerCapAvailable(sCap);
}
pMod->SetClient(pOldClient);
} catch (CModule::EModException e) {
if (CModule::UNLOAD == e) {
UnloadModule((*this)[a]->GetModName());
}
}
}
return bResult;
}
示例11: catch
// Maybe create new macro for this?
bool CModules::IsClientCapSupported(CClient* pClient, const CString& sCap, bool bState) {
bool bResult = false;
for (unsigned int a = 0; a < size(); ++a) {
try {
CModule* pMod = (CModule*) (*this)[a];
CClient* pOldClient = pMod->GetClient();
pMod->SetClient(m_pClient);
if (m_pUser) {
CUser* pOldUser = pMod->GetUser();
pMod->SetUser(m_pUser);
bResult |= pMod->IsClientCapSupported(pClient, sCap, bState);
pMod->SetUser(pOldUser);
} else {
// WTF? Is that possible?
bResult |= pMod->IsClientCapSupported(pClient, sCap, bState);
}
pMod->SetClient(pOldClient);
} catch (CModule::EModException e) {
if (CModule::UNLOAD == e) {
UnloadModule((*this)[a]->GetModName());
}
}
}
return bResult;
}
示例12: FindModule
bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
CString sMod = sModule; // Make a copy incase the reference passed in is from CModule::GetModName()
CModule* pModule = FindModule(sMod);
sRetMsg = "";
if (!pModule) {
sRetMsg = "Module [" + sMod + "] not loaded.";
return false;
}
if (pModule->IsFake()) {
for (iterator it = begin(); it != end(); it++) {
if (*it == pModule) {
erase(it);
sRetMsg = "Fake module [" + sMod + "] unloaded";
return true;
}
}
sRetMsg = "Fake module [" + sMod + "] not loaded.";
return false;
}
ModHandle p = pModule->GetDLL();
if (p) {
typedef void (*fp)(CModule*);
fp Unload = (fp)dlsym(p, "ZNCModUnload");
if (Unload) {
Unload(pModule);
for (iterator it = begin(); it != end(); it++) {
if (*it == pModule) {
erase(it);
break;
}
}
dlclose(p);
sRetMsg = "Module [" + sMod + "] unloaded";
return true;
} else {
sRetMsg = "Unable to unload module [" + sMod + "] could not find ZNCModUnload()";
return false;
}
}
sRetMsg = "Unable to unload module [" + sMod + "]";
return false;
}
示例13: FreeCurrentDictionary
void CSession::FreeCurrentDictionary()
{
if (m_pEnchantDict)
{
CModule* pMod = CModule::GetInstance();
if (pMod)
{
pMod->FreeDictionary(m_pEnchantDict);
m_pEnchantDict = NULL;
}
}
}
示例14: tscDestroySession
tsc_result TSC_CALLTYPE
tscDestroySession( tsc_cookie SessionID )
{
tsc_func_init();
CModule* pM = CModule::GetInstance();
if (!pM)
return Error_Internal_NullModulePtr();
tsc_result r = TSC_E_FAIL;
r = pM->DestroySession(SessionID);
return r;
}
示例15: tscGetLastError
const char* TSC_CALLTYPE
tscGetLastError()
{
if (s_szLastError != s_szErrNoErr)
return s_szLastError;
else
{
CModule* pM = CModule::GetInstance();
if (pM)
return pM->GetLastError();
else
return s_szErrErr; // catch-all error text
}
}