Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Protected Attributes
Arc::InfoCache Class Reference

Stores XML document in filesystem split into parts. More...

#include <InfoCache.h>

Collaboration diagram for Arc::InfoCache:
Collaboration graph
[legend]

List of all members.

Public Member Functions

bool Query (const char *xml_path, const char *q, XMLNodeContainer &result)
bool Query (const std::string &xml_path, std::string &q, XMLNodeContainer &result)
bool Set (const char *xml_path, XMLNode &value)
bool Set (const std::string &xml_path, XMLNode &value)
bool Get (const char *xml_path, XMLNodeContainer &result)
bool Get (const std::string &xml_path, XMLNodeContainer &result)
bool Unset (const char *xml_path)
bool Unset (const std::string &xml_path)
 InfoCache (const Config &cfg, const std::string &service_id)
 Creates object according to configuration (see InfoCacheConfig.xsd)
 ~InfoCache ()

Protected Attributes

std::string path_base

Detailed Description

Stores XML document in filesystem split into parts.

Definition at line 18 of file InfoCache.h.


Constructor & Destructor Documentation

Arc::InfoCache::InfoCache ( const Config cfg,
const std::string &  service_id 
)

Creates object according to configuration (see InfoCacheConfig.xsd)

XML configuration is passed in cfg. Argument service_id is used to distiguish between various documents stored under same path - corresponding files will be stored in subdirectory with service_id name.

Definition at line 60 of file InfoCache.cpp.

{
    std::string cfg_s;
    cfg.GetXML(cfg_s);
    logger.msg(DEBUG,"Cache configuration: %s",cfg_s);
    std::string root = std::string(const_cast<Config&>(cfg)["CacheRoot"]);
    if(root.empty()) {
        logger.msg(ERROR,"Missing cache root in configuration");
        return;
    }
    if(service_id.empty()) {
        logger.msg(ERROR,"Missing service id");
        return;
    }
    logger.msg(DEBUG,"Cache root: %s",root);
    if (!create_directory(root)) return;
    std::string id(service_id);
    std::string sdir = Glib::build_filename(root, id);
    if (!create_directory(sdir)) return;
    path_base=sdir;
    logger.msg(DEBUG,"Cache directory: %s",path_base);
}

Here is the call graph for this function:

Definition at line 83 of file InfoCache.cpp.

{
    // NOP
}

Member Function Documentation

bool Arc::InfoCache::Get ( const char *  xml_path,
XMLNodeContainer result 
)

Definition at line 182 of file InfoCache.cpp.

{
    if (path_base.empty()) {
        logger.msg(ERROR,"InfoCache object is not set up");
        return false;
    }
    if (xml_path[0] != '/') {
        logger.msg(ERROR,"Invalid path in Get(): %s",xml_path);
        return false;
    }
    std::string p(xml_path);
    clean_path(p);
    std::list<std::string> tokens;
    tokenize(p, tokens, "/");
    if (tokens.size() <= 0) {
        NS ns;
        XMLNode node(ns, "InfoDoc");
        merge_xml(path_base, node);
        result.AddNew(node);
        return true;
    }
    XMLNode node;
    return get_path(path_base,tokens,node);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::InfoCache::Get ( const std::string &  xml_path,
XMLNodeContainer result 
) [inline]

Definition at line 27 of file InfoCache.h.

{ return Get(xml_path.c_str(), result); };

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::InfoCache::Query ( const char *  xml_path,
const char *  q,
XMLNodeContainer result 
)

Definition at line 207 of file InfoCache.cpp.

{
    if (path_base.empty()) {
        logger.msg(ERROR,"InfoCache object is not set up");
        return false;
    }
    XMLNodeContainer gc;
    Get(path, gc);
    NS ns;
    
    for (int i = 0; i < gc.Size(); i++) {
        XMLNode node = gc[i];
        XMLNodeList xresult = node.XPathLookup(query,ns);
        result.AddNew(xresult);
    }
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::InfoCache::Query ( const std::string &  xml_path,
std::string &  q,
XMLNodeContainer result 
) [inline]

Definition at line 23 of file InfoCache.h.

{ return Query(xml_path.c_str(), q.c_str(), result); };

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::InfoCache::Set ( const char *  xml_path,
XMLNode value 
)

Definition at line 144 of file InfoCache.cpp.

{
    if (path_base.empty()) {
        logger.msg(ERROR,"InfoCache object is not set up");
        return false;
    }
    if (xml_path[0] != '/') {
        logger.msg(ERROR,"Invalid path in Set(): %s",xml_path);
        return false;
    }
    std::string p(xml_path);
    clean_path(p);
    std::list<std::string> tokens;
    tokenize(p, tokens, "/");
    bool ret;
    ret = set_path(path_base, tokens, value);
    return ret;
}

Here is the call graph for this function:

bool Arc::InfoCache::Set ( const std::string &  xml_path,
XMLNode value 
) [inline]

Definition at line 25 of file InfoCache.h.

{ return Set(xml_path.c_str(), value) ; };

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::InfoCache::Unset ( const char *  xml_path)

Definition at line 163 of file InfoCache.cpp.

{
    if (path_base.empty()) {
        logger.msg(ERROR,"InfoCache object is not set up");
        return false;
    }
    if (xml_path[0] != '/') {
        logger.msg(ERROR,"Invalid path in Set(): %s",xml_path);
        return false;
    }
    std::string p(xml_path);
    clean_path(p);
    std::list<std::string> tokens;
    tokenize(p, tokens, "/");
    bool ret;
    ret = unset_path(path_base, tokens);
    return ret;
}

Here is the call graph for this function:

bool Arc::InfoCache::Unset ( const std::string &  xml_path) [inline]

Definition at line 29 of file InfoCache.h.

{ return Unset(xml_path.c_str()); };

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

std::string Arc::InfoCache::path_base [protected]

Definition at line 20 of file InfoCache.h.


The documentation for this class was generated from the following files: