Skip to content

Commit

Permalink
Merge pull request #22 from hsorby/usecase_1i
Browse files Browse the repository at this point in the history
All review comments have been addressed and tests are passing. Closes #20.
  • Loading branch information
nickerso committed Jun 8, 2015
2 parents fd911a1 + 9ae9f14 commit 8c2ac73
Show file tree
Hide file tree
Showing 15 changed files with 338 additions and 25 deletions.
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
cmake_minimum_required(VERSION 3.2)

set(PROJECT_NAME libCellML)
project(${PROJECT_NAME} CXX)
project(${PROJECT_NAME} VERSION 0.1.0 LANGUAGES CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(common)
Expand All @@ -33,7 +33,12 @@ endif()
if(COVERAGE AND GCOV_FOUND)
set( LIBCELLML_COVERAGE "${COVERAGE}" CACHE BOOL ${_PARAM_ANNOTATION} FORCE )
elseif(COVERAGE)
message(WARNING "Coverage testing requested but gcov or it's requirements not found!")
if (CMAKE_COMPILER_IS_GCC)
message(WARNING "Coverage testing requested but gcov or its requirements not found!")
else()
message(WARNING "Coverage testing is not possible without a GNU C++ compiler!")
endif()
unset(COVERAGE CACHE)
endif()

# MEMCHECK ==> LIBCELLML_MEMCHECK
Expand All @@ -44,7 +49,12 @@ endif()
if( MEMCHECK AND VALGRIND_FOUND )
set( LIBCELLML_MEMCHECK "${MEMCHECK}" CACHE BOOL ${_PARAM_ANNOTATION} FORCE )
elseif(MEMCHECK)
message(WARNING "Memcheck testing requested but valgrind or it's requirements not found!")
if (CMAKE_COMPILER_IS_GCC)
message(WARNING "Memcheck testing requested but valgrind or its requirements not found!")
else()
message(WARNING "Memcheck testing is not possible without a GNU C++ compiler!")
endif()
unset(MEMCHECK CACHE)
endif()

# UNIT_TESTS ==> LIBCELLML_UNIT_TESTS
Expand Down
8 changes: 8 additions & 0 deletions docs/mainpage.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

/// @mainpage libCellML

libCellML Code Documentation
============================

This is the documentation for the source code.

10 changes: 5 additions & 5 deletions doxy.config
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY =
OUTPUT_DIRECTORY = docs/build/html/code

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -152,7 +152,7 @@ FULL_PATH_NAMES = YES
# will be relative from the directory where doxygen is started.
# This tag requires that the tag FULL_PATH_NAMES is set to YES.

STRIP_FROM_PATH = /home/libcellml/buildslave/Documentation_Builder/libcellml/src/api src/api /home/libcellml/buildslave/Documentation_Builder/libcellml/src/ src
STRIP_FROM_PATH = /home/libcellml/buildslave/Documentation_Builder/libcellml/src/api src/api /home/libcellml/buildslave/Documentation_Builder/libcellml/src/ src docs

# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
# path mentioned in the documentation of a class, which tells the reader which
Expand Down Expand Up @@ -281,7 +281,7 @@ OPTIMIZE_OUTPUT_VHDL = NO
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
# the files are not read by doxygen.

EXTENSION_MAPPING =
EXTENSION_MAPPING = dox=md

# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
# according to the Markdown format, which allows for more readable
Expand Down Expand Up @@ -758,7 +758,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = $(DOXYGEN_INPUT_DIR) src
INPUT = $(DOXYGEN_INPUT_DIR) src docs/mainpage.dox

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -1023,7 +1023,7 @@ GENERATE_HTML = YES
# The default directory is: html.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_OUTPUT = html
HTML_OUTPUT = .

# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
# generated HTML page (for example: .htm, .php, .asp).
Expand Down
27 changes: 19 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.cmake_minimum_required (VERSION 3.1)

# The version number.
set(LIBCELLML_VERSION_MAJOR 0)
set(LIBCELLML_VERSION_MINOR 1)
set(LIBCELLML_VERSION_PATCH 0)

foreach(VERSION_PART LIBCELLML_VERSION_MAJOR LIBCELLML_VERSION_MINOR LIBCELLML_VERSION_PATCH)
foreach(VERSION_PART libCellML_VERSION_MAJOR libCellML_VERSION_MINOR libCellML_VERSION_PATCH)
string(LENGTH ${${VERSION_PART}} VERSION_PART_LENGTH)
if(VERSION_PART_LENGTH EQUAL 1)
set(${VERSION_PART}_PAD 0)
endif()
endforeach()
set(LIBCELLML_LIBRARY_VERSION 0x${LIBCELLML_VERSION_MAJOR_PAD}${LIBCELLML_VERSION_MAJOR}${LIBCELLML_VERSION_MINOR_PAD}${LIBCELLML_VERSION_MINOR}${LIBCELLML_VERSION_PATCH_PAD}${LIBCELLML_VERSION_PATCH})
set(LIBCELLML_LIBRARY_VERSION_STRING "${LIBCELLML_VERSION_MAJOR}.${LIBCELLML_VERSION_MINOR}.${LIBCELLML_VERSION_PATCH}")
set(LIBCELLML_LIBRARY_VERSION 0x${libCellML_VERSION_MAJOR_PAD}${libCellML_VERSION_MAJOR}${libCellML_VERSION_MINOR_PAD}${libCellML_VERSION_MINOR}${libCellML_VERSION_PATCH_PAD}${libCellML_VERSION_PATCH})
set(LIBCELLML_LIBRARY_VERSION_STRING "${libCellML_VERSION_MAJOR}.${libCellML_VERSION_MINOR}.${libCellML_VERSION_PATCH}")

set(CELLML_EXPORT_H "${CMAKE_CURRENT_BINARY_DIR}/api/libcellml/libcellml_export.h")
set(LIBCELLML_CONFIG_H "${CMAKE_CURRENT_BINARY_DIR}/libcellml_config.h")
Expand All @@ -35,10 +30,14 @@ configure_file(

set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
${CMAKE_CURRENT_SOURCE_DIR}/model.cpp
)

set(API_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/version.h
${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/model.h
${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/entity.h
${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/enumerations.h
${CELLML_EXPORT_H}
)

Expand All @@ -52,18 +51,25 @@ add_compiler_export_flags()
add_library(cellml
${SOURCE_FILES}
${HEADER_FILES}
${MODULE_HEADER_FILES}
${API_HEADER_FILES}
)

target_include_directories(cellml
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/api>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/module>
$<INSTALL_INTERFACE:include/>
$<INSTALL_INTERFACE:include/libcellml/module>
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
)

set_target_properties(cellml PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON)

if(LIBCELLML_TREAT_WARNINGS_AS_ERRORS)
target_warnings_as_errors(cellml)
endif()
Expand Down Expand Up @@ -95,5 +101,10 @@ install(FILES
DESTINATION include/libcellml
)

install(FILES
${MODULE_HEADER_FILES}
DESTINATION include/libcellml/module
)

install(EXPORT libcellml-targets DESTINATION lib/cmake)

45 changes: 45 additions & 0 deletions src/api/libcellml/entity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2015 University of Auckland
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Some license of other
*/

#ifndef LIBCELLML_LIBCELLML_ENTITY_H_
#define LIBCELLML_LIBCELLML_ENTITY_H_

#include "libcellml/enumerations.h"

namespace libcellml {

/**
* @brief The Entity class.
* Base class for all serialisable libCellML classes.
*/
class Entity
{
protected:
/**
* @brief Pure virtual serialise method.
* Pure virtual serialise method for serialising a CellML object to a std::string.
* @param format The format to serialise the object to.
* @return std::string representation of the object.
*/
virtual std::string serialise(libcellml::CELLML_FORMATS format) const = 0;

};

}

#endif /* LIBCELLML_LIBCELLML_ENTITY_H_ */


37 changes: 37 additions & 0 deletions src/api/libcellml/enumerations.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2015 University of Auckland
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Some license of other
*/

#ifndef LIBCELLML_LIBCELLML_ENUMERATIONS_H_
#define LIBCELLML_LIBCELLML_ENUMERATIONS_H_

/** @file */

namespace libcellml {

/**
* @brief The CELLML_FORMATS enum.
* Enum describing the formats that are available for
* serialisation.
*/
enum CELLML_FORMATS
{
CELLML_FORMAT_XML = 0 /**< XML format for CellML files. */
};

}

#endif /* LIBCELLML_LIBCELLML_ENUMERATIONS_H_ */

72 changes: 72 additions & 0 deletions src/api/libcellml/model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copyright 2015 University of Auckland
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Some license of other
*/

#ifndef LIBCELLML_LIBCELLML_MODEL_H_
#define LIBCELLML_LIBCELLML_MODEL_H_

#include <string>
#include <memory>

#include "libcellml/libcellml_export.h"
#include "libcellml/entity.h"

//! Everything in libCellML is in this namespace.
namespace libcellml {

/**
* @brief The Model class.
* The Model class is for representing a CellML Model.
*/
class LIBCELLML_EXPORT Model: public Entity
{
public:
/**
* @brief Model Constructor.
* Default Model constructor.
*/
Model();
/**
* @brief Model Destructor.
* Default Model destructor.
*/
~Model();

Model(Model&& rhs); /**< move constructor */
Model& operator=(Model&& rhs); /**< move assignment */

/**
* @brief serialise the Model.
* This method serialises the Model to a std:string representation in the
* desired format.
* @sa deserialise
* @param format The format to serialise the Model to.
* @return std::string representation of the Model in the given format.
*/
std::string serialise(libcellml::CELLML_FORMATS format) const;

private:

Model(const Model&) = delete; /**< non-copyable */
Model& operator=(const Model&) = delete; /**< non-copyable */

struct ModelImpl; /**< Forward declaration for pImpl idiom. */
std::unique_ptr<ModelImpl> mPimpl; /**< Private member to implementation pointer */
};

}

#endif /* LIBCELLML_LIBCELLML_MODEL_H_ */

24 changes: 24 additions & 0 deletions src/api/libcellml/module/libcellml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/*
Copyright 2015 University of Auckland

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Some license of other
*/

#ifndef LIBCELLML_LIBCELLML_MODULE_LIBCELLML_H_
#define LIBCELLML_LIBCELLML_MODULE_LIBCELLML_H_

#include <libcellml/version.h>
#include <libcellml/model.h>

#endif // LIBCELLML_LIBCELLML_MODULE_LIBCELLML_H_
6 changes: 3 additions & 3 deletions src/configure/libcellml_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ limitations under the License.Some license of other

namespace libcellml {

#define LIBCELLML_VERSION_MAJOR @LIBCELLML_VERSION_MAJOR@
#define LIBCELLML_VERSION_MINOR @LIBCELLML_VERSION_MINOR@
#define LIBCELLML_VERSION_PATCH @LIBCELLML_VERSION_PATCH@
#define LIBCELLML_VERSION_MAJOR @libCellML_VERSION_MAJOR@
#define LIBCELLML_VERSION_MINOR @libCellML_VERSION_MINOR@
#define LIBCELLML_VERSION_PATCH @libCellML_VERSION_PATCH@

static unsigned int LIBCELLML_LIBRARY_VERSION=@LIBCELLML_LIBRARY_VERSION@;
static const std::string LIBCELLML_LIBRARY_VERSION_STRING="@LIBCELLML_LIBRARY_VERSION_STRING@";
Expand Down
Loading

0 comments on commit 8c2ac73

Please sign in to comment.