void TypedEventSource::Register(TypedEventSource* Source)
		{
			EventSourceArrayT& Registry = GetRegistry();
			EventSourceArrayT::iterator Match = std::find(Registry.begin(), Registry.end(), Source);
			DEBUG_ASSERT(Match == Registry.end());

			GetRegistry().push_back(Source);
		}
//----------------------------------------------------------------------------------------------
//	LoadRegistry
//----------------------------------------------------------------------------------------------
VOID CSetting::LoadRegistry()
{
	//	コントローラーの設定、設定の名称の領域を開放する
	if( Setting != NULL )
	{
		LocalFree( Setting );
	}
	if( SettingName != NULL )
	{
		for( LONG Index = 0; Index < SettingCount; Index ++ )
		{
			LocalFree( SettingName[Index] );
		}
		LocalFree( SettingName );
	}

	//	現在のコントローラーの設定を取得する
	GetDefaultSetting( &CurrentSetting );
	GetRegistry( &CurrentSetting, REG_BINARY, sizeof( SETTING ), CURRENT_SETTING );

	//	現在のコントローラーの設定の順番を取得する
	CurrentSettingIndex	= 0;
	GetRegistry( &CurrentSettingIndex, REG_DWORD, sizeof( LONG ), CURRENT_SETTING_INDEX );

	//	コントローラーの設定数を取得する
	SettingCount	= 1;
	GetRegistry( &SettingCount, REG_DWORD, sizeof( LONG ), SETTING_COUNT );

	//	コントローラーの設定、設定の名称を保存するための領域を確保する
	Setting		= (SETTING *)LocalAlloc( LPTR, SettingCount * sizeof( SETTING ) );
	SettingName	= (WCHAR * *)LocalAlloc( LPTR, SettingCount * sizeof( WCHAR * ) );
	for( LONG Index = 0; Index < SettingCount; Index ++ )
	{
		SettingName[Index]	= (WCHAR *)LocalAlloc( LPTR, sizeof( WCHAR ) * MAX_PATH );
	}

	//	標準の設定を取得する
	GetDefaultSetting( &Setting[0] );
	LoadString( Instance, IDS_DEFAULT_SETTING, SettingName[0], sizeof( WCHAR ) * MAX_PATH );

	//	コントローラーの設定、設定の名称を取得する
	for( LONG Index = 1; Index < SettingCount; Index ++ )
	{
		GetSetting( Index, &Setting[Index] );
		GetSettingName( Index, SettingName[Index], sizeof( WCHAR ) * MAX_PATH );
	}

	//	変更済みフラグを取得する
	ModifiedFlag	= FALSE;
	GetRegistry( &ModifiedFlag, REG_BINARY, sizeof( BOOLEAN ), MODIFIED_FLAG );

	//	設定の自動切換えを取得する
	AutoSettingChange	= FALSE;
	GetRegistry( &AutoSettingChange, REG_BINARY, sizeof( BOOLEAN ), AUTO_SETTING_CHANGE );
}
Ejemplo n.º 3
0
void StorageBase::RemovedFromContainer(Object const &container)
{
    ObjectColor::Color color = ObjectColor::White;
    StorageBase *parent = GetRegistry()->GetStorageBase(GetParentHandle());
    bool parent_is_black = parent && parent->IsBlack();
    if (parent_is_black)
        color = ObjectColor::Grey;
    
    bool removed = false;
    auto iter = containers.begin(), end = containers.end();
    for (; iter != end; )
    {
        StorageBase *base = GetRegistry()->GetStorageBase(*iter);
        if (!base)
        {
            iter = containers.erase(iter);
            continue;
        }

        if (!removed && *iter == container.GetHandle())
        {
            iter = containers.erase(iter);
            removed = true;
            if (parent_is_black)
            {
                // if removed from container and parent is black early out
                break;
            }
            else
            {
                // we need to check for other black parents to enforce the TriColor invariant
                continue;
            }
        }

        if (base->IsBlack())
        {
            color = ObjectColor::Grey;
            parent_is_black = true;
            // if any parent container is black, and we have already removed from the
            // given container, we can early out
            if (removed)
                break;
        }

        ++iter;
    }

    SetColorRecursive(color);
}
		void TypedEventSource::Unregister(TypedEventSource * Source)
		{
			EventSourceArrayT& Registry = GetRegistry();
			EventSourceArrayT::iterator Match = std::find(Registry.begin(), Registry.end(), Source);
			DEBUG_ASSERT(Match != Registry.end());

			Registry.erase(Match);
		}
