Ejemplo n.º 1
0
SelectionCollection::Impl::Impl(gmx_ana_poscalc_coll_t *pcc)
    : _options("selection", "Common selection control"),
      _debugLevel(0), _grps(NULL)
{
    _sc.root      = NULL;
    _sc.nvars     = 0;
    _sc.varstrs   = NULL;
    _sc.top       = NULL;
    gmx_ana_index_clear(&_sc.gall);
    _sc.pcc       = pcc;
    _sc.mempool   = NULL;
    _sc.symtab    = NULL;

    // TODO: This is not exception-safe if any called function throws.
    if (_sc.pcc == NULL)
    {
        int rc = gmx_ana_poscalc_coll_create(&_sc.pcc);
        if (rc != 0)
        {
            // TODO: A more reasonable error
            GMX_THROW(InternalError("Failed to create position calculation collection"));
        }
        _flags.set(Impl::efOwnPositionCollection);
    }
    _gmx_sel_symtab_create(&_sc.symtab);
    gmx_ana_selmethod_register_defaults(_sc.symtab);
}
Ejemplo n.º 2
0
/*!
 * \param[out] scp Pointer to a newly allocated empty selection collection.
 * \param[in]  pcc Position calculation data structure to use for selection
 *   position evaluation.
 * \returns    0 on success.
 */
int
gmx_ana_selcollection_create(gmx_ana_selcollection_t **scp,
                             gmx_ana_poscalc_coll_t *pcc)
{
    gmx_ana_selcollection_t *sc;
    
    snew(sc, 1);
    sc->rpost     = NULL;
    sc->spost     = NULL;
    sc->selstr    = NULL;
    sc->root      = NULL;
    sc->nr        = 0;
    sc->sel       = NULL;
    sc->top       = NULL;
    gmx_ana_index_clear(&sc->gall);
    sc->pcc       = pcc;
    _gmx_sel_symtab_create(&sc->symtab);
    *scp = sc;
    return 0;
}