Пример #1
0
/**
 * 初始化 profile 部分
 *
 * @param path     数据存放路径
 *
 * @return  0: success ;   -1: 程序处理失败
 */
int initProfile(const char * path, bool sync = true, bool buildHF = false)
{
    ProfileManager * mgr = ProfileManager::getInstance();

    if ( NULL == mgr )
    {
        TERR("ProfileManager instance is null");
        return -1;
    }

    if ( (NULL == path) || strlen( path ) <= 0 )
    {
        TERR("profile node's path attribute is null");
        return -1;
    }

    if ( mgr->getProfileDocNum() > 0 )
    {
        TLOG("profile has been loaded!");
        return 0;
    }

    mgr->setProfilePath( path );
    mgr->setDataSync( sync );

    TLOG("begin to load profile! path:%s", path);

    if ( 0 != mgr->load(!buildHF) )
    {
        TERR("load profile failed! path:%s", path);
        return -1;
    }

    TLOG("load profile success!");

    return 0;
}