//----------------------------------------------------------------------------------------------
//	GetSetting
//----------------------------------------------------------------------------------------------
VOID CSetting::GetSetting(
	 LONG		Index
	,SETTING *	Setting )
{
	//	コントローラーの設定を取得する
	WCHAR	KeyName[MAX_PATH];
	swprintf_s( KeyName, SETTING_DATA, Index );
	GetRegistry( Setting, REG_BINARY, sizeof( SETTING ), KeyName );
}
//----------------------------------------------------------------------------------------------
//	GetSettingName
//----------------------------------------------------------------------------------------------
VOID CSetting::GetSettingName(
	 LONG		Index
	,WCHAR *	SettingName
	,LONG		Size )
{
	//	コントローラーの設定を取得する
	WCHAR	KeyName[MAX_PATH];
	swprintf_s( KeyName, SETTING_NAME, Index );
	GetRegistry( SettingName, REG_SZ, Size, KeyName );
}
Ejemplo n.º 7
0
 void VariableRegistry::ListVariables(ostream& os, const string& pat) const
 {
     ListVariables_header(os);
     for (auto& i : GetRegistry())
     {
         if (FNM_NOMATCH == fnmatch(pat.c_str(), i.first.c_str(), 0))
             continue;
         ListVariables_onevar(os, i.first, i.second);
     }
 }
Ejemplo n.º 8
0
static int
GetFromRegistry(const char *name, int where, DWORD type,
		void *param, DWORD length)
{
	if (where & IDN_PERPROG) {
		/*
		 * First, try program specific setting.
		 */
		char keyname[256];

		/*
		 * Try HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE.
		 */
		if (GetPerProgKey(keyname, sizeof(keyname)) != NULL) {
			if (((where & IDN_CURUSER) &&
			     GetRegistry(HKEY_CURRENT_USER, keyname, name,
					 type, param, length)) ||
			    GetRegistry(HKEY_LOCAL_MACHINE, keyname, name,
					type, param, length)) {
				return (1);
			}
		}
	}

	if (where & IDN_GLOBAL) {
		/*
		 * Try global setting.
		 */
		if (((where & IDN_CURUSER) &&
		     GetRegistry(HKEY_CURRENT_USER, IDNKEY_WRAPPER, name,
				 type, param, length)) ||
		    GetRegistry(HKEY_LOCAL_MACHINE, IDNKEY_WRAPPER, name,
				type, param, length)) {
			return (1);
		}
	}

	/*
	 * Not found.
	 */
	return (0);
}
Ejemplo n.º 9
0
bool StorageBase::SetColor(ObjectColor::Color color)
{
    auto reg = GetRegistry();
    if (!reg->SetColor(*this, color))
        return false;

    this->color = color;
    if (color == ObjectColor::White)
    {
        Containers::const_iterator container = containers.begin(), end = containers.end();
        for (; container != end; ++container)
        {
            StorageBase *cont = GetRegistry()->GetStorageBase(*container);
            if (cont && cont->IsBlack())
                cont->SetColor(ObjectColor::Grey);
        }
    }

    return true;
}
Ejemplo n.º 10
0
Settings::Settings(openGalaxy *opengalaxy) : m_openGalaxy(opengalaxy)
{
#if __linux__
  // Linux: use configured (hardcoded) values
  default_textfile.assign( _LOG_DIR_ "/galaxy.log" );
  configfile.assign( _CONFIG_DIR_ "/galaxy.conf" );
  ssmtp_configfile.assign( _CONFIG_DIR_ "/ssmtp.conf" ); // only used under linux
  www_root_directory.assign( _WWW_DIR_ );
  certificates_directory.assign( _CERT_DIR_ );
#endif
#if _WIN32
  // Windows: load values from the registry
  std::string configdir;
  std::string datadir;
  std::string wwwdir;
  if(
   (false == GetRegistry("ConfigDirectory", configdir)) ||
   (false == GetRegistry("DataDirectory", datadir)) ||
   (false == GetRegistry("WebDirectory", wwwdir))
  ){
    throw new std::runtime_error( "openGalaxy::Settings could not read from registry!" ); 
  }
  default_textfile = configdir;
  default_textfile += "/galaxy.log.txt";
  configfile = configdir;
  configfile += "/galaxy.conf";
  www_root_directory = wwwdir;
  certificates_directory = datadir;
  certificates_directory += "/ssl";
#endif

  // Set default values
  defaults();

  // Apply the (new) syslog level
  m_openGalaxy->syslog().set_level(syslog_level);

  // Read settings from configuration file
  read( configfile.c_str() );
}
Ejemplo n.º 11
0
void StorageBase::MakeReachableGrey()
{
    Dictionary::const_iterator child = dictionary.begin(), end = dictionary.end();
    for (; child != end; ++child)
    {
        StorageBase *sub = GetRegistry()->GetStorageBase(child->second.GetHandle());
        if (!sub)
            continue;

        if (sub->IsWhite())
            sub->SetColor(ObjectColor::Grey);
    }

    GetClass()->MakeReachableGrey(*this);
}
		void TypedEventSource::Deinitialize()
		{
			EventSourceArrayT& Registry = GetRegistry();
			bool HasActiveSinks = false;
			for (auto Itr : Registry)
			{
				if (Itr->Sinks.size())
				{
					HasActiveSinks = true;
					BGSEECONSOLE_MESSAGE("TypedEventSource %d has %d active sinks at shutdown", (UInt32)Itr->TypeID, Itr->Sinks.size());
				}
			}

			SME_ASSERT(HasActiveSinks == false);
		}
Ejemplo n.º 13
0
void StorageBase::DetachFromContainers()
{
    if (containers.empty())
        return;

    Containers tmp = containers;
    Containers::const_iterator iter = tmp.begin(), end = tmp.end();
    for (; iter != end; ++iter)
    {
        StorageBase *cont = GetRegistry()->GetStorageBase(*iter);
        if (!cont)
            continue;

        cont->GetClass()->DetachFromContainer(*cont, *this);
    }
}
Ejemplo n.º 14
0
void pybase::Reload()
{
    ThrLock lock;

    PyObject *reg = GetRegistry(REGNAME);

    if(reg) {
        PyObject *key;
        Py_ssize_t pos = 0;
        while(PyDict_Next(reg,&pos,&key,NULL)) {
            pybase *th = (pybase *)PyLong_AsLong(key);
            FLEXT_ASSERT(th);
            th->Unload();
        }

        UnloadModule();
    }

    bool ok = ReloadModule();

    if(ok) {
        LoadModule();

        if(reg) {
            SetRegistry(REGNAME,reg);

            PyObject *key;
            Py_ssize_t pos = 0;
            while(PyDict_Next(reg,&pos,&key,NULL)) {
                pybase *th = (pybase *)PyLong_AsLong(key);
                FLEXT_ASSERT(th);
                th->Load();
            }
        }
        else
            Load();
    }

    Report();
}
//----------------------------------------------------------------------------------------------
//	SaveRegistry
//----------------------------------------------------------------------------------------------
VOID CSetting::SaveRegistry()
{
	//	現在のコントローラーの設定を更新する
	SetRegistry( &CurrentSetting, REG_BINARY, sizeof( SETTING ), CURRENT_SETTING );

	//	現在のコントローラーの設定の順番を更新する
	SetRegistry( &CurrentSettingIndex, REG_DWORD, sizeof( LONG ), CURRENT_SETTING_INDEX );

	//	コントローラーの設定数を取得しておく
	LONG	OldSettingCount	= 0;
	GetRegistry( &OldSettingCount, REG_DWORD, sizeof( LONG ), SETTING_COUNT );

	//	コントローラーの設定数を更新する
	SetRegistry( &SettingCount, REG_DWORD, sizeof( LONG ), SETTING_COUNT );

	//	コントローラーの設定、設定の名称を更新する
	for( LONG Index = 1; Index < SettingCount; Index ++ )
	{
		SetSetting( Index, &Setting[Index] );
		SetSettingName( Index, SettingName[Index] );
	}

	//	余分なコントローラーの設定、設定の名称を削除する
	if( OldSettingCount > SettingCount )
	{
		for( LONG Index = SettingCount; Index < OldSettingCount; Index ++ )
		{
			DelSetting( Index );
			DelSettingName( Index );
		}
	}

	//	変更済みフラグを更新する
	SetRegistry( &ModifiedFlag, REG_BINARY, sizeof( BOOLEAN ), MODIFIED_FLAG );

	//	設定の自動切換えを更新する
	SetRegistry( &AutoSettingChange, REG_BINARY, sizeof( BOOLEAN ), AUTO_SETTING_CHANGE );
}
Ejemplo n.º 16
0
HRESULT CDriverExtensionHelper::GetAdapter(IDirect3DDevice9 *pDevice, DispSvr::IDriverExtensionAdapter **ppAdapter)
{
	HRESULT hr = E_FAIL;

	CHECK_POINTER(pDevice);
	CHECK_POINTER(ppAdapter);

	switch (GetRegistry(REG_VENDOR_ID, 0))
	{
	case PCI_VENDOR_ID_NVIDIA:
		hr = CNvAPIDeviceExtensionAdapter::GetAdapter(pDevice, ppAdapter);
		break;

	case PCI_VENDOR_ID_INTEL:
		hr = CIntelDxva2DriverExtAdapter::GetAdapter(pDevice, ppAdapter);
		break;

	default:
		break;
	}

	return hr;
}
Ejemplo n.º 17
0
// avoid loops by passing history of objects traversed via handles argument
void StorageBase::SetColorRecursive(ObjectColor::Color color, HandleSet& handles)
{
    Handle handle = GetHandle();
    if (handles.find(handle) != handles.end())
        return;

    handles.insert(handle);

    if (!SetColor(color))
        return;

    GetClass()->SetReferencedObjectsColor(*this, color, handles);
    if (dictionary.empty())
        return;

    for (Dictionary::value_type const &child : dictionary)
    {
        StorageBase *sub = GetRegistry()->GetStorageBase(child.second.GetHandle());
        if (!sub)
            continue;

        sub->SetColorRecursive(color, handles);
    }
}
Ejemplo n.º 18
0
public:
  template<typename T>
  static Shape * Create() {
    return new T;
  }
  virtual void Draw() const = 0;
  virtual ~Shape() {}
};

class Line: public Shape {
public:
  void Draw() const {}
  static bool isRegistered;
};

bool Line::isRegistered = GetRegistry().insert(std::make_pair(iLine, Shape::Create<Line>)).second;

class Circle: public Shape {
public:
  static Circle * Create() {
    return new Circle;
  }
  void Draw() const {}
};

class Triangle: public Shape {
public:
  static Triangle * Create() {
    return new Triangle;
  }
  void Draw() const {}
Ejemplo n.º 19
0
void AddMailNotifyItem(LPFdirEntry lpFdirEntry, int type)
{
	char lpszText[10240];
	char szContributor[LEN_CIXNAME];
    char szFileName[LEN_CIXFILENAME];
	char szFileDate[64];
	char szFileSize[64];
	MAILOBJECT mailObject;
	LPFlistEntry lpFlistEntry;// = (LPFlistEntry)lpFdirEntry->fdirFlistEntry[0];
//	Context context = (Context)lpGlobals->context;

	if (lpFdirEntry->fdirFlistEntry[0] != NULL )
	{
		lpFlistEntry = (LPFlistEntry)lpFdirEntry->fdirFlistEntry[0];
	}
	lstrcpy( szContributor, "$CIX$" );
	GetRegistry((LPSTR)&szContributor);

	if(lstrcmp(lpGlobals->context.lpcConfName, "filepool") == 0)
		return;

	formatLong(szFileSize, "", lpFdirEntry->fdirSize, " bytes");
	strftime(szFileDate, 63, "%A %d %B %Y", localtime(&lpFdirEntry->fdirTimestamp));
    setCase(szFileName, lpFdirEntry->fdirName, setup.wNotifyCase);

	if (lpFdirEntry->fdirFlistEntry[0] != NULL )
	{
		wsprintf(lpszText, "\r\n"
					 " %s\r\n"
					 "\r\n"
					 "   Filename: %s\r\n"
					 "    Hotlink: cixfile:\r\n"
					 "  File size: %s\r\n"
					 "Contributor: %s\r\n"
					 "       Date: %s\r\n"
					 "%s"
					 "\r\n"
					 "Description: \r\n\r\n"
					 "%s\r\n",
					 type?"The following local file has been exported to the filepool:":"The following file has been exported to the filepool:",
				   (LPSTR)szFileName, 
				   (LPSTR)szFileSize,
				   (LPSTR)szContributor, 
				   (LPSTR)szFileDate,
				   setup.os_and_status?"     Status: \r\n        O/S: \r\n":"",
				   (LPSTR)lpFlistEntry->flistDescription);
	}
	else
	{
		wsprintf(lpszText, "\r\n"
					 " %s\r\n"
					 "\r\n"
					 "   Filename: %s\r\n"
					 "    Hotlink: cixfile:\r\n"
					 "  File size: %s\r\n"
					 "Contributor: %s\r\n"
					 "       Date: %s\r\n"
					 "%s"
					 "\r\n"
					 "Description: <Unknown>\r\n\r\n"
					 "\r\n",
					 type?"The following local file has been exported to the filepool:":"The following file has been exported to the filepool:",
				   (LPSTR)szFileName, 
				   (LPSTR)szFileSize,
				   (LPSTR)szContributor, 
				   (LPSTR)szFileDate,
				   setup.os_and_status?"     Status: \r\n        O/S: \r\n":"");
	}
	InitObject(&mailObject, OT_MAIL, MAILOBJECT);
	lstrcpy(mailObject.szTo, "*****@*****.**");
	lstrcpy(mailObject.szSubject, "Export To Filepool - ");
	lstrcat(mailObject.szSubject, szFileName);
	mailObject.szCC[0] = '\x0';
	mailObject.szReply[0] = '\x0';
	PutObject(NULL, &mailObject, lpszText);
}
Ejemplo n.º 20
0
#include "base.h"

#include <iostream>

class RuleThree: public TRule {
public:
  virtual void Do() const {
    std::cout << "rule three\n";
  }
  static bool isRegistered;
};

bool RuleThree::isRegistered = GetRegistry().insert(std::make_pair("rule3", TRule::Create<RuleThree>)).second;