Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
oayan authored Aug 17, 2020
1 parent 8c21e40 commit c8c7ac9
Show file tree
Hide file tree
Showing 16 changed files with 1,478 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
add_library(common STATIC
${CMAKE_CURRENT_SOURCE_DIR}/src/edge.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/noise.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/tree.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/block.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/cxxpool.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/edge.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/gaussiannoise.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/helpers.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/link.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/node.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/noise.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/threadpool.h
# ${CMAKE_CURRENT_SOURCE_DIR}/include/Common/tree.h
)

target_include_directories(common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(common PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/Common)
83 changes: 83 additions & 0 deletions Common/include/Common/block.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

#ifndef BLOCK_H
#define BLOCK_H

#include "link.h"

template <typename typeIn, typename typeOut>
class Block
{
public:
/**
* @brief Block Block class constructor
*/
Block();

/**
* @brief setInputLink assign an input link to block
* @param l constant pointer to link instance
*/
void setInputLink(Link<typeIn>* const l);

/**
* @brief setOutLink assign an output link to block
* @param l constant pouinter to link instance
*/
void setOutLink(Link<typeOut>* const l);

/**
* @brief update virtual method. Derived class overrides this method
*/
virtual void update() = 0;
protected:
virtual ~Block() {}
Link<typeIn>* inputLink;
Link<typeOut>* outputLink;

/**
* @brief read Getter method for reading the input link
* @return Returns input link value
*/
typeIn read();

/**
* @brief write Setter method for writing to the output link
* @param v Value to write
*/
void write(const typeOut& v);
};

template<typename typeIn, typename typeOut>
Block<typeIn, typeOut>::Block()
{

}

template<typename typeIn, typename typeOut>
void Block<typeIn, typeOut>::setInputLink(Link<typeIn> * const l)
{
inputLink = l;
}

template<typename typeIn, typename typeOut>
void Block<typeIn, typeOut>::setOutLink(Link<typeOut> * const l)
{
outputLink = l;
}

template<typename typeIn, typename typeOut>
typeIn Block<typeIn, typeOut>::read()
{
return inputLink->readValue();
}

template<typename typeIn, typename typeOut>
void Block<typeIn, typeOut>::write(const typeOut& v)
{
outputLink->setValue(v);
}

#endif // BLOCK_H
Loading

0 comments on commit c8c7ac9

Please sign in to comment.