Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh: add shell namespaces and verify for mesh bp #55

Merged
merged 16 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
###############################################################################
# Copyright (c) 2014-2015, Lawrence Livermore National Security, LLC.
#
#
# Produced at the Lawrence Livermore National Laboratory
#
#
# LLNL-CODE-666778
#
#
# All rights reserved.
#
# This file is part of Conduit.
#
#
# This file is part of Conduit.
#
# For details, see: http://software.llnl.gov/conduit/.
#
#
# Please also read conduit/LICENSE
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
#
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
#
#
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
###############################################################################
sudo: false
language: cpp
Expand All @@ -58,8 +58,8 @@ addons:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- gcc-4.8
- g++-4.8
- gfortran-4.8
before_install:
# download a newer version of cmake
Expand Down Expand Up @@ -114,9 +114,9 @@ script:
- cd ${TRAVIS_BUILD_DIR}/src/examples/using-with-make
- env CXX=${CONDUIT_CXX} CONDUIT_DIR=${TRAVIS_BUILD_DIR}/travis-debug-install make
- env LD_LIBRARY_PATH=${TRAVIS_BUILD_DIR}/travis-debug-install/lib/ ./example

after_success:
- coveralls --gcov /usr/bin/gcov-4.8 --include src/libs/conduit src/libs/blueprint --gcov-options '\-lp' --root $TRAVIS_BUILD_DIR --build-root $TRAVIS_BUILD_DIR/travis-debug-build;
- coveralls --gcov /usr/bin/gcov-4.8 --include src/libs/conduit --include src/libs/blueprint --gcov-options '\-lp' --root $TRAVIS_BUILD_DIR --build-root $TRAVIS_BUILD_DIR/travis-debug-build;
notifications:
email:
recipients:
Expand Down
34 changes: 28 additions & 6 deletions src/libs/blueprint/blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ void
about(Node &n)
{
n.reset();
n["protocols/mesh"] = "enabled";
n["protocols/mesh/coordset"] = "enabled";
n["protocols/mesh/topology"] = "enabled";
n["protocols/mesh/field"] = "enabled";
n["protocols/mesh/index"] = "enabled";

n["protocols/mcarray"] = "enabled";
}

Expand All @@ -108,16 +112,34 @@ verify(const std::string &protocol,
{
bool res = false;
info.reset();

std::string p_curr;
std::string p_next;
utils::split_path(protocol,p_curr,p_next);

if(protocol == "mesh")
if(!p_next.empty())
{
res = mesh::verify(n,info);
if(protocol == "mesh")
{
res = mesh::verify(p_next,n,info);
}
else if(protocol == "mcarray")
{
res = mcarray::verify(p_next,n,info);
}
}
else if(protocol == "mcarray")
else
{
res = mcarray::verify(n,info);
if(protocol == "mesh")
{
res = mesh::verify(n,info);
}
else if(protocol == "mcarray")
{
res = mcarray::verify(n,info);
}
}

return res;
}

Expand Down
75 changes: 62 additions & 13 deletions src/libs/blueprint/blueprint_mcarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,40 +82,89 @@ namespace mcarray

//-----------------------------------------------------------------------------
bool
verify(const Node &n)
verify(const std::string &/*protocol*/,
const Node &/*n*/,
Node &info)
{
Node info;
return verify(n,info);
info["valid"] = "false";
// mcarray doens't provide any nested protocols
return false;
}


//----------------------------------------------------------------------------
bool verify(const conduit::Node &n,
Node &info)
{
bool res = true;

// mcarray needs to be an object or a list
if( ! (n.dtype().is_object() || n.dtype().is_list()) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incredibly minor complaint, but I feel like this line doesn't match the coding standards used for of the rest of Conduit. In particular, it doesn't feel like the expanded spacing in this statement fits; something like if(!(n.dtype().is_object() || n.dtype().is_list())) seems more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

{
info["errors"].append().set("mcarray has no children");
res = false;
}

NodeConstIterator itr = n.children();

bool ok = !n.dtype().is_empty();

index_t num_elems = 0;
while(itr.has_next() && ok)

while(itr.has_next())
{
// get the next child
const Node &chld = itr.next();

ok = chld.dtype().is_number();
if(ok)
// make sure we have a number
if(chld.dtype().is_number())
{
if(num_elems == 0)
{
num_elems = chld.dtype().number_of_elements();
}

ok = ( chld.dtype().number_of_elements() == num_elems);
if(chld.dtype().number_of_elements() != num_elems)
{
std::ostringstream oss;
std::string chld_name = itr.path();

if(chld_name.size() == 0)
{
oss << "child [" << itr.index() << "]";
}
else
{
oss << "child \"" << chld_name << "\"";
}

oss << " does not have the same number of "
<< "elements as mcarray components.";

info["errors"].append().set(oss.str());

res = false;
}
}
else
{
std::ostringstream oss;
std::string chld_name = itr.path();

if(chld_name.size() == 0)
{
oss << "child [" << itr.index() << "]";
}
else
{
oss << "child \"" << chld_name << "\"";
}

oss << " is not a numeric type.";
info["errors"].append().set(oss.str());

res = false;
}
}
return ok;

return res;
}


Expand Down
7 changes: 5 additions & 2 deletions src/libs/blueprint/blueprint_mcarray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ namespace mcarray
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
bool BLUEPRINT_API verify(const conduit::Node &n);
bool BLUEPRINT_API verify(const conduit::Node &n,
conduit::Node &info);

//-----------------------------------------------------------------------------
bool BLUEPRINT_API verify(const conduit::Node &n,
bool BLUEPRINT_API verify(const std::string &protocol,
const conduit::Node &n,
conduit::Node &info);


//-----------------------------------------------------------------------------
/// mcarray blueprint property and transform methods
///
Expand Down
Loading