SiteHopper Database

Creating a new Database

Listing 2: Simple example to create new SiteHopper database

/* 
(C) 2022 Cadence Design Systems, Inc. (Cadence) 
All rights reserved.
TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
provided to current licensees or subscribers of Cadence products or
SaaS offerings (each a "Customer").
Customer is hereby permitted to use, copy, and modify the Sample Code,
subject to these terms. Cadence claims no rights to Customer's
modifications. Modification of Sample Code is at Customer's sole and
exclusive risk. Sample Code may require Customer to have a then
current license or subscription to the applicable Cadence offering.
THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
liable for any damages or liability in connection with the Sample Code
or its use.
*/
#include <oebio.h>
#include <oechem.h>
#include <oeplatform.h>
#include <oesitehopper.h>
#include <oesystem.h>
#include <openeye.h>

using namespace OESiteHopper;
using namespace OEBio;
using namespace OESystem;
using namespace OEChem;
using namespace OEPlatform;

int main(int argc, char* argv[])
{
  if (argc < 3 || argc > 4)
  {
    OEThrow.Usage("%s <shdb> <du directory> [-verbose]", argv[0]);
    return 0;
  }

  OEConsoleProgressTracer consoleTracer;
  OENullTracer nullTracer;
  OETracerBase* tracer = &consoleTracer;

  if (argc == 4)
  {
    tracer = &nullTracer;
    if (std::string(argv[3]) == "-verbose")
      OEThrow.SetLevel(OEErrorLevel::Debug);
    else
      OEThrow.Fatal("unknown argument: %s", argv[3]);
  }

  if (OEFileExists(argv[1]))
    OEThrow.Fatal("%s already exists, exiting...", argv[1]);

  OESiteHopperDatabase shdb;
  if (!shdb.Open(argv[1], OESiteHopperDatabaseMode::CREATE))
    OEThrow.Fatal("Unable to open %s for creation.", argv[1]);

  auto ncpu = 0; // use all available CPUs
  shdb.AddDirectory(argv[2], ncpu, *tracer);

  return 0;
}

Download code

sitehopperbuild.cpp

Query database info

Get an OEDesignUnit from database